diff --git a/apps/api/src/routes/portal.ts b/apps/api/src/routes/portal.ts index dc556c8..f7f5b07 100644 --- a/apps/api/src/routes/portal.ts +++ b/apps/api/src/routes/portal.ts @@ -142,10 +142,7 @@ portalRouter.get("/appointments", async (c) => { staff: a.staffId ? { id: staffMap[a.staffId]?.id, name: staffMap[a.staffId]?.name } : null, })); - const upcoming = appts.filter(a => a.startTime > now && a.status !== "cancelled"); - const past = appts.filter(a => a.startTime <= now || a.status === "cancelled"); - - return c.json({ upcoming, past }); + return c.json({ appointments: appts }); }); portalRouter.get("/pets", async (c) => { @@ -153,7 +150,7 @@ portalRouter.get("/pets", async (c) => { const clientId = c.get("portalClientId"); const clientPets = await db.select().from(pets).where(eq(pets.clientId, clientId)); - return c.json(clientPets.map(p => ({ id: p.id, name: p.name, breed: p.breed, weightKg: p.weightKg, dateOfBirth: p.dateOfBirth, photoKey: p.photoKey, groomingNotes: p.groomingNotes }))); + return c.json(clientPets.map(p => ({ id: p.id, name: p.name, breed: p.breed, weight: p.weightKg, birthDate: p.dateOfBirth, photoUrl: p.photoKey, notes: p.groomingNotes }))); }); portalRouter.get("/invoices", async (c) => { diff --git a/apps/web/src/portal/sections/PetProfiles.tsx b/apps/web/src/portal/sections/PetProfiles.tsx index f657e6a..e9fb07b 100644 --- a/apps/web/src/portal/sections/PetProfiles.tsx +++ b/apps/web/src/portal/sections/PetProfiles.tsx @@ -27,8 +27,7 @@ interface Appointment { } interface AppointmentsResponse { - upcoming: Appointment[]; - past: Appointment[]; + appointments: Appointment[]; } interface Props { @@ -46,7 +45,7 @@ function buildHeaders(sessionId: string | null): Record { export function PetProfiles({ sessionId, readOnly }: Props) { const [pets, setPets] = useState([]); - const [appointments, setAppointments] = useState({ upcoming: [], past: [] }); + const [appointments, setAppointments] = useState({ appointments: [] }); const [selectedPetId, setSelectedPetId] = useState(""); const [activeTab, setActiveTab] = useState<"info" | "medical" | "grooming" | "history">("info"); const [editingPetId, setEditingPetId] = useState(null); @@ -90,7 +89,7 @@ export function PetProfiles({ sessionId, readOnly }: Props) { }, [sessionId]); const selectedPet = pets.find(p => p.id === selectedPetId) ?? null; - const petHistory = appointments.past.filter(a => a.pet?.id === selectedPetId); + const petHistory = appointments.appointments.filter(a => a.pet?.id === selectedPetId && new Date(a.startTime) <= new Date()); const editingPet = editingPetId ? pets.find(p => p.id === editingPetId) ?? null : null; function handlePetSave(updatedPet: Pet) {