diff --git a/frontend/src/components/RSVPForm.tsx b/frontend/src/components/RSVPForm.tsx index bff1ebd..8d134f1 100644 --- a/frontend/src/components/RSVPForm.tsx +++ b/frontend/src/components/RSVPForm.tsx @@ -24,28 +24,26 @@ import { Event } from '../types'; interface RSVPFormData { name: string; + email_address: string; // Required email field attending: string; bringing_guests: string; guest_count: number; guest_names: string[]; items_bringing: string[]; other_items: string; - send_email_confirmation: boolean; // New field for email opt-in - email_address: string; // New field for recipient email } const RSVPForm: React.FC = () => { const { slug } = useParams<{ slug: string }>(); const [formData, setFormData] = useState({ name: '', + email_address: '', // Required email field attending: '', bringing_guests: '', guest_count: 1, guest_names: [], items_bringing: [], - other_items: '', - send_email_confirmation: false, // Initialize to false - email_address: '' // Initialize to empty + other_items: '' }); const [neededItems, setNeededItems] = useState([]); const [claimedItems, setClaimedItems] = useState([]); @@ -209,9 +207,7 @@ const RSVPForm: React.FC = () => { guest_count: 0, guest_names: [], items_bringing: [], // Clear items when not attending - other_items: '', - send_email_confirmation: false, // Also reset email opt-in - email_address: '' // And email address + other_items: '' })); } else if (name === 'bringing_guests') { // When bringing guests is changed @@ -266,7 +262,7 @@ const RSVPForm: React.FC = () => { setError(null); // Validate required fields - if (!formData.name.trim() || !formData.attending) { + if (!formData.name.trim() || !formData.email_address.trim() || !formData.attending) { setError('Please fill in all required fields'); setIsSubmitting(false); return; @@ -296,7 +292,7 @@ const RSVPForm: React.FC = () => { ...formData, items_bringing: formData.items_bringing, other_items: splitOtherItems, - send_email_confirmation: formData.send_email_confirmation, + send_email_confirmation: true, // Always send email confirmation now email_address: formData.email_address.trim() }; const response = await axios.post(`/api/events/${slug}/rsvp`, submissionData); @@ -307,13 +303,8 @@ const RSVPForm: React.FC = () => { axios.get(`/api/events/${slug}/rsvps`) ]); - // Optionally display success message with edit link if email was sent - if (formData.send_email_confirmation && formData.email_address.trim()) { - // The backend sends the email, we just need to confirm success here - setSuccess(true); - } else { - setSuccess(true); // Still show success even if email wasn't sent - } + // Email confirmation is always sent now + setSuccess(true); // Process needed items let items: string[] = []; @@ -476,6 +467,18 @@ const RSVPForm: React.FC = () => { variant="outlined" /> + + Are you attending?