11import React from "react" ;
22import { useParams , Link } from "react-router-dom" ;
33import { ArrowLeft , MapPin , Ruler , Utensils , Shield , Info } from "lucide-react" ;
4- import { getAnimalById , categories } from "../../data/animals" ;
4+
5+ import { getAnimalBySlug } from "~features/Animal/Animal" ;
6+ import { getCategoryByName } from "~features/AnimalCategory/AnimalCategory" ;
57
68export default function AnimalDetailPage ( ) {
79 const { animalId } = useParams < { animalId : string } > ( ) ;
@@ -10,13 +12,13 @@ export default function AnimalDetailPage() {
1012 return < div > Animal not found</ div > ;
1113 }
1214
13- const animal = getAnimalById ( animalId ) ;
15+ const animal = getAnimalBySlug ( animalId ) ;
1416
1517 if ( ! animal ) {
1618 return < div > Animal not found</ div > ;
1719 }
1820
19- const category = categories . find ( ( cat ) => cat . id === animal . category ) ;
21+ const category = getCategoryByName ( animal . category ) ;
2022
2123 const getStatusColor = ( status : string ) => {
2224 switch ( status . toLowerCase ( ) ) {
@@ -35,6 +37,7 @@ export default function AnimalDetailPage() {
3537 }
3638 } ;
3739
40+ console . log ( animal , category ) ;
3841 return (
3942 < div className = "min-h-screen bg-gray-50" >
4043 < div className = "max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8" >
@@ -45,7 +48,7 @@ export default function AnimalDetailPage() {
4548 </ Link >
4649 < span className = "text-gray-400" > /</ span >
4750 < Link
48- to = { `/category/${ animal . category } ` }
51+ to = { `/category/${ category ?. slug } ` }
4952 className = "text-teal-600 hover:text-teal-700"
5053 >
5154 { category ?. name }
0 commit comments