1
1
import { useCallback , useMemo } from 'react' ;
2
2
import { format } from 'date-fns' ;
3
- import { useNavigate } from 'react-router-dom' ;
3
+ import { Link } from 'react-router-dom' ;
4
4
import { ChevronRight } from 'lucide-react' ;
5
5
6
6
import {
@@ -20,9 +20,8 @@ import { IUseSheltersDataSupplyData } from '@/hooks/useShelters/types';
20
20
import { ShelterSupplyCategoryRow } from '../ShelterSupplyCategoryRow' ;
21
21
22
22
const ShelterListItem = ( props : IShelterListItemProps ) => {
23
- const { data, onClick } = props ;
23
+ const { data } = props ;
24
24
const { capacity, shelteredPeople } = data ;
25
- const navigate = useNavigate ( ) ;
26
25
const { availability, className : availabilityClassName } =
27
26
useMemo < IShelterAvailabilityProps > (
28
27
( ) => getAvailabilityProps ( capacity , shelteredPeople ) ,
@@ -42,53 +41,52 @@ const ShelterListItem = (props: IShelterListItemProps) => {
42
41
} , [ ] ) ;
43
42
44
43
return (
45
- < div className = "flex flex-col p-4 w-full border-2 border-border rounded-md gap-1 relative" >
46
- < Button size = "sm" variant = "ghost" className = "absolute top-4 right-4" >
47
- < ChevronRight
48
- className = "h-5 w-5"
49
- onClick = { ( ) => navigate ( `/abrigo/${ data . id } ` ) }
50
- />
51
- </ Button >
52
- < div
53
- className = "flex items-center gap-1"
54
- onClick = { ( ) => navigate ( `/abrigo/${ data . id } ` ) }
55
- >
56
- < h3
57
- className = "font-semibold text-lg hover:cursor-pointer hover:text-slate-500"
58
- onClick = { onClick }
44
+ < Link to = { `/abrigo/${ data . id } ` } target = "_blank" >
45
+ < div className = "flex flex-col p-4 w-full border-2 border-border rounded-md gap-1 relative hover:bg-accent" >
46
+ < Button size = "sm" variant = "ghost" className = "absolute top-4 right-4" >
47
+ < ChevronRight
48
+ className = "h-5 w-5"
49
+ />
50
+ </ Button >
51
+ < div
52
+ className = "flex items-center gap-1"
59
53
>
60
- { data . name }
61
- </ h3 >
62
- { data . verified && < VerifiedBadge /> }
54
+ < h3
55
+ className = "font-semibold text-lg hover:cursor-pointer hover:text-slate-500"
56
+ >
57
+ { data . name }
58
+ </ h3 >
59
+ { data . verified && < VerifiedBadge /> }
60
+ </ div >
61
+ < h6 className = { cn ( 'font-semibold text-md' , availabilityClassName ) } >
62
+ { availability }
63
+ </ h6 >
64
+ < h6 className = "text-muted-foreground text-sm md:text-lg font-medium" >
65
+ { data . address }
66
+ </ h6 >
67
+ { data . shelterSupplies . length > 0 && (
68
+ < >
69
+ < ShelterSupplyCategoryRow
70
+ title = "Necessita voluntários:"
71
+ tags = { tags . NeedVolunteers . map ( getChipProps ) }
72
+ />
73
+ < ShelterSupplyCategoryRow
74
+ title = "Necessita urgente doações de:"
75
+ tags = { tags . NeedDonations . map ( getChipProps ) }
76
+ />
77
+ < ShelterSupplyCategoryRow
78
+ title = "Sobrando para doações:"
79
+ tags = { tags . RemainingSupplies . map ( getChipProps ) }
80
+ />
81
+ </ >
82
+ ) }
83
+ { data . updatedAt && (
84
+ < small className = "text-sm md:text-md font-light text-muted-foreground mt-2" >
85
+ Atualizado em { format ( data . updatedAt , 'dd/MM/yyyy HH:mm' ) }
86
+ </ small >
87
+ ) }
63
88
</ div >
64
- < h6 className = { cn ( 'font-semibold text-md' , availabilityClassName ) } >
65
- { availability }
66
- </ h6 >
67
- < h6 className = "text-muted-foreground text-sm md:text-lg font-medium" >
68
- { data . address }
69
- </ h6 >
70
- { data . shelterSupplies . length > 0 && (
71
- < >
72
- < ShelterSupplyCategoryRow
73
- title = "Necessita voluntários:"
74
- tags = { tags . NeedVolunteers . map ( getChipProps ) }
75
- />
76
- < ShelterSupplyCategoryRow
77
- title = "Necessita urgente doações de:"
78
- tags = { tags . NeedDonations . map ( getChipProps ) }
79
- />
80
- < ShelterSupplyCategoryRow
81
- title = "Sobrando para doações:"
82
- tags = { tags . RemainingSupplies . map ( getChipProps ) }
83
- />
84
- </ >
85
- ) }
86
- { data . updatedAt && (
87
- < small className = "text-sm md:text-md font-light text-muted-foreground mt-2" >
88
- Atualizado em { format ( data . updatedAt , 'dd/MM/yyyy HH:mm' ) }
89
- </ small >
90
- ) }
91
- </ div >
89
+ </ Link >
92
90
) ;
93
91
} ;
94
92
0 commit comments