Fix public schedule page to use actual API response schema #206

Closed
opened 2026-04-03 22:28:14 +00:00 by forgejo_admin · 1 comment
Contributor

Type

Bug

Lineage

Discovered while seeding practice_schedules table (basketball-api#279). API returns 17 practices correctly, but public schedule page renders nothing because field names don't match.

Repo

forgejo_admin/westside-landing

What Broke

The public schedule page at /schedule was built against hardcoded fallback data shapes, not the actual /public/schedule API response. With real data in the database, practices and events don't render because the frontend references fields that don't exist in the API response.

Repro Steps

  1. Visit /schedule on westside-app
  2. Toggle to Kings — no practices shown (or only fallback data)
  3. Check browser console — no errors, but p.group is undefined so all filter results are empty

Field Mismatches

Frontend expects API returns Impact
p.group === 'travel' / 'local' no group field All practices filtered out
p.team_name p.label groupByTeam returns "Practice" for all
p.day_of_week = "Monday" (string) p.day_of_week = 0 (integer) Shows "0" instead of day name
p.start_time = "7:00 PM" p.start_time = "19:00" .replace(':00','') gives "19" not "7 PM"
event.name event.title Event names don't render
event.date event.start_date / event.end_date Event dates don't render

Expected Behavior

Public schedule page renders all 17 practices and any events from the API, with human-readable day names and 12-hour time formatting.

Environment

  • Cluster/namespace: prod
  • Service: westside-landing frontend (local dir: ~/westside-app)
  • API: basketball-api /public/schedule endpoint (confirmed returning 17 practices)

File Targets

Files the agent should modify:

  • src/routes/(public)/schedule/+page.svelte — fix field mappings, add day/time formatters, classify travel vs local

Reference (correct implementation):

  • src/routes/(app)/admin/schedule/+page.svelte — already uses correct API schema (DAY_NAMES[], p.label, start_date, groupByLabel())

Files the agent should NOT touch:

  • src/lib/public-api.js — API client is correct
  • src/lib/api.js — admin API client is correct
  • Any backend files — API response is correct

Acceptance Criteria

  • Kings practices render in two groups: Travel Teams (17U Elite, 17U Select, 16U Elite) and Local Teams (17U Local, 16U Local)
  • Queens practices render (17U Elite Queens, 16U Elite Queens)
  • Day names show as "Monday", "Tuesday" etc, not integers
  • Times show as "7:00 PM" not "19:00"
  • Events render with correct title, dates, location when events exist
  • Fallback data still works when API is unavailable
  • Travel/local classification derived from team label pattern (contains "Local" = local, else travel)

Test Expectations

  • Visual: /schedule shows all Kings practices grouped correctly
  • Visual: Queens tab shows Queens practices (not just "contact director" message)
  • Visual: day names and times are human-readable
  • Verify: fallback still triggers when API is down
  • Run command: npm run build (no build errors)

Constraints

  • Match the admin page's approach: use DAY_NAMES[] array for day mapping, format times with a helper
  • Keep fallback data as-is for resilience
  • No changes to API or backend — this is purely frontend field mapping
  • Pure CSS vars, no Tailwind

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • westside-basketball — project this affects
  • forgejo_admin/basketball-api#279 — data seeding ticket that exposed this bug
### Type Bug ### Lineage Discovered while seeding `practice_schedules` table (basketball-api#279). API returns 17 practices correctly, but public schedule page renders nothing because field names don't match. ### Repo `forgejo_admin/westside-landing` ### What Broke The public schedule page at `/schedule` was built against hardcoded fallback data shapes, not the actual `/public/schedule` API response. With real data in the database, practices and events don't render because the frontend references fields that don't exist in the API response. ### Repro Steps 1. Visit `/schedule` on westside-app 2. Toggle to Kings — no practices shown (or only fallback data) 3. Check browser console — no errors, but `p.group` is undefined so all filter results are empty ### Field Mismatches | Frontend expects | API returns | Impact | |---|---|---| | `p.group === 'travel'` / `'local'` | no `group` field | All practices filtered out | | `p.team_name` | `p.label` | groupByTeam returns "Practice" for all | | `p.day_of_week` = "Monday" (string) | `p.day_of_week` = 0 (integer) | Shows "0" instead of day name | | `p.start_time` = "7:00 PM" | `p.start_time` = "19:00" | `.replace(':00','')` gives "19" not "7 PM" | | `event.name` | `event.title` | Event names don't render | | `event.date` | `event.start_date` / `event.end_date` | Event dates don't render | ### Expected Behavior Public schedule page renders all 17 practices and any events from the API, with human-readable day names and 12-hour time formatting. ### Environment - Cluster/namespace: prod - Service: westside-landing frontend (local dir: ~/westside-app) - API: basketball-api `/public/schedule` endpoint (confirmed returning 17 practices) ### File Targets Files the agent should modify: - `src/routes/(public)/schedule/+page.svelte` — fix field mappings, add day/time formatters, classify travel vs local Reference (correct implementation): - `src/routes/(app)/admin/schedule/+page.svelte` — already uses correct API schema (`DAY_NAMES[]`, `p.label`, `start_date`, `groupByLabel()`) Files the agent should NOT touch: - `src/lib/public-api.js` — API client is correct - `src/lib/api.js` — admin API client is correct - Any backend files — API response is correct ### Acceptance Criteria - [ ] Kings practices render in two groups: Travel Teams (17U Elite, 17U Select, 16U Elite) and Local Teams (17U Local, 16U Local) - [ ] Queens practices render (17U Elite Queens, 16U Elite Queens) - [ ] Day names show as "Monday", "Tuesday" etc, not integers - [ ] Times show as "7:00 PM" not "19:00" - [ ] Events render with correct title, dates, location when events exist - [ ] Fallback data still works when API is unavailable - [ ] Travel/local classification derived from team label pattern (contains "Local" = local, else travel) ### Test Expectations - [ ] Visual: `/schedule` shows all Kings practices grouped correctly - [ ] Visual: Queens tab shows Queens practices (not just "contact director" message) - [ ] Visual: day names and times are human-readable - [ ] Verify: fallback still triggers when API is down - Run command: `npm run build` (no build errors) ### Constraints - Match the admin page's approach: use `DAY_NAMES[]` array for day mapping, format times with a helper - Keep fallback data as-is for resilience - No changes to API or backend — this is purely frontend field mapping - Pure CSS vars, no Tailwind ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `westside-basketball` — project this affects - `forgejo_admin/basketball-api#279` — data seeding ticket that exposed this bug
Author
Contributor

Scope Review: READY

Review note: review-757-2026-04-03

All file targets verified — field mismatches confirmed in code exactly as described. Admin reference implementation has correct patterns (DAY_NAMES[], formatTime(), groupByLabel(), start_date). Single-file fix, well under 5-minute agent threshold.

  • [SCOPE] Create architecture note arch-landing-site (non-blocking, does not affect execution)
## Scope Review: READY Review note: `review-757-2026-04-03` All file targets verified — field mismatches confirmed in code exactly as described. Admin reference implementation has correct patterns (DAY_NAMES[], formatTime(), groupByLabel(), start_date). Single-file fix, well under 5-minute agent threshold. - **[SCOPE]** Create architecture note `arch-landing-site` (non-blocking, does not affect execution)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/westside-app#206
No description provided.