diff --git a/src/app/user/shelters/[id]/edit/page.tsx b/src/app/user/shelters/[uuid]/edit/page.tsx similarity index 93% rename from src/app/user/shelters/[id]/edit/page.tsx rename to src/app/user/shelters/[uuid]/edit/page.tsx index 0949829..10e45d3 100644 --- a/src/app/user/shelters/[id]/edit/page.tsx +++ b/src/app/user/shelters/[uuid]/edit/page.tsx @@ -11,11 +11,11 @@ import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"; export default function EditShelterPage({ params, }: { - params: { id: number }; + params: { uuid: string }; }) { const { data, isLoading, error } = - api.userShelters.findUserShelterById.useQuery({ - id: Number(params.id), + api.userShelters.findUserShelterByUuid.useQuery({ + uuid: params.uuid, }); if (error) { diff --git a/src/app/user/shelters/_components/form-edit-register/dialog-delete/index.tsx b/src/app/user/shelters/_components/form-edit-register/dialog-delete/index.tsx index 45f4317..359301d 100644 --- a/src/app/user/shelters/_components/form-edit-register/dialog-delete/index.tsx +++ b/src/app/user/shelters/_components/form-edit-register/dialog-delete/index.tsx @@ -18,7 +18,7 @@ import { useState } from "react"; import { api } from "~/trpc/react"; import { useRouter } from "next/navigation"; -export function DialogDelete({ shelterId }: { shelterId: number }) { +export function DialogDelete({ shelterUuid }: { shelterUuid: string }) { const router = useRouter(); const [open, setOpen] = useState(false); @@ -62,7 +62,7 @@ export function DialogDelete({ shelterId }: { shelterId: number }) { - {isEditing && } + {isEditing && } diff --git a/src/app/user/shelters/_components/shelters-list-table/columns.tsx b/src/app/user/shelters/_components/shelters-list-table/columns.tsx index df6a541..64d0174 100644 --- a/src/app/user/shelters/_components/shelters-list-table/columns.tsx +++ b/src/app/user/shelters/_components/shelters-list-table/columns.tsx @@ -60,7 +60,7 @@ export const columns: ColumnDef[] = [ return (
- + Editar diff --git a/src/schemas/shelter.ts b/src/schemas/shelter.ts index c2994e0..d51c6e1 100644 --- a/src/schemas/shelter.ts +++ b/src/schemas/shelter.ts @@ -75,4 +75,5 @@ export const apiShelterSchema = z.object({ ...shelterSchema.shape, ...addressSchema.shape, id: z.number(), + uuid: z.string(), }); diff --git a/src/server/api/routers/user/shelters.ts b/src/server/api/routers/user/shelters.ts index 311d05a..cfdced1 100644 --- a/src/server/api/routers/user/shelters.ts +++ b/src/server/api/routers/user/shelters.ts @@ -5,8 +5,8 @@ import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc"; import { db } from "~/server/db"; import { apiShelterSchema, createShelterSchema } from "~/schemas/shelter"; -const InputIdParams = z.object({ - id: z.number(), +const InputUuiDParams = z.object({ + uuid: z.string(), }); export const userSheltersRouter = createTRPCRouter({ @@ -23,6 +23,7 @@ export const userSheltersRouter = createTRPCRouter({ return result.map((shelter) => ({ id: shelter.id, + uuid: shelter.uuid, name: shelter.name, phone: shelter.phone, capacity: shelter.capacity.toString(), @@ -44,13 +45,13 @@ export const userSheltersRouter = createTRPCRouter({ }, })); }), - findUserShelterById: protectedProcedure - .input(InputIdParams) + findUserShelterByUuid: protectedProcedure + .input(InputUuiDParams) .query(async ({ ctx, input }) => { const result = await db.shelter.findFirst({ where: { createdById: ctx.session.user.id, - id: input.id, + uuid: input.uuid, }, }); @@ -63,6 +64,7 @@ export const userSheltersRouter = createTRPCRouter({ return { id: result.id, + uuid: result.uuid, name: result.name, phone: result.phone, capacity: result.capacity.toString(), @@ -118,7 +120,7 @@ export const userSheltersRouter = createTRPCRouter({ const result = await db.shelter.findFirst({ where: { createdById: ctx.session.user.id, - id: input.id, + uuid: input.uuid, }, }); @@ -128,8 +130,8 @@ export const userSheltersRouter = createTRPCRouter({ await db.shelter.update({ where: { - id: result.id, createdById: ctx.session.user.id, + id: result.id, }, data: { name: input.name, @@ -153,12 +155,12 @@ export const userSheltersRouter = createTRPCRouter({ }); }), delete: protectedProcedure - .input(InputIdParams) + .input(InputUuiDParams) .mutation(async ({ ctx, input }) => { const result = await db.shelter.findFirst({ where: { createdById: ctx.session.user.id, - id: input.id, + uuid: input.uuid, }, });