import React, { useState, useEffect } from 'react'; interface FormModalProps { isOpen: boolean; onClose: () => void; onSave: (name: string) => void; title: string; initialValue?: string; } const FormModal: React.FC = ({ isOpen, onClose, onSave, title, initialValue = '', }) => { const [name, setName] = useState(initialValue); useEffect(() => { setName(initialValue); }, [initialValue]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (name.trim()) { onSave(name.trim()); } }; if (!isOpen) return null; return (
e.stopPropagation()} >

{title}

setName(e.target.value)} className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-red-500 focus:border-red-500" placeholder={`Masukkan nama...`} required autoFocus />
); }; export default FormModal;