fix: replace hardcoded practice schedules with DB query #50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "49-dynamic-practice-schedules"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces three hardcoded practice schedule blocks (boys travel, girls travel, local) with a single dynamic
{#each}loop that fetches from thepractice_schedulestable. This fixes the 16U Local schedule showing Friday instead of Tuesday/Wednesday, and means schedule changes no longer require code deploys.Changes
src/routes/contract/[token]/+page.server.ts: Added second SQL query joiningpractice_schedulesviaplayer_teamsto fetch active schedules for the player's team. AddedformatTimeandformatTimeRangehelpers to convert 24h times ("18:00") to friendly format ("6 – 8 PM"). Returnspractices[]in page data.src/routes/contract/[token]/+page.svelte: Replaced all three hardcoded practice schedule blocks (~40 lines of static HTML with team-name conditionals) with a single shared{#each practices}loop. Falls back to "Practice schedule will be communicated by your coach." when no rows exist.src/lib/types.ts: AddedPracticeScheduleinterface for the return type.Test Plan
npm run buildcleanpractice_schedulesrows — should show dynamic scheduleReview Checklist
npm run build).schedule-row,.schedule-day,.schedule-detailCSS classes preservedRelated Notes
Related
QA Review — PR #50
Scope Check
The PR targets issue #49 (dynamic practice schedules). The branch includes a second commit (
95f10d3 feat: add age-based team reassignment clause) that is out of scope for #49 — it adds Queens color CSS, Nike EYBL rename, and an age-based reassignment paragraph. This is pre-existing on the branch and not part of the practice schedule work, but it ships with this PR. Consider rebasing to isolate, or accept as-is if that content was already approved.Code Review
src/routes/contract/[token]/+page.server.tspractice_schedulesviaplayer_teamsandplayerscorrectly. Filtersis_active = true. Orders byday_of_week, start_time. Clean.formatTimehandles 12h conversion correctly (midnight=12 AM, noon=12 PM, hours >12 subtract). Minutes preserved when non-zero.formatTimeRangeomits redundant AM/PM when both times share the same period. Good UX.minutevariable informatTimeis computed but never used (line:const minute = parseInt(minuteStr || '0')). It's only used implicitly via theminute === 0check further down — but wait, that check is actuallyif (minute === 0)which does use it. Correct.src/routes/contract/[token]/+page.svelte{#each practices}loops. DRY improvement.notesfield renders insideschedule-optionalspan with parentheses. Matches the existing pattern for optional items..schedule-row,.schedule-day,.schedule-detailpreserved. No visual regression expected.src/lib/types.tsPracticeScheduleinterface added with all needed fields. Clean.Potential Issues
practice_schedulestable has atenant_idcolumn per the issue schema. If multiple tenants share the database, this could return schedules from the wrong tenant. Currently likely single-tenant so low risk, but worth noting.practice_schedulestable doesn't exist yet. If this PR deploys before the table is seeded, the query will throw a Postgres error and the contract page will 500. The table already exists per the issue description, so this is fine for now.Nits
\u2013(en-dash) informatTimeRangeis a Unicode literal. Works correctly but the hardcoded HTML used–. No functional difference since this renders as text interpolation, not raw HTML.VERDICT: APPROVED
Core practice schedule changes are correct, well-structured, and the build passes. The out-of-scope Queens commit is a minor branch hygiene issue, not a blocker.
13fd5318e1todb4b24ae8f