import { useState } from "react"; import { FaUserEdit } from "react-icons/fa"; interface ReassignModalProps { open: boolean; onClose: () => void; onConfirm: (data: { firstName: string; lastName: string; email: string; message: string }) => void; } export default function ReassignModal({ open, onClose, onConfirm }: ReassignModalProps) { const [firstName, setFirstName] = useState(""); const [lastName, setLastName] = useState(""); const [email, setEmail] = useState(""); const [message, setMessage] = useState(""); const [errors, setErrors] = useState<{ lastName?: string; email?: string }>({}); if (!open) return null; const validate = () => { const newErrors: { lastName?: string; email?: string } = {}; if (!lastName.trim()) newErrors.lastName = "Last name is required."; if (!email.trim()) newErrors.email = "Email is required."; else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) newErrors.email = "Enter a valid email."; setErrors(newErrors); return Object.keys(newErrors).length == 0; }; const handleSubmit = () => { if (!validate()) return; onConfirm({ firstName, lastName, email, message }); onClose(); }; return (
Please enter the recipient details to reassign this document.
{/* Form Fields */}{errors.lastName}
)}{errors.email}
}