My Pets
- {pets.length === 0 ? ( -- You haven't added any pets yet.{" "} - - Add your first pet - -
- ) : ( --
- {pets.map((pet) => (
-
- - {pet.name} - - {pet.species.name} - - - ))} -
diff --git a/src/app/(app)/pets/PetGrid.tsx b/src/app/(app)/pets/PetGrid.tsx new file mode 100644 index 0000000..bb31846 --- /dev/null +++ b/src/app/(app)/pets/PetGrid.tsx @@ -0,0 +1,67 @@ +"use client"; + +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { PetCard } from "@/components/pet/PetCard"; +import { Button } from "@/components/ui/button"; +import { useActivePet } from "@/context/ActivePetContext"; + +/** + * PetGrid — client island that renders the My Pets card grid with active pet state. + * Server page fetches data; this island handles interactivity (pet selection). + */ + +type Pet = { + id: string; + name: string; + avatarKey?: string | null; + species: { id: string; name: string }; + breed: { id: string; name: string } | null; +}; + +interface PetGridProps { + pets: Pet[]; +} + +export function PetGrid({ pets }: PetGridProps) { + const { activePetId, setActivePet } = useActivePet(); + const router = useRouter(); + + if (pets.length === 0) { + return ( +
Add your first pet
++ Give your pet their own profile on OnlyPets. +
+ +Danger zone
+ ++ Managed by @{ownerUsername} +
+ + {/* Edit link — base-nova Button doesn't support asChild; use Link with button styles */} + + Edit profile + +{pet.bio}
+{pet.adoptionStory}
++ No posts yet +
+- You haven't added any pets yet.{" "} - - Add your first pet - -
- ) : ( -Your pet will be their own star on OnlyPets.
- {/* PetForm goes here — Plan 03 */} -