@@ -2,15 +2,16 @@ import { useMemo } from 'react';
2
2
import { ChevronLeft , Pencil } from 'lucide-react' ;
3
3
import { useNavigate , useParams } from 'react-router-dom' ;
4
4
5
- import { CardAboutShelter , Header , LoadingScreen } from '@/components' ;
5
+ import { CardAboutShelter , Chip , Header , LoadingScreen } from '@/components' ;
6
6
import { useShelter } from '@/hooks' ;
7
7
import { IShelterAvailabilityProps } from '@/components/ShelterListItem/types' ;
8
- import { cn , getAvailabilityProps , group } from '@/lib/utils' ;
8
+ import { cn , getAvailabilityProps , getCategoriesToFilterVolunteers , getSupplyPriorityProps , group } from '@/lib/utils' ;
9
9
import { Button } from '@/components/ui/button' ;
10
10
import { ShelterCategoryItems } from './components' ;
11
11
import { IShelterCategoryItemsProps } from './components/ShelterCategoryItems/types' ;
12
12
import { SupplyPriority } from '@/service/supply/types' ;
13
13
import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx' ;
14
+ import { IUseShelterDataSupply } from '@/hooks/useShelter/types' ;
14
15
15
16
const Shelter = ( ) => {
16
17
const params = useParams ( ) ;
@@ -20,8 +21,9 @@ const Shelter = () => {
20
21
const { data : shelters } = useShelter ( id ) ;
21
22
22
23
const shelterCategories : IShelterCategoryItemsProps [ ] = useMemo ( ( ) => {
23
- const grouped = group ( shelters ?. shelterSupplies ?? [ ] , 'priority' ) ;
24
+ const grouped = group ( shelter ?. shelterSupplies ?. filter ( ( s ) => ! getCategoriesToFilterVolunteers ( ) . some ( c => c . includes ( s . supply ?. supplyCategory ?. name ?. toLowerCase ( ) ) ) ) ?? [ ] , 'priority' ) ;
24
25
delete grouped [ SupplyPriority . NotNeeded ] ;
26
+
25
27
return Object . entries ( grouped )
26
28
. sort ( ( [ a ] , [ b ] ) => ( + a > + b ? - 1 : 1 ) )
27
29
. map ( ( [ key , values ] ) => ( {
@@ -30,6 +32,10 @@ const Shelter = () => {
30
32
} ) ) ;
31
33
} , [ shelters . shelterSupplies ] ) ;
32
34
35
+ const volunteerTags : IUseShelterDataSupply [ ] = useMemo ( ( ) => {
36
+ return shelter ?. shelterSupplies ?. filter ( ( s ) => getCategoriesToFilterVolunteers ( ) . some ( c => c . includes ( s . supply ?. supplyCategory ?. name ?. toLowerCase ( ) ) ) ) . reverse ( )
37
+ } , [ shelter . shelterSupplies ] )
38
+
33
39
const { availability, className : availabilityClassName } =
34
40
useMemo < IShelterAvailabilityProps > (
35
41
( ) => getAvailabilityProps ( shelter ?. capacity , shelter ?. shelteredPeople ) ,
@@ -93,6 +99,23 @@ const Shelter = () => {
93
99
</ div >
94
100
</ div >
95
101
< div className = "flex flex-col gap-8 p-4 " >
102
+
103
+ < div className = "flex flex-col gap-3" >
104
+ < div className = "flex gap-2 items-center" >
105
+ < h3 >
106
+ Voluntários
107
+ </ h3 >
108
+ </ div >
109
+ < div className = "flex gap-2 flex-wrap" >
110
+ { volunteerTags . map ( ( v , idx ) => (
111
+ < Chip
112
+ className = { getSupplyPriorityProps ( v . priority ) . className }
113
+ key = { idx }
114
+ label = { v . supply . name }
115
+ />
116
+ ) ) }
117
+ </ div >
118
+ </ div >
96
119
{ shelterCategories . map ( ( categoryProps , idx ) => (
97
120
< ShelterCategoryItems key = { idx } { ...categoryProps } />
98
121
) ) }
0 commit comments