| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 'use client';
- import { X } from 'lucide-react';
- interface ConfirmModalProps {
- isOpen: boolean;
- title: string;
- message: string;
- onConfirm: () => void;
- onCancel: () => void;
- }
- export default function ConfirmModal({ isOpen, onCancel, onConfirm, message, title }: ConfirmModalProps) {
- if (!isOpen) return null;
- return (
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4">
- <div className="bg-white rounded-xl shadow-2xl w-full max-w-md flex flex-col animate-in zoom-in duration-200">
-
- {/* Header */}
- <div className="px-6 py-4 border-b flex justify-between items-center bg-gray-50">
- <h3 className="font-bold text-gray-900 text-lg">{title}</h3>
- <button onClick={onCancel} className="text-gray-400 hover:text-gray-600 p-1 rounded-full hover:bg-gray-100 transition">
- <X size={24} />
- </button>
- </div>
- {/* Body */}
- <div className="p-6 flex-1 flex flex-col justify-center">
- <p className="text-sm text-gray-600 mb-6 text-center">{message}</p>
- </div>
- {/* Footer Buttons */}
- <div className="px-6 py-4 border-t bg-gray-50 flex justify-end gap-3">
- <button
- onClick={onCancel}
- className="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 text-sm font-medium transition"
- >
- 取消
- </button>
- <button
- onClick={() => {
- onConfirm(); // 调用确认回调
- onCancel(); // 关闭弹窗
- }}
- className="px-6 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 text-sm font-bold transition"
- >
- 确认
- </button>
- </div>
- </div>
- </div>
- );
- }
|