Yaltopia-FIFA/components/ui/confirm-dialog.tsx
Kirubel-Kibru-Yaltopia 89440985f1
Some checks failed
Deploy to Cloudflare Workers / deploy (push) Has been cancelled
x
2026-05-24 21:46:10 +03:00

61 lines
1.4 KiB
TypeScript

"use client";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
export function ConfirmDialog({
open,
onOpenChange,
title,
description,
confirmLabel = "Confirm",
cancelLabel = "Cancel",
variant = "danger",
loading,
onConfirm,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
title: string;
description: string;
confirmLabel?: string;
cancelLabel?: string;
variant?: "danger" | "primary";
loading?: boolean;
onConfirm: () => void | Promise<void>;
}) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
<DialogDescription>{description}</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button
variant="ghost"
onClick={() => onOpenChange(false)}
disabled={loading}
>
{cancelLabel}
</Button>
<Button
variant={variant === "danger" ? "danger" : "default"}
disabled={loading}
onClick={() => void onConfirm()}
>
{loading ? "Please wait…" : confirmLabel}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}