61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
interface ConfirmDialogProps {
|
|
title: string;
|
|
message: string;
|
|
confirmText?: string;
|
|
cancelText?: string;
|
|
onConfirm: () => void;
|
|
onCancel: () => void;
|
|
type?: 'danger' | 'warning' | 'info';
|
|
}
|
|
|
|
export default function ConfirmDialog({
|
|
title,
|
|
message,
|
|
confirmText = 'OK',
|
|
cancelText = 'Cancelar',
|
|
onConfirm,
|
|
onCancel,
|
|
type = 'danger',
|
|
}: ConfirmDialogProps) {
|
|
const buttonStyles = {
|
|
danger: 'bg-red-500 hover:bg-red-600 text-white',
|
|
warning: 'bg-yellow-500 hover:bg-yellow-600 text-white',
|
|
info: 'bg-primary hover-primary text-white',
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className="fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4 animate-in fade-in duration-200"
|
|
onClick={onCancel}
|
|
>
|
|
<div
|
|
className="bg-white dark:bg-secondary rounded-2xl shadow-2xl max-w-md w-full p-6 animate-in zoom-in-95 duration-200"
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
<h3 className="text-xl font-bold text-secondary dark:text-white mb-3">
|
|
{title}
|
|
</h3>
|
|
<p className="text-gray-600 dark:text-gray-400 mb-6">
|
|
{message}
|
|
</p>
|
|
<div className="flex gap-3">
|
|
<button
|
|
onClick={onCancel}
|
|
className="flex-1 px-4 py-3 border border-gray-300 dark:border-white/10 text-gray-700 dark:text-gray-300 rounded-xl font-medium hover:bg-gray-50 dark:hover:bg-white/5 transition-colors"
|
|
>
|
|
{cancelText}
|
|
</button>
|
|
<button
|
|
onClick={onConfirm}
|
|
className={`flex-1 px-4 py-3 rounded-xl font-medium transition-colors ${buttonStyles[type]}`}
|
|
>
|
|
{confirmText}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|