Coach Lifecycle Phase 3 — Pre / During / Post Session Experience
What & Why
Once a coach is assigned to a session, almost every interaction happens through — which is
6,607 lines and mixes pre-session prep, in-session attendance/notes, AI session plan, post-session athlete evaluations, and timesheet entry into one wall. Coaches lose track of "what do I do next?", and the AI session plan in particular is buried (the only reference is a toast on line 5008). This phase decomposes the SOF page into a clear three-stage experience and connects the post-session timesheet directly to the existing / payroll pipeline so payroll runs touch fewer hands.
This phase depends on Phase 1 (coach is approved, level/pay band set) and Phase 2 (coach is assigned to the session via the cleaned-up flow), but does not change those tables — it only reads from them.
Done looks like
- A coach navigating to their assigned session lands on Pre-session by default, with three clear tabs/stages: Before, During, After.
- Before shows: session metadata (date/time/location/group), confirmed athlete roster, equipment checklist, the AI session plan rendered prominently with a regenerate-with-notes button, and a "Mark ready" affordance.
- During shows: live attendance check-in (reusing existing QR-code system), quick-add session notes, the AI plan as a reference sidebar, and a single "End session" action that stamps the actual end time.
- After shows: a per-athlete evaluation entry flow (reuses existing route), a timesheet card pre-filled from check-in start/end times that the coach can edit (with a server-side cap of e.g. scheduledHours + 1h before requiring admin approval), and a Submit for payroll action that creates the row in PENDING state.
- The admin payroll queue surfaces submitted rows for one-click (already exists; we only wire the link from this surface).
- The 6,607-line is split into three sibling components (, , ) under a thin router page. Heavy shared state lives in a dedicated hook.
- Behavior parity: every existing feature still works (attendance, notes, eval entry, the existing AI plan generator, the existing report export). No data shape changes.
Out of scope
- Rewriting the AI prompt or session-plan generation logic — only its UI placement.
- Modifying schema or admin payroll batch UI. We only feed it from the post-session card.
- Phase 1 / Phase 2 surfaces.
- Mobile-specific layout polish (best-effort responsive, no dedicated mobile rebuild).
Steps
1.
Decompose the SOF page — Replace with a thin router that owns shared state via a new hook () and renders one of , , based on a param. Stage defaults to until session start time, once started, once ended. Coach can override via the tab bar. 2.
Pre-session screen — Surface AI session plan as the primary content (not a buried button). Add regenerate-with-notes, mark-ready, roster/equipment checklist. 3.
During-session screen — Lift existing attendance + notes UI here. Add an end-session action. 4.
Post-session screen — Lift existing athlete-evaluation UI here. Add a new
Timesheet card: pre-filled from session start/end, editable, validated server-side, and a Submit-for-payroll button that POSTs to a new (or extended) route which writes a PENDING row tied to the assignment. 5.
Server: timesheet submission endpoint — New (or extend an existing route). Requires the requester to be the assigned coach; validates hours; idempotent on . On success returns the created row. 6.
Wire payroll handoff — On the admin payroll page, show submitted-but-pending rows from this session with one-click . Reuse existing endpoints; only UI wiring. 7.
e2e coverage — A new spec walks a coach through Pre → During → After and asserts the AI plan renders pre-session, attendance is captured during, and the timesheet POST creates a PENDING row with the correct rate (event override → coach level → CUSTOM).
Architectural constraints
- Stage transitions are advisory, not enforced — a coach can always switch tabs (no time-locked UI).
- Timesheet submission must be IDEMPOTENT: re-submitting from After should update the existing PENDING row, not create duplicates, and is REJECTED once the row is .
- The hourly rate fallback chain stays exactly as in — event override → coach level → CUSTOM, default 20.
- All three sub-screens MUST stay under (or its current equivalent) and the assignment ownership check on the route layer is non-negotiable.
- Keep s stable on every interactive element (mirroring the existing convention) so tests stay readable.
- No changes to shape, no changes to the AI plan generation pipeline, no changes to evaluation submission contracts.
Relevant files
- - - - - - - - - -
No comments:
Post a Comment