Skip to content

Commit 2828388

Browse files
committed
fix: removed empty shelter tags empty row
1 parent e626902 commit 2828388

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed

src/lib/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ function groupShelterSuppliesByTag(data: IUseSheltersDataSupplyData[]) {
129129

130130
data.forEach((shelterSupply) => {
131131
Object.keys(grouped).forEach((key: string) => {
132-
console.log(shelterSupply.supply);
133132
if (shelterSupply.tags.includes(key as ShelterTagType)) {
134133
grouped[key as ShelterTagType].push(shelterSupply);
135134
}

src/pages/EditShelterSupply/EditShelterSupply.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const EditShelterSupply = () => {
5656

5757
const handleClickSupplyRow = useCallback(
5858
(item: ISupplyRowItemProps) => {
59-
console.log('Item: ', item);
6059
setModalOpened(true);
6160
setModalData({
6261
value: `${item.priority ?? SupplyPriority.NotNeeded}`,

src/pages/Home/components/ShelterListItem/ShelterListItem.tsx

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo } from 'react';
1+
import { useCallback, useMemo } from 'react';
22
import { format } from 'date-fns';
33
import { useNavigate } from 'react-router-dom';
44
import { ChevronRight } from 'lucide-react';
@@ -33,6 +33,14 @@ const ShelterListItem = (props: IShelterListItemProps) => {
3333
return groupShelterSuppliesByTag(data.shelterSupplies);
3434
}, [data.shelterSupplies]);
3535

36+
const getChipProps = useCallback((s: IUseSheltersDataSupplyData) => {
37+
const { className } = getSupplyPriorityProps(s.priority);
38+
return {
39+
label: s.supply.name,
40+
className,
41+
};
42+
}, []);
43+
3644
return (
3745
<div className="flex flex-col p-4 w-full border-2 border-border rounded-md gap-1 relative">
3846
<Button size="sm" variant="ghost" className="absolute top-4 right-4">
@@ -60,36 +68,15 @@ const ShelterListItem = (props: IShelterListItemProps) => {
6068
<>
6169
<ShelterSupplyCategoryRow
6270
title="Necessita volunários:"
63-
tags={tags.NeedVolunteers.map((t) => {
64-
const { className } = getSupplyPriorityProps(t.priority);
65-
return {
66-
...t,
67-
label: t.supply.name,
68-
className,
69-
};
70-
})}
71+
tags={tags.NeedVolunteers.map(getChipProps)}
7172
/>
7273
<ShelterSupplyCategoryRow
7374
title="Necessita urgente doações de:"
74-
tags={tags.NeedDonations.map((t) => {
75-
const { className } = getSupplyPriorityProps(t.priority);
76-
return {
77-
...t,
78-
label: t.supply.name,
79-
className,
80-
};
81-
})}
75+
tags={tags.NeedDonations.map(getChipProps)}
8276
/>
8377
<ShelterSupplyCategoryRow
8478
title="Sobrando para doações:"
85-
tags={tags.RemainingSupplies.map((t) => {
86-
const { className } = getSupplyPriorityProps(t.priority);
87-
return {
88-
...t,
89-
label: t.supply.name,
90-
className,
91-
};
92-
})}
79+
tags={tags.RemainingSupplies.map(getChipProps)}
9380
/>
9481
</>
9582
)}

src/pages/Home/components/ShelterSupplyCategoryRow/ShelterSupplyCategoryRow.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { Fragment } from 'react';
22

33
import { Separator } from '@/components/ui/separator';
44
import { IShelterSupplyCategoryRowProps } from './types';
@@ -11,6 +11,8 @@ const ShelterSupplyCategoryRow = React.forwardRef<
1111
>((props, ref) => {
1212
const { description, tags, title, className = '', ...rest } = props;
1313

14+
if (tags.length === 0) return <Fragment />;
15+
1416
return (
1517
<div className={cn('flex flex-col gap-3', className)} ref={ref} {...rest}>
1618
<Separator className="mt-2" />

0 commit comments

Comments
 (0)