Files
buzz-sheet/components/admin/delete-confirmation-dialog.tsx
T
gunshiz 381ee216dd
CI / Verify (push) Successful in 1m2s
CI / Build immutable images and deploy (push) Successful in 2m50s
fix : qol
2026-09-03 18:29:52 +07:00

58 lines
1.6 KiB
TypeScript

"use client";
import type { ComponentProps, ReactNode } from "react";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
interface DeleteConfirmationDialogProps {
title: ReactNode;
description: ReactNode;
onConfirm: () => void | Promise<void>;
confirmLabel?: ReactNode;
trigger?: ComponentProps<typeof AlertDialogTrigger>["render"];
children?: ReactNode;
open?: ComponentProps<typeof AlertDialog>["open"];
onOpenChange?: ComponentProps<typeof AlertDialog>["onOpenChange"];
}
export function DeleteConfirmationDialog({
title,
description,
onConfirm,
confirmLabel = "ยืนยันลบ",
trigger,
children,
open,
onOpenChange,
}: DeleteConfirmationDialogProps) {
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
{trigger ? (
<AlertDialogTrigger render={trigger}>{children}</AlertDialogTrigger>
) : null}
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{title}</AlertDialogTitle>
<AlertDialogDescription>{description}</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>ยกเลิก</AlertDialogCancel>
<AlertDialogAction variant="destructive" onClick={onConfirm}>
{confirmLabel}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}