fix: map coach profile fields to match API contract #205

Merged
forgejo_admin merged 1 commit from 285-coach-profile-contract into main 2026-04-03 22:25:03 +00:00

Summary

Fix two field mapping bugs on the coach profile page where the frontend read fields that don't exist in the API response contract.

Changes

  • src/routes/(app)/coaches/[id]/+page.svelte — changed coach.title to coach.role to match CoachProfileResponse.role. Replaced coach.team_name with coach.teams?.[0]?.name since the API returns a teams array, not a flat team_name field. Updated the fallback placeholder object to match.

Test Plan

  • npm run check passes with 0 errors (7 pre-existing a11y warnings unrelated to this change)
  • Verify coach profile page displays the correct role label and team name from the API response

Review Checklist

  • No unrelated changes
  • svelte-check passes with 0 errors
  • Field names match API contract (CoachProfileResponse)
  • Fallback placeholder updated to use role instead of title
## Summary Fix two field mapping bugs on the coach profile page where the frontend read fields that don't exist in the API response contract. ## Changes - `src/routes/(app)/coaches/[id]/+page.svelte` — changed `coach.title` to `coach.role` to match `CoachProfileResponse.role`. Replaced `coach.team_name` with `coach.teams?.[0]?.name` since the API returns a `teams` array, not a flat `team_name` field. Updated the fallback placeholder object to match. ## Test Plan - `npm run check` passes with 0 errors (7 pre-existing a11y warnings unrelated to this change) - Verify coach profile page displays the correct role label and team name from the API response ## Review Checklist - [x] No unrelated changes - [x] svelte-check passes with 0 errors - [x] Field names match API contract (`CoachProfileResponse`) - [x] Fallback placeholder updated to use `role` instead of `title` ## Related Notes - Spike: forgejo_admin/basketball-api#278 (Mismatch 8) ## Related - Closes forgejo_admin/basketball-api#285
fix: map coach profile fields to match API contract (role, team_name)
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
11bb081fe5
The coach profile page read coach.title but the API returns coach.role,
and used coach.team_name which does not exist in the API response.
Now reads coach.role directly and derives team name from coach.teams[0].name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

PR #205 Review

DOMAIN REVIEW

Tech stack: SvelteKit (.svelte component)

Contract verification: I cross-referenced the field mappings against the API source at /home/ldraney/basketball-api/src/basketball_api/routes/coaches_api.py:

  • CoachProfileResponse has role: str -- confirmed. The old coach.title field does not exist in the contract. Fix is correct.
  • CoachProfileResponse has teams: list[CoachTeamResponse] where CoachTeamResponse has name: str -- confirmed. The old coach.team_name field does not exist. Fix to coach.teams?.[0]?.name is correct.
  • Optional chaining on coach.teams?.[0]?.name in the {#if} guard means the fallback placeholder (which lacks a teams array) is handled safely -- the block simply won't render. The inner coach.teams[0].name is protected by the truthy {#if} guard. No runtime error risk.
  • Fallback placeholder updated: title replaced with role, team_name removed. Consistent with the contract.

Accessibility: No new a11y concerns introduced. Existing structure preserved.

Scope: Exactly 1 file, 4 additions, 5 deletions. Tightly scoped to the two field mappings called out in the issue.

BLOCKERS

None.

This is a pure field-rename fix with no new functionality, so the "new functionality must have tests" blocker does not apply. The PR body confirms npm run check passes with 0 errors.

NITS

  1. The fallback placeholder could include teams: [] for completeness, so the shape matches the API contract even in the error path. Non-blocking since optional chaining handles it.

SOP COMPLIANCE

  • Branch named after issue: 285-coach-profile-contract follows {issue-number}-{kebab-case-purpose}
  • PR body follows template: Summary, Changes, Test Plan, Review Checklist, Related sections present
  • Related references spike #278 and closes #285
  • No secrets committed
  • No unrelated changes (1 file, surgical fix)
  • Commit message is descriptive (fix: map coach profile fields to match API contract)

PROCESS OBSERVATIONS

  • Low change-failure risk: minimal diff, field renames only, no logic changes.
  • The spike reference (basketball-api#278) provides good traceability for the audit that identified these mismatches.
  • This is a cross-repo fix (issue on basketball-api, work on westside-landing). The PR body documents this clearly.

VERDICT: APPROVED

## PR #205 Review ### DOMAIN REVIEW **Tech stack**: SvelteKit (`.svelte` component) **Contract verification**: I cross-referenced the field mappings against the API source at `/home/ldraney/basketball-api/src/basketball_api/routes/coaches_api.py`: - `CoachProfileResponse` has `role: str` -- confirmed. The old `coach.title` field does not exist in the contract. Fix is correct. - `CoachProfileResponse` has `teams: list[CoachTeamResponse]` where `CoachTeamResponse` has `name: str` -- confirmed. The old `coach.team_name` field does not exist. Fix to `coach.teams?.[0]?.name` is correct. - Optional chaining on `coach.teams?.[0]?.name` in the `{#if}` guard means the fallback placeholder (which lacks a `teams` array) is handled safely -- the block simply won't render. The inner `coach.teams[0].name` is protected by the truthy `{#if}` guard. No runtime error risk. - Fallback placeholder updated: `title` replaced with `role`, `team_name` removed. Consistent with the contract. **Accessibility**: No new a11y concerns introduced. Existing structure preserved. **Scope**: Exactly 1 file, 4 additions, 5 deletions. Tightly scoped to the two field mappings called out in the issue. ### BLOCKERS None. This is a pure field-rename fix with no new functionality, so the "new functionality must have tests" blocker does not apply. The PR body confirms `npm run check` passes with 0 errors. ### NITS 1. The fallback placeholder could include `teams: []` for completeness, so the shape matches the API contract even in the error path. Non-blocking since optional chaining handles it. ### SOP COMPLIANCE - [x] Branch named after issue: `285-coach-profile-contract` follows `{issue-number}-{kebab-case-purpose}` - [x] PR body follows template: Summary, Changes, Test Plan, Review Checklist, Related sections present - [x] Related references spike #278 and closes #285 - [x] No secrets committed - [x] No unrelated changes (1 file, surgical fix) - [x] Commit message is descriptive (`fix: map coach profile fields to match API contract`) ### PROCESS OBSERVATIONS - Low change-failure risk: minimal diff, field renames only, no logic changes. - The spike reference (basketball-api#278) provides good traceability for the audit that identified these mismatches. - This is a cross-repo fix (issue on basketball-api, work on westside-landing). The PR body documents this clearly. ### VERDICT: APPROVED
forgejo_admin deleted branch 285-coach-profile-contract 2026-04-03 22:25:03 +00:00
Sign in to join this conversation.
No reviewers
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
forgejo_admin/westside-app!205
No description provided.