From d1ff61a9098f448bdcafd65827968062f7c32cbb Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 19 Apr 2026 02:11:16 +0000 Subject: [PATCH] fix(gro-817): guard appointments.past and map API pet field names - Guard appointments.past with fallback: apptsData?.upcoming || [], apptsData?.past || [] to prevent TypeError when API returns unexpected shape - Map API fields (weightKg, dateOfBirth, photoKey, groomingNotes) to interface fields (weight, birthDate, photoUrl, notes) expected by UI Co-Authored-By: Paperclip --- apps/web/src/portal/sections/PetProfiles.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/web/src/portal/sections/PetProfiles.tsx b/apps/web/src/portal/sections/PetProfiles.tsx index f657e6a..c93a939 100644 --- a/apps/web/src/portal/sections/PetProfiles.tsx +++ b/apps/web/src/portal/sections/PetProfiles.tsx @@ -71,10 +71,18 @@ export function PetProfiles({ sessionId, readOnly }: Props) { } const petsData = await petsRes.json(); - const apptsData: AppointmentsResponse = await apptsRes.json(); + const apptsData = await apptsRes.json(); - setPets(petsData); - setAppointments(apptsData); + setPets(petsData.map((p: { id: string; name: string; breed: string; weightKg: number; dateOfBirth: string; photoKey: string | null; groomingNotes: string | null }) => ({ + id: p.id, + name: p.name, + breed: p.breed, + weight: p.weightKg, + birthDate: p.dateOfBirth, + photoUrl: p.photoKey ?? null, + notes: p.groomingNotes ?? null, + }))); + setAppointments({ upcoming: apptsData?.upcoming || [], past: apptsData?.past || [] }); if (petsData.length > 0 && !selectedPetId) { setSelectedPetId(petsData[0].id);