diff --git a/app/routers/dashboard.py b/app/routers/dashboard.py index 9b4bc47..215b5ce 100644 --- a/app/routers/dashboard.py +++ b/app/routers/dashboard.py @@ -1,3 +1,4 @@ +from datetime import date, timedelta from fastapi import APIRouter, Request, Depends from fastapi.responses import HTMLResponse from fastapi.templating import Jinja2Templates @@ -13,6 +14,13 @@ router = APIRouter() templates = Jinja2Templates(directory="app/templates") +def _week_bounds() -> tuple[str, str]: + today = date.today() + monday = today - timedelta(days=today.weekday()) + sunday = monday + timedelta(days=6) + return monday.isoformat(), sunday.isoformat() + + @router.get("/", response_class=HTMLResponse) async def root_redirect(): from fastapi.responses import RedirectResponse @@ -21,6 +29,8 @@ async def root_redirect(): @router.get("/dashboard", response_class=HTMLResponse) async def dashboard(request: Request, user: User = Depends(get_current_user)): + week_start, week_end = _week_bounds() + async with async_session() as session: result = await session.execute( select(Workout) @@ -43,9 +53,23 @@ async def dashboard(request: Request, user: User = Depends(get_current_user)): ) current_phase = result.scalar_one_or_none() + result = await session.execute( + select(Workout) + .where( + Workout.user_id == user.id, + Workout.date >= week_start, + Workout.date <= week_end, + ) + .order_by(Workout.date) + ) + this_week = result.scalars().all() + return templates.TemplateResponse(request, "dashboard.html", { "user": user, "recent_workouts": recent_workouts, "latest_checkin": latest_checkin, "current_phase": current_phase, + "this_week": this_week, + "week_start": week_start, + "week_end": week_end, }) diff --git a/app/static/style.css b/app/static/style.css index ced289e..79c57df 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -37,10 +37,24 @@ .chat-input { display: flex; gap: 0.5rem; + align-items: flex-start; } -.chat-input input { +.chat-input textarea { flex: 1; + resize: vertical; + min-height: 2.5rem; +} + +.chat-input button { + width: auto; + padding: 0.5rem 1.5rem; + flex-shrink: 0; +} + +.chat-status { + margin-top: 0.25rem; + font-size: 0.85rem; } .nav-link.active { diff --git a/app/templates/chat.html b/app/templates/chat.html index ea32f37..6f89a38 100644 --- a/app/templates/chat.html +++ b/app/templates/chat.html @@ -13,38 +13,64 @@
- - + +
+

{% endblock %} diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index bb19893..0c331f9 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -27,6 +27,32 @@ {% endif %} +

This Week ({{ week_start }} — {{ week_end }})

+{% if this_week %} + + + + + + + + + + + {% for w in this_week %} + + + + + + + {% endfor %} + +
DayNameStatus
{{ w.date }}{{ w.name }}{{ w.status }}View
+{% else %} +

No workouts planned this week. Ask the AI Coach to plan your week.

+{% endif %} + {% if latest_checkin %}

Latest Morning Check-in

@@ -35,7 +61,7 @@
{% endif %} -

Recent Workouts

+

Past Workouts

{% if recent_workouts %}