From c5816f8907e64404514334d2673716b5662a04dd Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Fri, 25 Sep 2026 11:55:09 -0300 Subject: [PATCH] fix(sites): name the site in the delete confirmation and toast --- .../_components/location-delete-dialog.tsx | 4 ++-- .../locations/use-cases/use-delete-location.ts | 4 ++-- .../locations/site-detail-panel.test.tsx | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app/(protected)/locations/_components/location-delete-dialog.tsx b/src/app/(protected)/locations/_components/location-delete-dialog.tsx index 0b02c348..ed87aa3c 100644 --- a/src/app/(protected)/locations/_components/location-delete-dialog.tsx +++ b/src/app/(protected)/locations/_components/location-delete-dialog.tsx @@ -23,10 +23,10 @@ export function LocationDeleteDialog({ }: LocationDeleteDialogProps) { return ( - Delete Location + Delete this site? - Are you sure you want to delete "{target?.name}"? This action cannot be undone. + This will permanently remove {target?.name} from Sites. This cannot be undone. diff --git a/src/domain/locations/use-cases/use-delete-location.ts b/src/domain/locations/use-cases/use-delete-location.ts index 4e710337..598b6126 100644 --- a/src/domain/locations/use-cases/use-delete-location.ts +++ b/src/domain/locations/use-cases/use-delete-location.ts @@ -10,10 +10,10 @@ export function useDeleteLocation(): UseMutationResult locationsApi.delete(id), onSuccess: () => { void queryClient.invalidateQueries({ queryKey: queryKeys.locations.all }); - toast.success("Location deleted successfully!"); + toast.success("Site deleted"); }, onError: (error: Error) => { - toast.error(error.message || "Failed to delete location"); + toast.error(error.message || "Failed to delete site"); }, }); } diff --git a/src/test/app/(protected)/locations/site-detail-panel.test.tsx b/src/test/app/(protected)/locations/site-detail-panel.test.tsx index 0b0cf469..5eaace69 100644 --- a/src/test/app/(protected)/locations/site-detail-panel.test.tsx +++ b/src/test/app/(protected)/locations/site-detail-panel.test.tsx @@ -202,4 +202,17 @@ describe("Sites page detail panel", () => { expect(screen.queryByRole("heading", { name: "DAL1" })).not.toBeInTheDocument(), ); }); + it("row delete asks to confirm removing the site without opening the panel", async () => { + renderWithProviders(, { withAuth: false }); + + fireEvent.click(await screen.findByRole("button", { name: "Delete site DAL1" })); + + const confirm = await screen.findByRole("dialog", { name: "Delete this site?" }); + expect( + within(confirm).getByText( + "This will permanently remove DAL1 from Sites. This cannot be undone.", + ), + ).toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "DAL1" })).not.toBeInTheDocument(); + }); });