From 7f59e42a905af62fbedfe8ec06b66fe6ed6a493c Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 8 Mar 2026 22:53:59 -0500 Subject: [PATCH] Add DogDetail page --- client/src/pages/DogDetail.jsx | 145 +++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 client/src/pages/DogDetail.jsx diff --git a/client/src/pages/DogDetail.jsx b/client/src/pages/DogDetail.jsx new file mode 100644 index 0000000..af61ae5 --- /dev/null +++ b/client/src/pages/DogDetail.jsx @@ -0,0 +1,145 @@ +import { useEffect, useState } from 'react' +import { useParams, Link } from 'react-router-dom' +import { Dog, GitBranch, Edit, Trash2 } from 'lucide-react' +import axios from 'axios' + +function DogDetail() { + const { id } = useParams() + const [dog, setDog] = useState(null) + const [loading, setLoading] = useState(true) + + useEffect(() => { + fetchDog() + }, [id]) + + const fetchDog = async () => { + try { + const res = await axios.get(`/api/dogs/${id}`) + setDog(res.data) + setLoading(false) + } catch (error) { + console.error('Error fetching dog:', error) + setLoading(false) + } + } + + if (loading) { + return
Loading...
+ } + + if (!dog) { + return
Dog not found
+ } + + return ( +
+
+

{dog.name}

+
+ + + View Pedigree + + +
+
+ +
+
+

Basic Information

+
+
+ Breed: {dog.breed} +
+
+ Sex: {dog.sex === 'male' ? 'Male ♂' : 'Female ♀'} +
+ {dog.birth_date && ( +
+ Birth Date: {new Date(dog.birth_date).toLocaleDateString()} +
+ )} + {dog.color && ( +
+ Color: {dog.color} +
+ )} + {dog.registration_number && ( +
+ Registration: {dog.registration_number} +
+ )} + {dog.microchip && ( +
+ Microchip: {dog.microchip} +
+ )} +
+
+ +
+

Photos

+ {dog.photo_urls && dog.photo_urls.length > 0 ? ( +
+ {dog.photo_urls.map((url, index) => ( + {`${dog.name} + ))} +
+ ) : ( +
+ +

No photos uploaded

+
+ )} +
+
+ + {dog.notes && ( +
+

Notes

+

{dog.notes}

+
+ )} + +
+

Parents

+
+
+

Sire (Father)

+ {dog.sire ? ( + {dog.sire.name} + ) : ( +

Unknown

+ )} +
+
+

Dam (Mother)

+ {dog.dam ? ( + {dog.dam.name} + ) : ( +

Unknown

+ )} +
+
+
+ + {dog.offspring && dog.offspring.length > 0 && ( +
+

Offspring ({dog.offspring.length})

+
+ {dog.offspring.map(child => ( + + {child.name} - {child.sex === 'male' ? '♂' : '♀'} + + ))} +
+
+ )} +
+ ) +} + +export default DogDetail \ No newline at end of file