fix: map nested parent fields for player profile display #204

Merged
forgejo_admin merged 1 commit from 203-parent-phone-profile into main 2026-04-03 16:21:42 +00:00
Contributor

Summary

The player profile page accessed parent_phone, parent_email, and parent_name as flat fields on the player object, but the API returns them nested under player.parent. Added a mapping after the API fetch to bridge the two shapes.

Changes

  • src/routes/(app)/players/[id]/+page.svelte -- after apiFetch, map player.parent.{name,phone,email} to flat player.parent_{name,phone,email} fields expected by the template

Test Plan

  • Log in as admin, navigate to player 111 (Aleiyah Apaisa) -- Admin Actions card should show Parent Contact phone 3852329501 and Parent Email apaisasandra@gmail.com
  • Mock player (id 999) still renders parent info correctly (uses flat mock data, unaffected)
  • Coach roster view (/coach) still works (uses its own data shape, unaffected)
  • Build passes (npm run build)

Review Checklist

  • Build passes (npm run build)
  • Only target file modified per issue spec
  • Mock data path (id 999) unaffected -- returns before API fetch
  • Error fallback path unaffected -- already sets flat empty strings
  • Closes #203
  • Companion: basketball-api#276 (admin list endpoint -- independent fix)
## Summary The player profile page accessed `parent_phone`, `parent_email`, and `parent_name` as flat fields on the player object, but the API returns them nested under `player.parent`. Added a mapping after the API fetch to bridge the two shapes. ## Changes - `src/routes/(app)/players/[id]/+page.svelte` -- after `apiFetch`, map `player.parent.{name,phone,email}` to flat `player.parent_{name,phone,email}` fields expected by the template ## Test Plan - [ ] Log in as admin, navigate to player 111 (Aleiyah Apaisa) -- Admin Actions card should show Parent Contact phone `3852329501` and Parent Email `apaisasandra@gmail.com` - [ ] Mock player (id 999) still renders parent info correctly (uses flat mock data, unaffected) - [ ] Coach roster view (`/coach`) still works (uses its own data shape, unaffected) - [ ] Build passes (`npm run build`) ## Review Checklist - [x] Build passes (`npm run build`) - [x] Only target file modified per issue spec - [x] Mock data path (id 999) unaffected -- returns before API fetch - [x] Error fallback path unaffected -- already sets flat empty strings ## Related Notes - Closes #203 - Companion: basketball-api#276 (admin list endpoint -- independent fix)
fix: map nested parent fields from API response to flat template fields
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
42c2c2a938
The player profile page accessed parent_phone, parent_email, and
parent_name as flat fields, but the API returns them nested under a
parent object. This mapping bridges the two shapes so parent contact
info renders correctly in the Admin Actions card.

Closes #203

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

QA Review -- PR #204

Diff Analysis

  • 1 file changed, 6 additions, 0 deletions
  • src/routes/(app)/players/[id]/+page.svelte -- adds parent field mapping after API fetch

Findings

Correctness: PASS

  • Maps player.parent.{name,phone,email} to flat player.parent_{name,phone,email} fields
  • Guard if (player.parent) prevents null reference when parent data is absent
  • Fallback to empty string via || '' matches existing error-path defaults (lines 76-78)
  • Mock path (id 999) returns before API fetch -- unaffected
  • Error catch path already sets flat empty strings -- unaffected

Scope: PASS

  • Only touches the file specified in issue #203 file targets
  • Does not touch admin players list or coach roster (explicitly excluded per issue)

Build: PASS

  • PR author confirmed npm run build succeeds

Nits: None

  • Code style matches surrounding indentation (tabs)
  • Comment is descriptive and explains the mapping rationale

VERDICT: APPROVED

## QA Review -- PR #204 ### Diff Analysis - **1 file changed**, 6 additions, 0 deletions - `src/routes/(app)/players/[id]/+page.svelte` -- adds parent field mapping after API fetch ### Findings **Correctness: PASS** - Maps `player.parent.{name,phone,email}` to flat `player.parent_{name,phone,email}` fields - Guard `if (player.parent)` prevents null reference when parent data is absent - Fallback to empty string via `|| ''` matches existing error-path defaults (lines 76-78) - Mock path (id 999) returns before API fetch -- unaffected - Error catch path already sets flat empty strings -- unaffected **Scope: PASS** - Only touches the file specified in issue #203 file targets - Does not touch admin players list or coach roster (explicitly excluded per issue) **Build: PASS** - PR author confirmed `npm run build` succeeds **Nits: None** - Code style matches surrounding indentation (tabs) - Comment is descriptive and explains the mapping rationale ### VERDICT: APPROVED
Author
Contributor

PR #204 Review

DOMAIN REVIEW

Stack: SvelteKit (adapter-static), Svelte component (+page.svelte)

This is a 6-line bug fix that bridges a data shape mismatch between the API response (nested player.parent object) and the template (which expects flat player.parent_name, player.parent_phone, player.parent_email fields).

The implementation is correct:

  • Guard if (player.parent) prevents errors when parent data is absent
  • Fallback || '' ensures the template always gets a string, avoiding undefined rendering
  • Placement after apiFetch and before template render is the right spot
  • Mock path (id 999) returns before the API fetch and is unaffected
  • Error fallback path already sets flat empty strings and is unaffected

BLOCKERS

None.

  • No new functionality requiring test coverage -- this is a targeted data mapping fix in an existing Svelte component
  • No user input involved -- data sourced from the app's own authenticated API
  • No secrets or credentials
  • No DRY violation in auth/security paths

NITS

  1. Data contract translation layer -- The root cause is a mismatch between API shape (player.parent.name) and template shape (player.parent_name). A more durable long-term approach would be updating the template to read nested fields directly (player.parent?.name), eliminating the translation. However, that is out of scope for this bug fix and would touch more lines. Worth tracking as a follow-up if the pattern appears in other pages.

  2. Silent fallback -- || '' will coerce null, undefined, and empty string identically. For display purposes this is fine. If downstream logic ever needs to distinguish "no parent" from "parent with empty name," this would need revisiting. Not a concern today.

SOP COMPLIANCE

  • Branch named after issue (203-parent-phone-profile)
  • PR body follows template (Summary, Changes, Test Plan, Related)
  • Related references parent issue (Closes #203) and companion PR (basketball-api#276)
  • No secrets committed
  • Single file changed, no scope creep
  • Commit message is descriptive

PROCESS OBSERVATIONS

  • Clean, minimal fix. 1 file, 6 lines, directly addresses the reported bug.
  • Companion API fix (basketball-api#276) noted as independent -- good cross-repo awareness.
  • Test plan is manual but appropriate for a Svelte component data mapping fix in an adapter-static app.
  • Change failure risk: low. The guard clause and fallbacks make this safe even if the API shape changes again.

VERDICT: APPROVED

## PR #204 Review ### DOMAIN REVIEW **Stack**: SvelteKit (adapter-static), Svelte component (`+page.svelte`) This is a 6-line bug fix that bridges a data shape mismatch between the API response (nested `player.parent` object) and the template (which expects flat `player.parent_name`, `player.parent_phone`, `player.parent_email` fields). The implementation is correct: - Guard `if (player.parent)` prevents errors when parent data is absent - Fallback `|| ''` ensures the template always gets a string, avoiding `undefined` rendering - Placement after `apiFetch` and before template render is the right spot - Mock path (id 999) returns before the API fetch and is unaffected - Error fallback path already sets flat empty strings and is unaffected ### BLOCKERS None. - No new functionality requiring test coverage -- this is a targeted data mapping fix in an existing Svelte component - No user input involved -- data sourced from the app's own authenticated API - No secrets or credentials - No DRY violation in auth/security paths ### NITS 1. **Data contract translation layer** -- The root cause is a mismatch between API shape (`player.parent.name`) and template shape (`player.parent_name`). A more durable long-term approach would be updating the template to read nested fields directly (`player.parent?.name`), eliminating the translation. However, that is out of scope for this bug fix and would touch more lines. Worth tracking as a follow-up if the pattern appears in other pages. 2. **Silent fallback** -- `|| ''` will coerce `null`, `undefined`, and empty string identically. For display purposes this is fine. If downstream logic ever needs to distinguish "no parent" from "parent with empty name," this would need revisiting. Not a concern today. ### SOP COMPLIANCE - [x] Branch named after issue (`203-parent-phone-profile`) - [x] PR body follows template (Summary, Changes, Test Plan, Related) - [x] Related references parent issue (`Closes #203`) and companion PR (`basketball-api#276`) - [x] No secrets committed - [x] Single file changed, no scope creep - [x] Commit message is descriptive ### PROCESS OBSERVATIONS - Clean, minimal fix. 1 file, 6 lines, directly addresses the reported bug. - Companion API fix (`basketball-api#276`) noted as independent -- good cross-repo awareness. - Test plan is manual but appropriate for a Svelte component data mapping fix in an adapter-static app. - Change failure risk: low. The guard clause and fallbacks make this safe even if the API shape changes again. ### VERDICT: APPROVED
forgejo_admin deleted branch 203-parent-phone-profile 2026-04-03 16:21:42 +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
ldraney/westside-app!204
No description provided.