Skip to content

Commit 7836cce

Browse files
rhuamfagundesjg
andauthored
feat: added shelter category (#250)
Co-authored-by: José Fagundes <[email protected]>
1 parent 4bbc984 commit 7836cce

File tree

14 files changed

+202
-105
lines changed

14 files changed

+202
-105
lines changed

src/components/Authenticated/Authenticated.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { Fragment } from 'react';
33
import { IAuthenticatedProps } from './types';
44
import { useAuthRoles } from '@/hooks';
55

6-
const Authenticated = ({ children, role = 'User' }: IAuthenticatedProps) => {
6+
const Authenticated = ({
7+
children,
8+
bypass = false,
9+
role = 'User',
10+
}: IAuthenticatedProps) => {
711
const isAuthenticated = useAuthRoles(role);
812

9-
if (!isAuthenticated) return <Fragment />;
13+
if (!bypass && !isAuthenticated) return <Fragment />;
1014

1115
return <div className="contents">{children}</div>;
1216
};

src/components/Authenticated/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ import { AccessLevel } from '@/service/sessions/types';
22

33
export interface IAuthenticatedProps {
44
role?: AccessLevel;
5+
bypass?: boolean;
56
children?: React.ReactNode;
67
}

src/components/BurgerMenu/BurgerMenu.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Info,
88
LinkIcon,
99
Menu,
10+
ShieldAlert,
1011
} from 'lucide-react';
1112

1213
import { SessionServices } from '@/service';
@@ -49,27 +50,35 @@ const BurgerMenu = () => {
4950
<BurguerMenuItem
5051
label="Sobre nós"
5152
link="/sobre-nos"
52-
icon={<Info className="w-4 h-4" />}
53+
icon={<Info className="w-5 h-5" />}
5354
/>
5455
<BurguerMenuItem
5556
label="Cadastrar abrigo"
5657
link="https://forms.gle/2S7L2gR529Dc8P3T9"
57-
icon={<CirclePlus className="w-4 h-4" />}
58+
icon={<CirclePlus className="w-5 h-5" />}
59+
openExternal={true}
60+
/>
61+
<BurguerMenuItem
62+
label="Canal de Denúncias"
63+
link="https://contatoseguro.com.br/sos_rs"
64+
icon={<ShieldAlert className="w-5 h-5" />}
65+
openExternal={true}
5866
/>
5967
<BurguerMenuItem
6068
label="Como Ajudar"
6169
link="https://www.instagram.com/reel/C613CfGuh4b"
62-
icon={<CircleHelp className="w-4 h-4" />}
70+
icon={<CircleHelp className="w-5 h-5" />}
71+
openExternal={true}
6372
/>
6473
<BurguerMenuItem
6574
label="Política de Privacidade"
6675
link="/politica-de-privacidade"
67-
icon={<Info className="w-4 h-4" />}
76+
icon={<Info className="w-5 h-5" />}
6877
/>
6978
<BurguerMenuItem
7079
label="Apoiadores"
7180
link="/apoiadores"
72-
icon={<HeartHandshake className="w-4 h-4" />}
81+
icon={<HeartHandshake className="w-5 h-5" />}
7382
/>
7483
<Separator />
7584
{partners.length > 0 && (

src/components/BurgerMenu/components/BurguerMenuItem/BurguerMenuItem.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { ExternalLink } from 'lucide-react';
23

34
import { IBurguerMenuItemProps } from './types';
45
import { cn } from '@/lib/utils';
@@ -7,22 +8,31 @@ const BurguerMenuItem = React.forwardRef<
78
HTMLAnchorElement,
89
IBurguerMenuItemProps
910
>((props, ref) => {
10-
const { icon, label, onClick, link, className = '', ...rest } = props;
11+
const {
12+
icon,
13+
label,
14+
onClick,
15+
link,
16+
className = '',
17+
openExternal,
18+
...rest
19+
} = props;
1120

1221
return (
1322
<a
1423
ref={ref}
1524
href={link}
16-
target="_blank"
1725
className={cn(
1826
'hover:font-semibold flex gap-2 items-center text-zinc-600 [&_svg]:stroke-zinc-500',
1927
className
2028
)}
2129
onClick={onClick}
2230
{...rest}
31+
target={openExternal ? '_blank' : undefined}
2332
>
2433
{icon}
2534
{label}
35+
{openExternal && <ExternalLink className="w-3 h-3" />}
2636
</a>
2737
);
2838
});

src/components/BurgerMenu/components/BurguerMenuItem/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export interface IBurguerMenuItemProps
33
label: string;
44
icon?: React.ReactNode;
55
link?: string;
6+
openExternal?: boolean;
67
onClick?: () => void;
78
}

src/components/CardAboutShelter/CardAboutShelter.tsx

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { Card } from '../ui/card';
1313
import { ICardAboutShelter } from './types';
1414
import { InfoRow } from './components';
1515
import { checkAndFormatAddress } from './utils';
16+
import { ShelterCategory } from '@/hooks/useShelter/types';
17+
import { Fragment } from 'react/jsx-runtime';
1618

1719
const CardAboutShelter = (props: ICardAboutShelter) => {
1820
const { shelter } = props;
@@ -33,42 +35,46 @@ const CardAboutShelter = (props: ICardAboutShelter) => {
3335
{Boolean(shelter.zipCode) && (
3436
<InfoRow icon={<MapPinned />} label="CEP:" value={shelter.zipCode} />
3537
)}
36-
<InfoRow
37-
icon={<PawPrint />}
38-
label={
39-
check(shelter.petFriendly) ? (
40-
shelter.petFriendly ? (
41-
<p>
42-
O abrigo <b>aceita</b> animais
43-
</p>
44-
) : (
45-
<p>
46-
O abrigo <b>não</b> aceita animais
47-
</p>
48-
)
49-
) : (
50-
<b>Não informado se aceita animais</b>
51-
)
52-
}
53-
/>
54-
<InfoRow
55-
icon={<HandHeart />}
56-
label="Pessoas abrigadas:"
57-
value={
58-
check(shelter.shelteredPeople)
59-
? `${shelter.shelteredPeople} pessoas`
60-
: 'Não informado'
61-
}
62-
/>
63-
<InfoRow
64-
icon={<UsersRound />}
65-
label="Capacidade do abrigo:"
66-
value={
67-
check(shelter.capacity)
68-
? `${shelter.capacity} pessoas`
69-
: 'Não informado'
70-
}
71-
/>
38+
{shelter.category === ShelterCategory.Shelter && (
39+
<Fragment>
40+
<InfoRow
41+
icon={<PawPrint />}
42+
label={
43+
check(shelter.petFriendly) ? (
44+
shelter.petFriendly ? (
45+
<p>
46+
O abrigo <b>aceita</b> animais
47+
</p>
48+
) : (
49+
<p>
50+
O abrigo <b>não</b> aceita animais
51+
</p>
52+
)
53+
) : (
54+
<b>Não informado se aceita animais</b>
55+
)
56+
}
57+
/>
58+
<InfoRow
59+
icon={<HandHeart />}
60+
label="Pessoas abrigadas:"
61+
value={
62+
check(shelter.shelteredPeople)
63+
? `${shelter.shelteredPeople} pessoas`
64+
: 'Não informado'
65+
}
66+
/>
67+
<InfoRow
68+
icon={<UsersRound />}
69+
label="Capacidade do abrigo:"
70+
value={
71+
check(shelter.capacity)
72+
? `${shelter.capacity} pessoas`
73+
: 'Não informado'
74+
}
75+
/>
76+
</Fragment>
77+
)}
7278
<InfoRow
7379
icon={<Smartphone />}
7480
label="Contato:"

src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const InfoRow = React.forwardRef<HTMLDivElement, IInfoRowProps>(
1818
) : isLink ? (
1919
<a
2020
href={value}
21-
target="_blank"
2221
className="text-blue-500 break-all cursor-pointer hover:underline"
2322
>
2423
{value}

src/hooks/useShelter/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
export enum ShelterCategory {
2+
Shelter = 'Shelter',
3+
DistributionCenter = 'DistributionCenter',
4+
}
5+
16
export interface IUseShelterData {
27
id: string;
38
name: string;
@@ -17,6 +22,8 @@ export interface IUseShelterData {
1722
latitude?: string | null;
1823
longitude?: string | null;
1924
shelterSupplies: IUseShelterDataSupply[];
25+
category: ShelterCategory;
26+
actived: boolean;
2027
createdAt: string;
2128
updatedAt?: string | null;
2229
}

src/hooks/useShelters/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ShelterTagType } from '@/pages/Home/components/ShelterListItem/types';
2+
import { ShelterCategory } from '../useShelter/types';
23

34
export interface IUseSheltersData {
45
id: string;
@@ -18,6 +19,8 @@ export interface IUseSheltersData {
1819
verified: boolean;
1920
latitude?: string | null;
2021
longitude?: string | null;
22+
category: ShelterCategory;
23+
actived: boolean;
2124
createdAt: string;
2225
updatedAt?: string | null;
2326
shelterSupplies: IUseSheltersDataSupplyData[];

src/lib/utils.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ShelterCategory } from '@/hooks/useShelter/types';
12
import { IUseSheltersDataSupplyData } from '@/hooks/useShelters/types';
23
import {
34
ShelterTagInfo,
@@ -41,11 +42,18 @@ function nameStatusPriority(priority: SupplyPriority) {
4142
if (priority === SupplyPriority.Remaining) return 'Disponível para doação';
4243
}
4344

44-
function getAvailabilityProps(
45-
capacity?: number | null,
46-
shelteredPeople?: number | null
47-
) {
48-
if (capacity && (shelteredPeople || shelteredPeople === 0)) {
45+
function getAvailabilityProps(props: {
46+
capacity?: number | null;
47+
shelteredPeople?: number | null;
48+
category: ShelterCategory;
49+
}) {
50+
const { category, capacity, shelteredPeople } = props;
51+
if (category === ShelterCategory.DistributionCenter) {
52+
return {
53+
availability: 'Centro de Distribuição',
54+
className: 'text-green-600',
55+
};
56+
} else if (capacity && (shelteredPeople || shelteredPeople === 0)) {
4957
if (shelteredPeople < capacity)
5058
return {
5159
availability: 'Abrigo disponível',

0 commit comments

Comments
 (0)