import { useEffect, useState } from "react"; import type { MedicalAlert, PetProfileSummary } from "@groombook/types"; import { PetPhotoDisplay } from "./PetPhotoDisplay.js"; interface Props { petId: string; } type LoadState = | { status: "idle" } | { status: "loading" } | { status: "loaded"; data: PetProfileSummary } | { status: "error"; message: string }; function computeAge(dateOfBirth: string | null): string | null { if (!dateOfBirth) return null; const birth = new Date(dateOfBirth); const now = new Date(); const totalMonths = (now.getFullYear() - birth.getFullYear()) * 12 + (now.getMonth() - birth.getMonth()); if (totalMonths < 1) return "<1 mo"; if (totalMonths < 12) return `${totalMonths} mo`; const years = Math.floor(totalMonths / 12); const months = totalMonths % 12; if (months === 0) return `${years} yr`; return `${years} yr ${months} mo`; } function TemperamentDots({ score }: { score: number }) { return (