mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 18:30:39 +09:00
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
|
|
import { Button } from "@/components/ui/button";
|
||
|
|
import {
|
||
|
|
Dialog,
|
||
|
|
DialogContent,
|
||
|
|
DialogDescription,
|
||
|
|
DialogFooter,
|
||
|
|
DialogHeader,
|
||
|
|
DialogTitle,
|
||
|
|
} from "@/components/ui/dialog";
|
||
|
|
|
||
|
|
interface ConfirmDialogProps {
|
||
|
|
open: boolean;
|
||
|
|
onOpenChange: (open: boolean) => void;
|
||
|
|
title: string;
|
||
|
|
description?: string;
|
||
|
|
confirmLabel?: string;
|
||
|
|
cancelLabel?: string;
|
||
|
|
destructive?: boolean;
|
||
|
|
onConfirm: () => void;
|
||
|
|
busy?: boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function ConfirmDialog({
|
||
|
|
open,
|
||
|
|
onOpenChange,
|
||
|
|
title,
|
||
|
|
description,
|
||
|
|
confirmLabel = "Confirm",
|
||
|
|
cancelLabel = "Cancel",
|
||
|
|
destructive,
|
||
|
|
onConfirm,
|
||
|
|
busy,
|
||
|
|
}: ConfirmDialogProps) {
|
||
|
|
return (
|
||
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||
|
|
<DialogContent className="sm:max-w-sm">
|
||
|
|
<DialogHeader>
|
||
|
|
<DialogTitle>{title}</DialogTitle>
|
||
|
|
{description && <DialogDescription>{description}</DialogDescription>}
|
||
|
|
</DialogHeader>
|
||
|
|
<DialogFooter>
|
||
|
|
<Button variant="outline" size="sm" onClick={() => onOpenChange(false)} disabled={busy}>
|
||
|
|
{cancelLabel}
|
||
|
|
</Button>
|
||
|
|
<Button
|
||
|
|
variant={destructive ? "destructive" : "default"}
|
||
|
|
size="sm"
|
||
|
|
onClick={onConfirm}
|
||
|
|
disabled={busy}
|
||
|
|
>
|
||
|
|
{busy ? "Working…" : confirmLabel}
|
||
|
|
</Button>
|
||
|
|
</DialogFooter>
|
||
|
|
</DialogContent>
|
||
|
|
</Dialog>
|
||
|
|
);
|
||
|
|
}
|