mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 16:43:23 +00:00
fix(sites): name the site in the delete confirmation and toast
This commit is contained in:
parent
551f6af208
commit
c5816f8907
3 changed files with 17 additions and 4 deletions
|
|
@ -23,10 +23,10 @@ export function LocationDeleteDialog({
|
|||
}: LocationDeleteDialogProps) {
|
||||
return (
|
||||
<Dialog open={Boolean(target)} onClose={onClose}>
|
||||
<DialogTitle>Delete Location</DialogTitle>
|
||||
<DialogTitle>Delete this site?</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
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.
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ export function useDeleteLocation(): UseMutationResult<void, Error, string | num
|
|||
mutationFn: (id: string | number) => 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");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(<LocationsListPage />, { 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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue