45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
export const ConfirmationDialog = ({
|
|
isOpen,
|
|
title,
|
|
message,
|
|
confirmLabel = "Confirm",
|
|
cancelLabel = "Cancel",
|
|
confirmColor = "bg-blue-600 hover:bg-blue-700",
|
|
onConfirm,
|
|
onCancel,
|
|
}: {
|
|
isOpen: boolean;
|
|
title: string;
|
|
message: string | React.ReactNode;
|
|
confirmLabel?: string;
|
|
cancelLabel?: string;
|
|
confirmColor?: string;
|
|
onConfirm: () => void;
|
|
onCancel: () => void;
|
|
}) => {
|
|
if (!isOpen) return null;
|
|
|
|
return (
|
|
<div className="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50">
|
|
<div className="bg-white p-6 rounded-md shadow-md w-[90%] max-w-md">
|
|
<h2 className="text-xl font-semibold mb-4">{title}</h2>
|
|
<p>{message}</p>
|
|
<div className="mt-6 flex justify-end space-x-4">
|
|
<button
|
|
className="bg-gray-200 px-4 py-2 rounded hover:bg-gray-300"
|
|
onClick={onCancel}
|
|
>
|
|
{cancelLabel}
|
|
</button>
|
|
<button
|
|
className={`${confirmColor} text-white px-4 py-2 rounded`}
|
|
onClick={onConfirm}
|
|
>
|
|
{confirmLabel}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|