From c7f37dd298a0fab8392885199ed5f91062b7bca4 Mon Sep 17 00:00:00 2001 From: Rhuam Sena Date: Sat, 18 May 2024 18:41:07 -0300 Subject: [PATCH] Staging (#251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] Config readme * wip: loading * Delete yarn.lock * refact: created shelter list view component in home page * Fix: mobile UI has broken for mobile devices (#22) *Fix: mobile UI has broken for mobile devices * fix: remove chip as fixed as no wrap property * chore: add shelter card clickable * chore: remove Fragment component * build: add set sm as max mobile dimension sm: 425px * style: add responsive layout * refactor: filter page * fix: priority * fix: filter parameters * fix: fixed volunteer supply that had been fulfilled displaying on shelter page * fix: improve readability * feat: hidden filter button if filter is empty * feat: cache in axios request * fix: cache search params * feat: cache clean on searchs * wip: donation tags * fix: clean search params * Update README.md [fix] Retirando a seção Funcionalidades e Backlog * fix: donation tags / componentized the urgent supplies section * fix: removed empty shelter tags empty row * feat: full edit shelter and improved interface of pet friendly in shelter page * refact: add live link and tech stack to readme * Fix/develop bugs (#90) * fix: cache bug (invalite cache on create/update operation) * feat: added update many shelter supplies and admin rule * Add license (#81) Closes #65. * fix: app port (#80) * docs: added shadcn/ui reference * fix for volunteer shelter title (#95) * treat contact link as a proper link * simplified href * docs: add discord link on readme * Normalizes search string in supply filter so it ignores accents (#125) * normalized search string to ignore accents * revert removed button * add a copy to clipboard button to PIX and contact info (#124) * add a copy to clipboard button to PIX and contact info * use && operator instead of ternary * Substitui onClick e useNavigate por para melhorar acessibilidade (#128) * replaced navigate in favour of html link and added card hover * fixed lint warnings * fix: change shelter title style (#106) Prevents badge misalignment on very large titles * Add new feature and creating LoadingSkeleton (#115) * Add new feature and creating LoadingSkeleton * fix/add: add favicon and canonical metatag (#136) * fix/add: add favicon and canonical metatag * fix: fixed the path * refactor: changed order of shelters to updated at instead priority sum (#137) * Remove zod dependency (#143) * replaced zod validation with yup * removed zod dependency from package.json * sort dependencies * fixed validation schema variable name * removed .shape() and added .strict() * deleted unused file * Added burger menu to home page (#149) * Implemented Burger menu * commented unused components * feat: Update BurgerMenu to display user's name when logged in * removed comments * implemented login and logout button * Feat/partners (#155) * fix: menu bar with api partners * fix: menu bar with api partners * fix: remove unused session in burguer menu / removed import all icons from lucide and use link icon instead custom icons * [BUG] Botão de Limpar Filtro sumindo após remover input de busca (#147) * fix: clean filter button disappearing after removing search input manually * fix: removing log * Modificação nas telas de abrigos para adicionar cidades (#110) * feat: filter shlters by cities * feat: city on shelter forms, info and list * feat: shelter city quantities on filter * fix: wrong conditional * fix: bug that removing city filter on home doesnt affect the filter * feat: new address fields on shelter forms * feat: useDebouncedValue, useViaCep * feat: adapt useFetch for conditional paths and different response * feat: address fields required and zipCode triggering viaCep * feat: address fields required on update shelter * feat: address fields on shelter details when theres no address field * fix: suggestions(shorthand, optional chaining, separated zipCode, formatted city on list) * feat: sticky footer on filter dialog * fix: reset errors on zipcode search; copy filter change * fix: timeoutId not assigned value; InfoRow copy can copy undefined * Campo de quantidade adicionado quando adicionar suprimento a um abrigo (#46) * feat(shelter-supply): input to add quantity supply * feat(shelter-supply): show quantity supply at Shelter page and EditShelter page * resolve conflict --------- Co-authored-by: Lipe * feat: google analytics * feat: edit shelter supply item quantity (#170) * fix: send address field formatted (#171) * feat: add a template to log bugs/defects (#168) * feat: add a template to log bugs/defects * Feat/privacy terms about us (#169) * feat: privacy policy page * feat: done about us page * fix: removed redundant value check in info row component * fix: ordering the list of items on the shelter edit page (#166) * feat: Melhoria no esquema de cores dos chip's e ajuste de acessibilidade (#162) * feat: new text colors with adjusted light var colors * feat: change chip element tag to span and improve a11y * feat: added update date information to shelter page (#159) * Adding update date to shelter page * (Aditional) Informing when no update date for shelter in main page * feat: ajuste de textos de voluntários e doações (#129) * hotfix: shelter list item broken div tag * Feat/back navigation to home (#177) * feat: added back navigation to home when click in header label * Hotfix/merge bugs (#183) * fix: shelter list item duplicate code after merge * fix: order in filter select menu, filter supplies by category and useSupplies interface * fix: update shelter validation schema and created useAuthRoles hook to reduce complexity of code * fix: conflicts with master branch * feat: dev and staging gh actions * wip * feat: done supporters page * feat: added shelter category (#250) Co-authored-by: José Fagundes --------- Co-authored-by: helenapaixao Co-authored-by: José Fagundes Co-authored-by: Luccas Specht Co-authored-by: MatheusDubin Co-authored-by: danmqs Co-authored-by: Giovanni Bassi <334958+giggio@users.noreply.github.com> Co-authored-by: Felipe Monteiro Co-authored-by: André Ferraz <74271823+decofma@users.noreply.github.com> Co-authored-by: Sombrio Co-authored-by: Filipe Pacheco de Fraga Co-authored-by: Daniel Marques Co-authored-by: Matheus Dubin Da Silveira <46721495+MatheusDubin@users.noreply.github.com> Co-authored-by: Miguel Dalberto <65927539+migueldalberto@users.noreply.github.com> Co-authored-by: Pablo A. Maximo Co-authored-by: Marcos Nascimento <62677231+Marcos-Nacimento@users.noreply.github.com> Co-authored-by: Gilmar José <99229360+g42puts@users.noreply.github.com> Co-authored-by: Kelvin Co-authored-by: Jhonatan David <82552187+jotahdavid@users.noreply.github.com> Co-authored-by: Alexander Scheibler <60936422+alexanderscheibler@users.noreply.github.com> Co-authored-by: Giovani Andrino Carnaval Co-authored-by: Thiago Oliveira <55795035+thdq@users.noreply.github.com> Co-authored-by: Henrique Uhlmann Gobbi Co-authored-by: Janderson Soares <7406406+jandersonsc@users.noreply.github.com> --- .../Authenticated/Authenticated.tsx | 8 +- src/components/Authenticated/types.ts | 1 + src/components/BurgerMenu/BurgerMenu.tsx | 22 ++++- .../BurguerMenuItem/BurguerMenuItem.tsx | 14 +++- .../components/BurguerMenuItem/types.ts | 1 + .../CardAboutShelter/CardAboutShelter.tsx | 78 +++++++++-------- .../components/InfoRow/InfoRow.tsx | 1 - src/hooks/useShelter/types.ts | 7 ++ src/hooks/useShelters/types.ts | 3 + src/lib/utils.ts | 18 ++-- src/pages/Home/components/Filter/Filter.tsx | 4 +- .../ShelterListItem/ShelterListItem.tsx | 39 +++++++-- src/pages/Shelter/Shelter.tsx | 31 ++++--- src/pages/UpdateShelter/UpdateShelter.tsx | 83 +++++++++++-------- 14 files changed, 206 insertions(+), 104 deletions(-) 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..3c60f9d3 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,22 +50,35 @@ const BurgerMenu = () => { } + icon={} /> } + icon={} + openExternal={true} + /> + } + openExternal={true} /> } + icon={} + openExternal={true} /> } + icon={} + /> + } /> ((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' }, - ]} - />