From 885430338a573f265723aab531cb148c9e97b861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Geraldo=20D=2E=20F?= Date: Thu, 16 May 2024 22:00:57 -0300 Subject: [PATCH 1/2] feat: added supporters page (#216) * fix: conflicts with master branch * feat: dev and staging gh actions * feat: done supporters page --- .github/workflows/dev.yml | 34 +++++++++++++++++++ .github/workflows/staging.yml | 34 +++++++++++++++++++ src/components/BurgerMenu/BurgerMenu.tsx | 6 ++++ src/hooks/index.ts | 2 ++ src/hooks/useSupporters/index.ts | 3 ++ src/hooks/useSupporters/types.ts | 8 +++++ src/hooks/useSupporters/useSupporters.tsx | 11 ++++++ src/pages/Supporters/Supporters.tsx | 41 +++++++++++++++++++++++ src/pages/Supporters/index.ts | 3 ++ src/pages/index.ts | 3 +- src/routes/Routes.tsx | 2 ++ 11 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/staging.yml create mode 100644 src/hooks/useSupporters/index.ts create mode 100644 src/hooks/useSupporters/types.ts create mode 100644 src/hooks/useSupporters/useSupporters.tsx create mode 100644 src/pages/Supporters/Supporters.tsx create mode 100644 src/pages/Supporters/index.ts diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 00000000..be5fa7a8 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: [develop] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: setup node js + uses: actions/setup-node@v4 + with: + node-version: 18.18.x + + - run: npm install + + - name: Create .env file + run: | + touch .env + echo VITE_API_URL=${{ secrets.DEV_VITE_API_URL }} >> .env + cat .env + + - run: npm run build + + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: sa-east-1 + - run: aws s3 sync ./dist s3://dev.sos-rs.com diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 00000000..b9ad33de --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: [staging] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: setup node js + uses: actions/setup-node@v4 + with: + node-version: 18.18.x + + - run: npm install + + - name: Create .env file + run: | + touch .env + echo VITE_API_URL=${{ secrets.STG_VITE_API_URL }} >> .env + cat .env + + - run: npm run build + + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: sa-east-1 + - run: aws s3 sync ./dist s3://stg.sos-rs.com diff --git a/src/components/BurgerMenu/BurgerMenu.tsx b/src/components/BurgerMenu/BurgerMenu.tsx index d42249a7..526a5e02 100644 --- a/src/components/BurgerMenu/BurgerMenu.tsx +++ b/src/components/BurgerMenu/BurgerMenu.tsx @@ -3,6 +3,7 @@ import { CircleHelp, CirclePlus, DoorOpen, + HeartHandshake, Info, LinkIcon, Menu, @@ -65,6 +66,11 @@ const BurgerMenu = () => { link="/politica-de-privacidade" icon={} /> + } + /> {partners.length > 0 && ( diff --git a/src/hooks/index.ts b/src/hooks/index.ts index ca1f96bd..a8007959 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -11,6 +11,7 @@ import { useViaCep } from './useViaCep'; import { usePartners } from './usePartners'; import { useGithubContributors } from './useGithubContributors'; import { useAuthRoles } from './useAuthRoles'; +import { useSupporters } from './useSupporters'; export { useShelters, @@ -26,4 +27,5 @@ export { usePartners, useGithubContributors, useAuthRoles, + useSupporters, }; diff --git a/src/hooks/useSupporters/index.ts b/src/hooks/useSupporters/index.ts new file mode 100644 index 00000000..6e7645d3 --- /dev/null +++ b/src/hooks/useSupporters/index.ts @@ -0,0 +1,3 @@ +import { useSupporters } from './useSupporters'; + +export { useSupporters }; diff --git a/src/hooks/useSupporters/types.ts b/src/hooks/useSupporters/types.ts new file mode 100644 index 00000000..9a499bb2 --- /dev/null +++ b/src/hooks/useSupporters/types.ts @@ -0,0 +1,8 @@ +export interface ISupporter { + id: string; + name: string; + imageUrl: string; + link: string; + createdAt: string; + updatedAt?: string | null; +} diff --git a/src/hooks/useSupporters/useSupporters.tsx b/src/hooks/useSupporters/useSupporters.tsx new file mode 100644 index 00000000..cc8a5ae7 --- /dev/null +++ b/src/hooks/useSupporters/useSupporters.tsx @@ -0,0 +1,11 @@ +import { useFetch } from '../useFetch'; +import { ISupporter } from './types'; + +const useSupporters = () => { + return useFetch('/supporters', { + initialValue: [], + cache: true, + }); +}; + +export { useSupporters }; diff --git a/src/pages/Supporters/Supporters.tsx b/src/pages/Supporters/Supporters.tsx new file mode 100644 index 00000000..a24d9102 --- /dev/null +++ b/src/pages/Supporters/Supporters.tsx @@ -0,0 +1,41 @@ +import { BurgerMenu, Header, LoadingScreen } from '@/components'; +import WithTooltip from '@/components/ui/with-tooltip'; +import { useSupporters } from '@/hooks'; +import { Link } from 'react-router-dom'; + +const Supporters = () => { + const { data: supporters, loading } = useSupporters(); + + if (loading) return ; + + return ( +
+
} /> +
+

+ Apoiadores do projeto +

+
+ {supporters + .sort((a, b) => a.createdAt.localeCompare(b.createdAt)) + .map((supporter, idx) => ( + + +
+
+
+ + + ))} +
+
+
+ ); +}; + +export { Supporters }; diff --git a/src/pages/Supporters/index.ts b/src/pages/Supporters/index.ts new file mode 100644 index 00000000..02e0cdb9 --- /dev/null +++ b/src/pages/Supporters/index.ts @@ -0,0 +1,3 @@ +import { Supporters } from './Supporters'; + +export { Supporters }; diff --git a/src/pages/index.ts b/src/pages/index.ts index 89193cb6..8afdb97c 100644 --- a/src/pages/index.ts +++ b/src/pages/index.ts @@ -1,5 +1,4 @@ import { SignIn } from './SignIn'; - import { Home } from './Home'; import { Shelter } from './Shelter'; import { EditShelterSupply } from './EditShelterSupply'; @@ -8,6 +7,7 @@ import { CreateShelter } from './CreateShelter'; import { UpdateShelter } from './UpdateShelter'; import { PrivacyPolicy } from './PrivacyPolicy'; import { AboutUs } from './AboutUs'; +import { Supporters } from './Supporters'; export { SignIn, @@ -19,4 +19,5 @@ export { UpdateShelter, PrivacyPolicy, AboutUs, + Supporters, }; diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index ae33aac3..6dd56608 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -10,6 +10,7 @@ import { UpdateShelter, PrivacyPolicy, AboutUs, + Supporters, } from '@/pages'; const Routes = () => { @@ -27,6 +28,7 @@ const Routes = () => { } /> } /> } /> + } /> } /> ); From c7f37dd298a0fab8392885199ed5f91062b7bca4 Mon Sep 17 00:00:00 2001 From: Rhuam Sena Date: Sat, 18 May 2024 18:41:07 -0300 Subject: [PATCH 2/2] 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' }, - ]} - />