Skip to content

Commit d48642e

Browse files
committed
fix: added new section dedicated for donations
1 parent 628bd6b commit d48642e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/components/ShelterListItem/ShelterListItem.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Separator } from '../ui/separator';
99
import { Chip } from '../Chip';
1010
import { Button } from '../ui/button';
1111
import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx';
12+
import { SupplyPriority } from '@/service/supply/types';
1213

1314
const ShelterListItem = (props: IShelterListItemProps) => {
1415
const { data } = props;
@@ -22,7 +23,7 @@ const ShelterListItem = (props: IShelterListItemProps) => {
2223

2324
const tags = useMemo(
2425
() => {
25-
return data.shelterSupplies?.filter((s) => !getCategoriesToFilterVolunteers().some(c => c.includes(s.supply?.supplyCategory?.name.toLowerCase())))
26+
return data.shelterSupplies?.filter((s) => !getCategoriesToFilterVolunteers().some(c => c.includes(s.supply?.supplyCategory?.name.toLowerCase())) && !(s.priority === SupplyPriority.Remaining))
2627
.sort((a, b) => b.priority - a.priority).slice(0, 10)
2728
},
2829
[data.shelterSupplies]
@@ -35,6 +36,13 @@ const ShelterListItem = (props: IShelterListItemProps) => {
3536
[data.shelterSupplies]
3637
)
3738

39+
const donationsTags = useMemo(
40+
() => {
41+
return data.shelterSupplies?.filter((s) => !getCategoriesToFilterVolunteers().some(c => c.includes(s.supply?.supplyCategory?.name.toLowerCase())) && s.priority === SupplyPriority.Remaining).reverse()
42+
},
43+
[data.shelterSupplies]
44+
)
45+
3846
return (
3947
<div className="flex flex-col p-4 w-full border-2 border-border rounded-md gap-1 relative">
4048
<Button
@@ -97,6 +105,21 @@ const ShelterListItem = (props: IShelterListItemProps) => {
97105
))}
98106
</div>
99107
</div>
108+
<div className="flex flex-col gap-3">
109+
<Separator className="mt-2" />
110+
<p className="text-muted-foreground text-sm md:text-lg font-medium">
111+
Sobrando, para doações:
112+
</p>
113+
<div className="flex gap-2 flex-wrap">
114+
{donationsTags.map((s, idx) => (
115+
<Chip
116+
className={getSupplyPriorityProps(s.priority).className}
117+
key={idx}
118+
label={s.supply.name}
119+
/>
120+
))}
121+
</div>
122+
</div>
100123
</>
101124
)}
102125
{data.updatedAt && (

src/pages/Shelter/Shelter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const Shelter = () => {
107107
</h3>
108108
</div>
109109
<div className="flex gap-2 flex-wrap">
110-
{volunteerTags.map((v, idx) => (
110+
{ volunteerTags.length == 0 ? <p>Não informado. <i> (Pode ser adicionado ao clicar em Editar itens) </i></p> : volunteerTags.map((v, idx) => (
111111
<Chip
112112
className={getSupplyPriorityProps(v.priority).className}
113113
key={idx}

0 commit comments

Comments
 (0)