diff --git a/src/components/Authenticated/Authenticated.tsx b/src/components/Authenticated/Authenticated.tsx index 9b51d6d0..7e4b88e8 100644 --- a/src/components/Authenticated/Authenticated.tsx +++ b/src/components/Authenticated/Authenticated.tsx @@ -3,10 +3,14 @@ import { Fragment } from 'react'; import { IAuthenticatedProps } from './types'; import { useAuthRoles } from '@/hooks'; -const Authenticated = ({ children, role = 'User' }: IAuthenticatedProps) => { +const Authenticated = ({ + children, + bypass = false, + role = 'User', +}: IAuthenticatedProps) => { const isAuthenticated = useAuthRoles(role); - if (!isAuthenticated) return ; + if (!bypass && !isAuthenticated) return ; return
{children}
; }; diff --git a/src/components/Authenticated/types.ts b/src/components/Authenticated/types.ts index 224d8d08..8cf9397f 100644 --- a/src/components/Authenticated/types.ts +++ b/src/components/Authenticated/types.ts @@ -2,5 +2,6 @@ import { AccessLevel } from '@/service/sessions/types'; export interface IAuthenticatedProps { role?: AccessLevel; + bypass?: boolean; children?: React.ReactNode; } diff --git a/src/components/BurgerMenu/BurgerMenu.tsx b/src/components/BurgerMenu/BurgerMenu.tsx index 526a5e02..2f823e5b 100644 --- a/src/components/BurgerMenu/BurgerMenu.tsx +++ b/src/components/BurgerMenu/BurgerMenu.tsx @@ -7,6 +7,7 @@ import { Info, LinkIcon, Menu, + ShieldAlert, } from 'lucide-react'; import { SessionServices } from '@/service'; @@ -49,27 +50,35 @@ const BurgerMenu = () => { } + icon={} /> } + icon={} + openExternal={true} + /> + } + openExternal={true} /> } + icon={} + openExternal={true} /> } + icon={} /> } + icon={} /> {partners.length > 0 && ( diff --git a/src/components/BurgerMenu/components/BurguerMenuItem/BurguerMenuItem.tsx b/src/components/BurgerMenu/components/BurguerMenuItem/BurguerMenuItem.tsx index 98d8a4c4..6f42570f 100644 --- a/src/components/BurgerMenu/components/BurguerMenuItem/BurguerMenuItem.tsx +++ b/src/components/BurgerMenu/components/BurguerMenuItem/BurguerMenuItem.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { ExternalLink } from 'lucide-react'; import { IBurguerMenuItemProps } from './types'; import { cn } from '@/lib/utils'; @@ -7,22 +8,31 @@ const BurguerMenuItem = React.forwardRef< HTMLAnchorElement, IBurguerMenuItemProps >((props, ref) => { - const { icon, label, onClick, link, className = '', ...rest } = props; + const { + icon, + label, + onClick, + link, + className = '', + openExternal, + ...rest + } = props; return ( {icon} {label} + {openExternal && } ); }); diff --git a/src/components/BurgerMenu/components/BurguerMenuItem/types.ts b/src/components/BurgerMenu/components/BurguerMenuItem/types.ts index d48e5ec0..e426a078 100644 --- a/src/components/BurgerMenu/components/BurguerMenuItem/types.ts +++ b/src/components/BurgerMenu/components/BurguerMenuItem/types.ts @@ -3,5 +3,6 @@ export interface IBurguerMenuItemProps label: string; icon?: React.ReactNode; link?: string; + openExternal?: boolean; onClick?: () => void; } diff --git a/src/components/CardAboutShelter/CardAboutShelter.tsx b/src/components/CardAboutShelter/CardAboutShelter.tsx index cff1ea22..34525112 100644 --- a/src/components/CardAboutShelter/CardAboutShelter.tsx +++ b/src/components/CardAboutShelter/CardAboutShelter.tsx @@ -13,6 +13,8 @@ import { Card } from '../ui/card'; import { ICardAboutShelter } from './types'; import { InfoRow } from './components'; import { checkAndFormatAddress } from './utils'; +import { ShelterCategory } from '@/hooks/useShelter/types'; +import { Fragment } from 'react/jsx-runtime'; const CardAboutShelter = (props: ICardAboutShelter) => { const { shelter } = props; @@ -33,42 +35,46 @@ const CardAboutShelter = (props: ICardAboutShelter) => { {Boolean(shelter.zipCode) && ( } label="CEP:" value={shelter.zipCode} /> )} - } - label={ - check(shelter.petFriendly) ? ( - shelter.petFriendly ? ( -

- O abrigo aceita animais -

- ) : ( -

- O abrigo não aceita animais -

- ) - ) : ( - Não informado se aceita animais - ) - } - /> - } - label="Pessoas abrigadas:" - value={ - check(shelter.shelteredPeople) - ? `${shelter.shelteredPeople} pessoas` - : 'Não informado' - } - /> - } - label="Capacidade do abrigo:" - value={ - check(shelter.capacity) - ? `${shelter.capacity} pessoas` - : 'Não informado' - } - /> + {shelter.category === ShelterCategory.Shelter && ( + + } + label={ + check(shelter.petFriendly) ? ( + shelter.petFriendly ? ( +

+ O abrigo aceita animais +

+ ) : ( +

+ O abrigo não aceita animais +

+ ) + ) : ( + Não informado se aceita animais + ) + } + /> + } + label="Pessoas abrigadas:" + value={ + check(shelter.shelteredPeople) + ? `${shelter.shelteredPeople} pessoas` + : 'Não informado' + } + /> + } + label="Capacidade do abrigo:" + value={ + check(shelter.capacity) + ? `${shelter.capacity} pessoas` + : 'Não informado' + } + /> +
+ )} } label="Contato:" diff --git a/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx b/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx index da5007a2..9b70fb2a 100644 --- a/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx +++ b/src/components/CardAboutShelter/components/InfoRow/InfoRow.tsx @@ -18,7 +18,6 @@ const InfoRow = React.forwardRef( ) : isLink ? ( {value} diff --git a/src/hooks/useShelter/types.ts b/src/hooks/useShelter/types.ts index 83a61d41..22c3bd67 100644 --- a/src/hooks/useShelter/types.ts +++ b/src/hooks/useShelter/types.ts @@ -1,3 +1,8 @@ +export enum ShelterCategory { + Shelter = 'Shelter', + DistributionCenter = 'DistributionCenter', +} + export interface IUseShelterData { id: string; name: string; @@ -17,6 +22,8 @@ export interface IUseShelterData { latitude?: string | null; longitude?: string | null; shelterSupplies: IUseShelterDataSupply[]; + category: ShelterCategory; + actived: boolean; createdAt: string; updatedAt?: string | null; } diff --git a/src/hooks/useShelters/types.ts b/src/hooks/useShelters/types.ts index 8cf76801..057bfcbe 100644 --- a/src/hooks/useShelters/types.ts +++ b/src/hooks/useShelters/types.ts @@ -1,4 +1,5 @@ import { ShelterTagType } from '@/pages/Home/components/ShelterListItem/types'; +import { ShelterCategory } from '../useShelter/types'; export interface IUseSheltersData { id: string; @@ -18,6 +19,8 @@ export interface IUseSheltersData { verified: boolean; latitude?: string | null; longitude?: string | null; + category: ShelterCategory; + actived: boolean; createdAt: string; updatedAt?: string | null; shelterSupplies: IUseSheltersDataSupplyData[]; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index a037935c..dc8981ac 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,3 +1,4 @@ +import { ShelterCategory } from '@/hooks/useShelter/types'; import { IUseSheltersDataSupplyData } from '@/hooks/useShelters/types'; import { ShelterTagInfo, @@ -41,11 +42,18 @@ function nameStatusPriority(priority: SupplyPriority) { if (priority === SupplyPriority.Remaining) return 'Disponível para doação'; } -function getAvailabilityProps( - capacity?: number | null, - shelteredPeople?: number | null -) { - if (capacity && (shelteredPeople || shelteredPeople === 0)) { +function getAvailabilityProps(props: { + capacity?: number | null; + shelteredPeople?: number | null; + category: ShelterCategory; +}) { + const { category, capacity, shelteredPeople } = props; + if (category === ShelterCategory.DistributionCenter) { + return { + availability: 'Centro de Distribuição', + className: 'text-green-600', + }; + } else if (capacity && (shelteredPeople || shelteredPeople === 0)) { if (shelteredPeople < capacity) return { availability: 'Abrigo disponível', diff --git a/src/pages/Home/components/Filter/Filter.tsx b/src/pages/Home/components/Filter/Filter.tsx index b63884bb..344fddd6 100644 --- a/src/pages/Home/components/Filter/Filter.tsx +++ b/src/pages/Home/components/Filter/Filter.tsx @@ -149,14 +149,14 @@ const Filter = (props: IFilterProps) => { return ( - + Faça sua busca:
-
+
{ + if (active) return {children}; + else + return ( +
+ {children} +
+ ); +}; + const ShelterListItem = (props: IShelterListItemProps) => { const { data } = props; const { capacity, shelteredPeople } = data; const { availability, className: availabilityClassName } = useMemo( - () => getAvailabilityProps(capacity, shelteredPeople), - [capacity, shelteredPeople] + () => + getAvailabilityProps({ + capacity, + shelteredPeople, + category: data.category, + }), + [capacity, shelteredPeople, data.category] ); const tags: ShelterTagInfo = useMemo(() => { @@ -45,7 +68,7 @@ const ShelterListItem = (props: IShelterListItemProps) => { : '(sem informação)'; return ( - +
@@ -58,9 +81,11 @@ const ShelterListItem = (props: IShelterListItemProps) => {
)}
- + {data.actived && ( + + )}
{availability} @@ -88,7 +113,7 @@ const ShelterListItem = (props: IShelterListItemProps) => { Atualizado em {updatedAtDate}
- + ); }; diff --git a/src/pages/Shelter/Shelter.tsx b/src/pages/Shelter/Shelter.tsx index b3473806..78fea039 100644 --- a/src/pages/Shelter/Shelter.tsx +++ b/src/pages/Shelter/Shelter.tsx @@ -1,6 +1,7 @@ import { useCallback, useMemo, useState } from 'react'; import { ChevronLeft, Pencil } from 'lucide-react'; import { useNavigate, useParams } from 'react-router-dom'; +import { format } from 'date-fns'; import { Authenticated, @@ -22,7 +23,7 @@ import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx'; import { ShelterSupplyServices } from '@/service'; import { useToast } from '@/components/ui/use-toast'; import { clearCache } from '@/api/cache'; -import { format } from 'date-fns'; +import { ShelterCategory } from '@/hooks/useShelter/types'; const Shelter = () => { const params = useParams(); @@ -47,8 +48,13 @@ const Shelter = () => { }, [shelter?.shelterSupplies]); const { availability, className: availabilityClassName } = useMemo( - () => getAvailabilityProps(shelter?.capacity, shelter?.shelteredPeople), - [shelter?.capacity, shelter?.shelteredPeople] + () => + getAvailabilityProps({ + capacity: shelter?.capacity, + shelteredPeople: shelter?.shelteredPeople, + category: shelter?.category, + }), + [shelter?.capacity, shelter?.shelteredPeople, shelter?.category] ); const [loadingUpdateMany, setLoadingUpdateMany] = useState(false); const { toast } = useToast(); @@ -112,14 +118,19 @@ const Shelter = () => {

{availability}

- + +
diff --git a/src/pages/UpdateShelter/UpdateShelter.tsx b/src/pages/UpdateShelter/UpdateShelter.tsx index a85a6f99..c1c8f739 100644 --- a/src/pages/UpdateShelter/UpdateShelter.tsx +++ b/src/pages/UpdateShelter/UpdateShelter.tsx @@ -1,4 +1,4 @@ -import { useContext, useEffect } from 'react'; +import { Fragment, useContext, useEffect } from 'react'; import { ChevronLeft, Loader } from 'lucide-react'; import { useNavigate, useParams } from 'react-router-dom'; import { useFormik } from 'formik'; @@ -23,6 +23,7 @@ import { useDebouncedValue, useViaCep } from '@/hooks'; import { cn } from '@/lib/utils'; import { FullUpdateShelterSchema, UpdateShelterSchema } from './types'; import { useAuthRoles } from '@/hooks/useAuthRoles/useAuthRoles'; +import { ShelterCategory } from '@/hooks/useShelter/types'; const UpdateShelter = () => { const navigate = useNavigate(); @@ -117,9 +118,9 @@ const UpdateShelter = () => { />
-
Atualizar abrigo
+
Atualização cadastral

- Atualize as informações desejadas sobre o abrigo. + Atualize as informações desejadas.

@@ -194,40 +195,52 @@ const UpdateShelter = () => { error={!!errors.contact} helperText={errors.contact} /> - + {shelter.category === ShelterCategory.Shelter && ( + + )} - - setFieldValue('petFriendly', v === 'true')} - options={[ - { value: 'true', label: 'Sim' }, - { value: 'false', label: 'Não' }, - ]} - /> + {shelter.category === ShelterCategory.Shelter && ( + + + + setFieldValue('petFriendly', v === 'true') + } + options={[ + { value: 'true', label: 'Sim' }, + { value: 'false', label: 'Não' }, + ]} + /> + + + setFieldValue('verified', v === 'true') + } + options={[ + { value: 'true', label: 'Sim' }, + { value: 'false', label: 'Não' }, + ]} + /> + + + )} - setFieldValue('verified', v === 'true')} - options={[ - { value: 'true', label: 'Sim' }, - { value: 'false', label: 'Não' }, - ]} - />