diff --git a/apps/web/components/ContactForm.tsx b/apps/web/components/ContactForm.tsx index 09fa7ed..013a6c8 100644 --- a/apps/web/components/ContactForm.tsx +++ b/apps/web/components/ContactForm.tsx @@ -1,34 +1,47 @@ +// Import necessary modules from React import React, { useState } from 'react'; +// Interface to define the props for ContactForm interface ContactFormProps { - onClose: () => void; + onClose: () => void; // Function to handle modal close event } +// Functional component definition for ContactForm const ContactForm: React.FC = ({ onClose }) => { + // State to manage form data (name, email, and message) const [formData, setFormData] = useState({ name: '', email: '', message: '' }); + + // State to track if the form has been submitted const [submitted, setSubmitted] = useState(false); + // Event handler for input and textarea changes const handleChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setFormData((prev) => ({ ...prev, [name]: value })); + const { name, value } = e.target; // Destructure name and value from the target element + setFormData((prev) => ({ ...prev, [name]: value })); // Update the form state dynamically }; + // Event handler for form submission const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - console.log(formData); - setSubmitted(true); - setFormData({ name: '', email: '', message: '' }); + e.preventDefault(); // Prevent default form submission behavior + console.log(formData); // Log form data (can be replaced with API call) + setSubmitted(true); // Set the submitted state to true + setFormData({ name: '', email: '', message: '' }); // Reset form fields after submission }; return (
+ {/* Close button for the modal */} × + + {/* Conditional rendering based on form submission status */} {submitted ? (
Thank you for contacting us!
) : (

Contact Us

+ + {/* Name Input Field */} = ({ onClose }) => { required className="form-input neon-input" /> + + {/* Email Input Field */} = ({ onClose }) => { required className="form-input neon-input" /> + + {/* Message Textarea */} - + + {/* Submit Button */} +
)}
@@ -66,4 +87,4 @@ const ContactForm: React.FC = ({ onClose }) => { ); }; -export default ContactForm; \ No newline at end of file +export default ContactForm; // Export the ContactForm component