ConfirmDialog.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/10 backdrop-blur-[2px] animate-in fade-in duration-200">
  26. <div className="bg-white rounded-[2.5rem] shadow-2xl w-full max-w-sm overflow-hidden animate-in zoom-in duration-300 pointer-events-auto border border-white/40 ring-1 ring-black/5">
  27. <div className="flex justify-between items-center px-10 pt-10 pb-4">
  28. <h3 className="text-base font-black text-slate-900 flex items-center gap-3">
  29. <div className="w-10 h-10 rounded-2xl bg-amber-50 flex items-center justify-center">
  30. <AlertCircle className="w-5 h-5 text-amber-500" />
  31. </div>
  32. {title || t('confirmTitle') || 'Confirm'}
  33. </h3>
  34. <button
  35. onClick={onCancel}
  36. className="w-8 h-8 rounded-full flex items-center justify-center text-slate-400 hover:text-slate-600 hover:bg-slate-100 transition-all"
  37. >
  38. <X size={18} />
  39. </button>
  40. </div>
  41. <div className="px-10 py-6">
  42. <p className="text-sm font-bold text-slate-500 leading-relaxed whitespace-pre-wrap">{message}</p>
  43. </div>
  44. <div className="px-10 pb-10 pt-2 flex justify-end gap-3">
  45. <button
  46. onClick={onCancel}
  47. className="flex-1 h-12 text-sm text-slate-600 hover:bg-slate-100 rounded-2xl transition-all font-black uppercase tracking-widest"
  48. >
  49. {cancelLabel || t('cancel') || 'Cancel'}
  50. </button>
  51. <button
  52. onClick={onConfirm}
  53. className="flex-1 h-12 text-sm bg-indigo-600 text-white rounded-2xl hover:bg-indigo-700 transition-all font-black shadow-lg shadow-indigo-600/20 active:scale-95 uppercase tracking-widest"
  54. >
  55. {confirmLabel || t('confirm') || 'Confirm'}
  56. </button>
  57. </div>
  58. </div>
  59. </div>
  60. );
  61. };
  62. export default ConfirmDialog;