import React, { useState } from 'react'; import { X, Key, Copy, CheckCircle, Mail } from 'lucide-react'; import { toast } from 'react-toastify'; import { Button, Card } from '../common'; interface PasswordResetModalProps { eventName: string; onConfirm: (sendEmail: boolean) => Promise<{ newPassword: string; emailSent: boolean }>; onClose: () => void; } export const PasswordResetModal: React.FC = ({ eventName, onConfirm, onClose }) => { const [isResetting, setIsResetting] = useState(false); const [sendEmail, setSendEmail] = useState(true); const [newPassword, setNewPassword] = useState(null); const [copied, setCopied] = useState(false); const handleReset = async () => { setIsResetting(true); try { const result = await onConfirm(sendEmail); setNewPassword(result.newPassword); toast.success('Password reset successfully'); } catch (error) { toast.error('Failed to reset password'); onClose(); } finally { setIsResetting(false); } }; const handleCopy = async () => { if (newPassword) { await navigator.clipboard.writeText(newPassword); setCopied(true); toast.success('Password copied to clipboard'); setTimeout(() => setCopied(false), 2000); } }; return (

{newPassword ? 'New Password' : 'Reset Gallery Password'}

{!newPassword ? ( <>

Are you sure you want to reset the password for {eventName}? This will generate a new password for gallery access.

Note: The old password will no longer work. Make sure to share the new password with the host.

) : ( <>

Password reset successfully!

{sendEmail && (

An email notification has been sent to the host.

)}

Important: Save this password securely. It cannot be recovered once you close this window.

)}
); };