You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
"use client";
|
|
|
|
import { type ReactNode } from "react";
|
|
import {
|
|
PrimaryButton,
|
|
SecondaryButton,
|
|
} from "@/components/ui/primary-button";
|
|
|
|
interface ConfirmDialogProps {
|
|
open: boolean;
|
|
title: string;
|
|
message: ReactNode;
|
|
confirmLabel?: string;
|
|
cancelLabel?: string;
|
|
onConfirm: () => void;
|
|
onCancel: () => void;
|
|
loading?: boolean;
|
|
}
|
|
|
|
export function ConfirmDialog({
|
|
open,
|
|
title,
|
|
message,
|
|
confirmLabel = "确认",
|
|
cancelLabel = "取消",
|
|
onConfirm,
|
|
onCancel,
|
|
loading = false,
|
|
}: ConfirmDialogProps) {
|
|
if (!open) return null;
|
|
|
|
return (
|
|
<div
|
|
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
|
|
role="dialog"
|
|
aria-modal
|
|
aria-labelledby="confirm-dialog-title"
|
|
>
|
|
<div className="w-full max-w-md rounded-xl bg-surface p-6 shadow-modal">
|
|
<h2 id="confirm-dialog-title" className="text-lg font-semibold text-text-primary">
|
|
{title}
|
|
</h2>
|
|
<div className="mt-2 text-sm text-text-secondary">{message}</div>
|
|
<div className="mt-6 flex justify-end gap-3">
|
|
<SecondaryButton onClick={onCancel} disabled={loading}>
|
|
{cancelLabel}
|
|
</SecondaryButton>
|
|
<PrimaryButton onClick={onConfirm} loading={loading}>
|
|
{confirmLabel}
|
|
</PrimaryButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|