diff --git a/src/components/CardAboutShelter/CardAboutShelter.tsx b/src/components/CardAboutShelter/CardAboutShelter.tsx index 2d1df3fc..4ac61065 100644 --- a/src/components/CardAboutShelter/CardAboutShelter.tsx +++ b/src/components/CardAboutShelter/CardAboutShelter.tsx @@ -3,67 +3,68 @@ import { UsersRound, HandHeart, PawPrint, - Phone, Landmark, + Smartphone, } from 'lucide-react'; import { Card } from '../ui/card'; import { ICardAboutShelter } from './types'; +import { InfoRow } from './components'; const CardAboutShelter = (props: ICardAboutShelter) => { const { shelter } = props; + + const check = (v?: string | number | boolean | null) => { + return ( + (v !== undefined && v !== null) || + (typeof v === 'number' && v === 0) || + (typeof v === 'boolean' && v) + ); + }; + return ( - -
Sobre o abrigo
-
- -

{shelter.address}

-
-
- -

Capacidade do abrigo:

-

- {typeof shelter.capacity !== 'number' - ? 'Não informado' - : `${shelter.capacity} pessoas`} -

-
-
- -

Pessoas abrigadas:

-

- {typeof shelter.capacity !== 'number' - ? 'Não informado' - : `${shelter.capacity} pessoas`}{' '} -

-
-
- -

- {shelter.petFriendly - ? 'O abrigo aceita animais' - : 'O abrigo não aceita animais'} -

-
-
- -

Contato:

-

- {typeof shelter.contact !== 'string' - ? 'Não informado' - : shelter.contact} -

-
-
-
- -

Chaves Pix:

-
-
-

- {typeof shelter.pix !== 'string' ? 'Não informado' : shelter.pix} -

-
+ +
Sobre o abrigo
+
+ } label={shelter.address} /> + } + label="Capacidade do abrigo:" + value={ + check(shelter.capacity) + ? `${shelter.capacity} pessoas` + : 'Não informado' + } + /> + } + label="Pessoas abrigadas:" + value={ + check(shelter.capacity) + ? `${shelter.capacity} pessoas` + : 'Não informado' + } + /> + } + label={ + check(shelter.petFriendly) + ? 'O abrigo aceita animais' + : 'O abrigo não aceita animais' + } + /> + } + label="Contato:" + value={ + check(shelter.contact) ? `${shelter.contact}` : 'Não informado' + } + /> + } + label="Chave Pix:" + value={check(shelter.pix) ? `${shelter.pix}` : 'Não informado'} + />
); diff --git a/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx b/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx new file mode 100644 index 00000000..4f204cd3 --- /dev/null +++ b/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx @@ -0,0 +1,41 @@ +import React, { Fragment } from 'react'; + +import { IInfoRowProps } from './types'; +import { cn } from '@/lib/utils'; + +const InfoRow = React.forwardRef( + (props, ref) => { + const { icon, label, value, className = '', ...rest } = props; + const isLink = value?.startsWith('http'); + const ValueComp = !value ? ( + + ) : isLink ? ( + window.open(value, '_blank')} + > + {value} + + ) : ( +

{value}

+ ); + + return ( +
+ {React.cloneElement(icon as any, { + className: 'min-w-5 min-h-5 w-5 h-5', + })} +

+ {label} +

+ {ValueComp} +
+ ); + } +); + +export { InfoRow }; diff --git a/src/components/CardAboutShelter/components/InfoRow/index.ts b/src/components/CardAboutShelter/components/InfoRow/index.ts new file mode 100644 index 00000000..a585cd25 --- /dev/null +++ b/src/components/CardAboutShelter/components/InfoRow/index.ts @@ -0,0 +1,3 @@ +import { InfoRow } from './InfoRow'; + +export { InfoRow }; diff --git a/src/components/CardAboutShelter/components/InfoRow/types.ts b/src/components/CardAboutShelter/components/InfoRow/types.ts new file mode 100644 index 00000000..40968b72 --- /dev/null +++ b/src/components/CardAboutShelter/components/InfoRow/types.ts @@ -0,0 +1,5 @@ +export interface IInfoRowProps extends React.ComponentPropsWithoutRef<'div'> { + label: string; + value?: string; + icon: React.ReactNode; +} diff --git a/src/components/CardAboutShelter/components/index.ts b/src/components/CardAboutShelter/components/index.ts new file mode 100644 index 00000000..a585cd25 --- /dev/null +++ b/src/components/CardAboutShelter/components/index.ts @@ -0,0 +1,3 @@ +import { InfoRow } from './InfoRow'; + +export { InfoRow }; diff --git a/src/components/ShelterListItem/ShelterListItem.tsx b/src/components/ShelterListItem/ShelterListItem.tsx index 0ed2ea1e..67c0fb52 100644 --- a/src/components/ShelterListItem/ShelterListItem.tsx +++ b/src/components/ShelterListItem/ShelterListItem.tsx @@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom'; import { ChevronRight } from 'lucide-react'; import { IShelterListItemProps, IShelterAvailabilityProps } from './types'; -import { cn, getAvailabilityProps } from '@/lib/utils'; +import { cn, getAvailabilityProps, getSupplyPriorityProps } from '@/lib/utils'; import { Separator } from '../ui/separator'; import { Chip } from '../Chip'; import { Button } from '../ui/button'; @@ -21,6 +21,14 @@ const ShelterListItem = (props: IShelterListItemProps) => { [capacity, shelteredPeople] ); + const tags = useMemo( + () => + data.supplies + .filter((s) => s.priority >= SupplyPriority.Needing) + .sort((a, b) => b.priority - a.priority), + [data.supplies] + ); + return (
)}