mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Refactor delete schedule action in ShowSchedules component
- Replaced the delete button with a DialogAction component for improved user interaction. - Added confirmation dialog for deleting schedules, enhancing user experience and preventing accidental deletions. - Updated success and error notifications for better feedback upon schedule deletion.
This commit is contained in:
parent
d7daa6d8e0
commit
ef02ba22b5
@ -26,6 +26,7 @@ import {
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { DialogAction } from "@/components/shared/dialog-action";
|
||||
|
||||
interface Props {
|
||||
applicationId: string;
|
||||
@ -161,32 +162,36 @@ export const ShowSchedules = ({ applicationId }: Props) => {
|
||||
applicationId={applicationId}
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-destructive hover:text-destructive"
|
||||
isLoading={isDeleting}
|
||||
<DialogAction
|
||||
title="Delete Schedule"
|
||||
description="Are you sure you want to delete this schedule?"
|
||||
type="destructive"
|
||||
onClick={async () => {
|
||||
await deleteSchedule({
|
||||
scheduleId: schedule.scheduleId,
|
||||
})
|
||||
.then(() => {
|
||||
utils.schedule.list.invalidate({
|
||||
applicationId,
|
||||
});
|
||||
toast.success(
|
||||
"Schedule deleted successfully",
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
toast.error(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Error deleting schedule",
|
||||
);
|
||||
.catch(() => {
|
||||
toast.error("Error deleting schedule");
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
<span className="sr-only">Delete</span>
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="group hover:bg-red-500/10 "
|
||||
isLoading={isDeleting}
|
||||
>
|
||||
<Trash2 className="size-4 text-primary group-hover:text-red-500" />
|
||||
</Button>
|
||||
</DialogAction>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
Loading…
Reference in New Issue
Block a user