ConfirmDialog.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import { AlertCircle, X } from 'lucide-react';
  3. import { useLanguage } from '../contexts/LanguageContext';
  4. interface ConfirmDialogProps {
  5. isOpen: boolean;
  6. title?: string;
  7. message: string;
  8. confirmLabel?: string;
  9. cancelLabel?: string;
  10. onConfirm: () => void;
  11. onCancel: () => void;
  12. }
  13. const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
  14. isOpen,
  15. title,
  16. message,
  17. confirmLabel,
  18. cancelLabel,
  19. onConfirm,
  20. onCancel,
  21. }) => {
  22. const { t } = useLanguage();
  23. if (!isOpen) return null;
  24. return (
  25. <div className="fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200">
  26. <div className="bg-white rounded-2xl shadow-2xl w-full max-w-md overflow-hidden animate-in zoom-in duration-200">
  27. <div className="flex justify-between items-center px-6 py-4 border-b">
  28. <h3 className="text-lg font-semibold text-slate-800 flex items-center gap-2">
  29. <AlertCircle className="w-5 h-5 text-amber-500" />
  30. {title || t('confirmTitle') || 'Confirm'}
  31. </h3>
  32. <button
  33. onClick={onCancel}
  34. className="text-slate-400 hover:text-slate-600 transition-colors"
  35. >
  36. <X size={20} />
  37. </button>
  38. </div>
  39. <div className="px-6 py-8">
  40. <p className="text-slate-600 whitespace-pre-wrap">{message}</p>
  41. </div>
  42. <div className="px-6 py-4 bg-slate-50 flex justify-end gap-3">
  43. <button
  44. onClick={onCancel}
  45. className="px-4 py-2 text-slate-600 hover:bg-slate-200 rounded-xl transition-colors font-medium"
  46. >
  47. {cancelLabel || t('cancel') || 'Cancel'}
  48. </button>
  49. <button
  50. onClick={onConfirm}
  51. className="px-6 py-2 bg-red-600 text-white rounded-xl hover:bg-red-700 transition-colors font-medium shadow-md shadow-red-600/20"
  52. >
  53. {confirmLabel || t('confirm') || 'Confirm'}
  54. </button>
  55. </div>
  56. </div>
  57. </div>
  58. );
  59. };
  60. export default ConfirmDialog;