@@ -2,26 +2,24 @@ 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 , Chip , Header , LoadingScreen } from '@/components' ;
5
+ import { CardAboutShelter , Header , LoadingScreen } from '@/components' ;
6
6
import { useShelter } from '@/hooks' ;
7
7
import { IShelterAvailabilityProps } from '@/components/ShelterListItem/types' ;
8
- import { cn , getAvailabilityProps , getCategoriesToFilterVolunteers , getSupplyPriorityProps , group } from '@/lib/utils' ;
8
+ import { cn , getAvailabilityProps , 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' ;
15
14
16
15
const Shelter = ( ) => {
17
16
const params = useParams ( ) ;
18
17
const { id = '-1' } = params ;
19
18
const navigate = useNavigate ( ) ;
20
19
const { data : shelter , loading } = useShelter ( id ?? '-1' ) ;
21
- const { data : shelters } = useShelter ( id ) ;
22
20
23
21
const shelterCategories : IShelterCategoryItemsProps [ ] = useMemo ( ( ) => {
24
- const grouped = group ( shelter ?. shelterSupplies ?. filter ( ( s ) => ! getCategoriesToFilterVolunteers ( ) . some ( c => c . includes ( s . supply ?. supplyCategory ?. name ?. toLowerCase ( ) ) ) ) ?? [ ] , 'priority' ) ;
22
+ const grouped = group ( shelter ?. shelterSupplies ?? [ ] , 'priority' ) ;
25
23
delete grouped [ SupplyPriority . NotNeeded ] ;
26
24
27
25
return Object . entries ( grouped )
@@ -30,11 +28,7 @@ const Shelter = () => {
30
28
priority : + key ,
31
29
tags : values . map ( ( v ) => v . supply . name ) ,
32
30
} ) ) ;
33
- } , [ shelters . shelterSupplies ] ) ;
34
-
35
- const volunteerTags : IUseShelterDataSupply [ ] = useMemo ( ( ) => {
36
- return shelter ?. shelterSupplies ?. filter ( ( s ) => getCategoriesToFilterVolunteers ( ) . some ( c => c . includes ( s . supply ?. supplyCategory ?. name ?. toLowerCase ( ) ) ) && s . priority > SupplyPriority . Remaining ) . reverse ( )
37
- } , [ shelter . shelterSupplies ] )
31
+ } , [ shelter ?. shelterSupplies ] ) ;
38
32
39
33
const { availability, className : availabilityClassName } =
40
34
useMemo < IShelterAvailabilityProps > (
@@ -97,26 +91,11 @@ const Shelter = () => {
97
91
</ div >
98
92
</ div >
99
93
< div className = "flex flex-col gap-8 p-4 " >
100
-
101
- < div className = "flex flex-col gap-3" >
102
- < div className = "flex gap-2 items-center" >
103
- < h3 >
104
- Voluntários
105
- </ h3 >
106
- </ div >
107
- < div className = "flex gap-2 flex-wrap" >
108
- { volunteerTags . length == 0 ? < p > Não informado. < i > (Pode ser adicionado ao clicar em Editar itens) </ i > </ p > : volunteerTags . map ( ( v , idx ) => (
109
- < Chip
110
- className = { getSupplyPriorityProps ( v . priority ) . className }
111
- key = { idx }
112
- label = { v . supply . name }
113
- />
114
- ) ) }
115
- </ div >
94
+ < div className = "flex flex-col gap-3" >
95
+ { shelterCategories . map ( ( categoryProps , idx ) => (
96
+ < ShelterCategoryItems key = { idx } { ...categoryProps } />
97
+ ) ) }
116
98
</ div >
117
- { shelterCategories . map ( ( categoryProps , idx ) => (
118
- < ShelterCategoryItems key = { idx } { ...categoryProps } />
119
- ) ) }
120
99
</ div >
121
100
</ div >
122
101
</ div >
0 commit comments