From ac33cd2fac57d14b34bb572d1225dbc2af58e5fd Mon Sep 17 00:00:00 2001 From: Gabriela de Castro Laurindo Date: Mon, 4 May 2026 15:16:56 -0300 Subject: [PATCH 1/3] =?UTF-8?q?[PETCONTROL-002]=20feat:=20iniciando=20visu?= =?UTF-8?q?aliza=C3=A7=C3=A3o=20da=20listagem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pets/page.tsx | 15 ++++-- src/features/pets/api/pets-api.ts | 6 +++ .../pets/components/pet-card/PetCard.tsx | 48 +++++++++++++++++ .../pets/components/pet-list/PetList.tsx | 51 +++++++++++++++++++ src/features/pets/hooks/pets/usePets.ts | 9 ++++ .../usePetsListViewModel.ts | 11 ++++ src/features/pets/index.ts | 3 ++ src/features/pets/types/pets.types.ts | 9 ++++ 8 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 src/features/pets/components/pet-card/PetCard.tsx create mode 100644 src/features/pets/components/pet-list/PetList.tsx create mode 100644 src/features/pets/hooks/pets/usePets.ts create mode 100644 src/features/pets/hooks/use-pets-list-view-model/usePetsListViewModel.ts create mode 100644 src/features/pets/types/pets.types.ts diff --git a/src/app/pets/page.tsx b/src/app/pets/page.tsx index 228517b..c99657a 100644 --- a/src/app/pets/page.tsx +++ b/src/app/pets/page.tsx @@ -1,12 +1,17 @@ -import { HealthCheckTest } from "@/shared/components/health-check-test/HealthCheckTest" -import { PetListHeader } from "@/features/pets" +import { PetList, PetListHeader } from "@/features/pets" +import { PageLoader } from "@/shared/components" export default function Page() { + // const { pets, isLoading } = usePetsListPageViewModel(); + return ( -
+
+ {/* */} + -
- + +
+
) diff --git a/src/features/pets/api/pets-api.ts b/src/features/pets/api/pets-api.ts index 505cbc3..50322fe 100644 --- a/src/features/pets/api/pets-api.ts +++ b/src/features/pets/api/pets-api.ts @@ -1,5 +1,6 @@ import { api } from "@/shared/lib/api.config" import { PetSchema } from "../schemas/pet.schema" +import { Pet } from "../types/pets.types" const BASE_URL = "/pets" @@ -7,4 +8,9 @@ export const petsApi = { create: async (pet: PetSchema): Promise => { await api.post(BASE_URL, pet) }, + + get: async (): Promise => { + const { data } = await api.get(BASE_URL) + return data + }, } diff --git a/src/features/pets/components/pet-card/PetCard.tsx b/src/features/pets/components/pet-card/PetCard.tsx new file mode 100644 index 0000000..a3ca638 --- /dev/null +++ b/src/features/pets/components/pet-card/PetCard.tsx @@ -0,0 +1,48 @@ +import { Pet } from "../../types/pets.types" +import { ContainerLayout, InfoButton } from "@/shared/components" +import { petStatusLabels } from "../../enums/pet-status.enum" +import { Edit, Trash2, PawPrint } from "lucide-react" + +interface PetCardProps { + pet: Pet +} + +export function PetCard({ pet }: PetCardProps) { + return ( + +
+ +
+ +
+
+

{pet.name}

+ + {petStatusLabels[pet.status]} + +
+

{pet.specieName}

+
+ +
+ {pet.tags.map((tag) => ( + + {tag} + + ))} +
+ +
+ + Editar + + +
+
+ ) +} diff --git a/src/features/pets/components/pet-list/PetList.tsx b/src/features/pets/components/pet-list/PetList.tsx new file mode 100644 index 0000000..571eb7a --- /dev/null +++ b/src/features/pets/components/pet-list/PetList.tsx @@ -0,0 +1,51 @@ +import { PetStatus } from "../../enums/pet-status.enum" +import { Pet } from "../../types/pets.types" +import { PetCard } from "../pet-card/PetCard" + +const MOCK_PETS: Pet[] = [ + { + id: "d8906906-5136-4ce5-825a-73ee95a267a1", + name: "Rex", + specieName: "Cachorro", + status: PetStatus.AVAILABLE, + tags: ["vacinado", "treinado"], + }, + { + id: "a1234567-b123-c123-d123-e123456789ab", + name: "Luna", + specieName: "Gato", + status: PetStatus.AVAILABLE, + tags: ["castrada", "calma"], + }, + { + id: "f9876543-e987-d987-c987-b987654321ba", + name: "Thor", + specieName: "Cachorro", + status: PetStatus.ADOPTED, + tags: ["brincalhão"], + }, +] + +interface PetListProps { + pets?: Pet[] +} + +export function PetList({ pets }: PetListProps) { + const displayPets = pets && pets.length > 0 ? pets : MOCK_PETS + + if (displayPets.length === 0) { + return ( +
+

Nenhum pet encontrado.

+
+ ) + } + + return ( +
+ {displayPets.map((pet) => ( + + ))} +
+ ) +} diff --git a/src/features/pets/hooks/pets/usePets.ts b/src/features/pets/hooks/pets/usePets.ts new file mode 100644 index 0000000..ae3a1b4 --- /dev/null +++ b/src/features/pets/hooks/pets/usePets.ts @@ -0,0 +1,9 @@ +// import { useQuery } from "@tanstack/react-query"; +// import { petsApi } from "../../api/pets-api"; + +// export function usePets() { +// return useQuery({ +// queryKey: ["pets"], +// queryFn: petsApi.get, +// }); +// } diff --git a/src/features/pets/hooks/use-pets-list-view-model/usePetsListViewModel.ts b/src/features/pets/hooks/use-pets-list-view-model/usePetsListViewModel.ts new file mode 100644 index 0000000..066f846 --- /dev/null +++ b/src/features/pets/hooks/use-pets-list-view-model/usePetsListViewModel.ts @@ -0,0 +1,11 @@ +// import { usePets } from "../pets/usePets"; + +// export function usePetsListPageViewModel() { +// const { data, isLoading, isError } = usePets(); + +// return { +// pets: data ?? [], +// isLoading, +// isError, +// }; +// } diff --git a/src/features/pets/index.ts b/src/features/pets/index.ts index f283b6a..e9a639c 100644 --- a/src/features/pets/index.ts +++ b/src/features/pets/index.ts @@ -1,3 +1,6 @@ export { PetListHeader } from "./components/pet-list-header/PetListHeader" export { PetForm } from "./components/pet-form/PetForm" export { useCreatePetPageViewModel } from "./hooks/create-pet-page-view-model/useCreatePetPageViewModel" +export { PetList } from "./components/pet-list/PetList" +// export { usePets } from "./hooks/pets/usePets" +// export { usePetsListPageViewModel } from "./hooks/use-pets-list-view-model/usePetsListViewModel" diff --git a/src/features/pets/types/pets.types.ts b/src/features/pets/types/pets.types.ts new file mode 100644 index 0000000..db4b577 --- /dev/null +++ b/src/features/pets/types/pets.types.ts @@ -0,0 +1,9 @@ +import { PetStatus } from "../enums/pet-status.enum" + +export interface Pet { + id: string + name: string + specieName: string + status: PetStatus + tags: string[] +} From b915b731ca19156af05cb7c8634a4a7b2862a204 Mon Sep 17 00:00:00 2001 From: Rachel Pizane Date: Tue, 5 May 2026 11:52:45 -0300 Subject: [PATCH 2/3] [PETCONTROL-002] feat: implementar listagem paginada dos pets --- src/app/layout.tsx | 6 +- src/app/pets/page.tsx | 26 +++- src/features/pets/api/pets-api.ts | 7 +- .../pets/components/pet-card/PetCard.tsx | 36 ++--- .../pet-list-header/PetListHeader.tsx | 17 ++- .../pets/components/pet-list/PetList.tsx | 41 ++---- .../pet-status-badge/PetStatusBadge.tsx | 23 +++ .../useCreatePetPageViewModel.ts | 3 + src/features/pets/hooks/pets/usePets.ts | 19 +-- .../usePetsListViewModel.ts | 51 +++++-- .../buttons/delete-button/DeleteButton.tsx | 25 ++++ .../buttons/info-button/InfoButton.tsx | 2 +- .../health-check-test/HealthCheckTest.tsx | 49 ------- src/shared/components/index.ts | 6 +- .../page-loader/PageLoader.tsx | 0 .../loaders/section-loader/SectionLoader.tsx | 28 ++++ .../custom-pagination/CustomPagination.tsx | 61 ++++++++ src/shared/components/ui/pagination.tsx | 132 ++++++++++++++++++ src/shared/hooks/useHealthCheck.ts | 17 --- src/shared/types/common.types.ts | 8 ++ 20 files changed, 411 insertions(+), 146 deletions(-) create mode 100644 src/features/pets/components/pet-status-badge/PetStatusBadge.tsx create mode 100644 src/shared/components/buttons/delete-button/DeleteButton.tsx delete mode 100644 src/shared/components/health-check-test/HealthCheckTest.tsx rename src/shared/components/{layout => loaders}/page-loader/PageLoader.tsx (100%) create mode 100644 src/shared/components/loaders/section-loader/SectionLoader.tsx create mode 100644 src/shared/components/pagination/custom-pagination/CustomPagination.tsx create mode 100644 src/shared/components/ui/pagination.tsx delete mode 100644 src/shared/hooks/useHealthCheck.ts diff --git a/src/app/layout.tsx b/src/app/layout.tsx index cd19956..4766155 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -14,6 +14,10 @@ const fontMono = Geist_Mono({ variable: "--font-mono", }) +export const metadata = { + title: "PetControl", +} + export default function RootLayout({ children, }: Readonly<{ @@ -34,7 +38,7 @@ export default function RootLayout({
-
{children}
+
{children}