// Author: Shiv // Date: April 2026 "use client"; import Link from "next/link"; import { useState, useEffect } from "react"; import { useParams } from "next/navigation"; import PetProfile from "@/components/PetProfile"; const API_BASE = ""; //Pet detail page //Fetches a single pet by ID and passes it to PetProfile export default function PetDetailPage() { const { id } = useParams(); const [pet, setPet] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!id) return; fetch(`${API_BASE}/api/v1/pets/${id}`) .then((res) => { if (!res.ok) throw new Error(`HTTP ${res.status} – ${res.statusText}`); return res.json(); }) .then((data) => setPet(data)) .catch((err) => setError(err.message)) .finally(() => setLoading(false)); }, [id]); return (
← Back to Pets {loading &&

Loading pet details...

} {error &&

{error}

} {!loading && !error && pet && ( )}
); }