Implement separate toggles for email notifications and event conclusion email

This commit is contained in:
Ryderjj89
2025-05-26 12:39:23 -04:00
parent f686d3ae2b
commit ec8a4398e3

View File

@@ -50,6 +50,7 @@ interface FormData {
email_notifications_enabled: boolean; email_notifications_enabled: boolean;
email_recipients: string; email_recipients: string;
thank_you_message: string; // Added thank you message field thank_you_message: string; // Added thank you message field
event_conclusion_email_enabled: boolean; // Added state for event conclusion email toggle
} }
const EventForm: React.FC = () => { const EventForm: React.FC = () => {
@@ -65,6 +66,7 @@ const EventForm: React.FC = () => {
email_notifications_enabled: false, email_notifications_enabled: false,
email_recipients: '', email_recipients: '',
thank_you_message: '', // Added thank you message state thank_you_message: '', // Added thank you message state
event_conclusion_email_enabled: false, // Initialize new state
}); });
const [wallpaper, setWallpaper] = useState<File | null>(null); const [wallpaper, setWallpaper] = useState<File | null>(null);
const [currentItem, setCurrentItem] = useState(''); const [currentItem, setCurrentItem] = useState('');
@@ -116,7 +118,7 @@ const EventForm: React.FC = () => {
setError(null); setError(null);
try { try {
const submitData = new FormData(); const submitData = new FormData();
// Append all form fields // Append all form fields
Object.entries(formData).forEach(([key, value]) => { Object.entries(formData).forEach(([key, value]) => {
if (key === 'needed_items') { if (key === 'needed_items') {
@@ -128,6 +130,9 @@ const EventForm: React.FC = () => {
// Append thank you message // Append thank you message
submitData.append('thank_you_message', formData.thank_you_message); submitData.append('thank_you_message', formData.thank_you_message);
// Append event conclusion email enabled state
submitData.append('event_conclusion_email_enabled', String(formData.event_conclusion_email_enabled));
// Append wallpaper if selected // Append wallpaper if selected
if (wallpaper) { if (wallpaper) {
@@ -148,11 +153,11 @@ const EventForm: React.FC = () => {
return ( return (
<Container maxWidth="sm"> <Container maxWidth="sm">
<Paper <Paper
elevation={3} elevation={3}
sx={{ sx={{
p: 4, p: 4,
mt: 4, mt: 4,
bgcolor: 'rgba(22, 28, 36, 0.95)', bgcolor: 'rgba(22, 28, 36, 0.95)',
backgroundImage: 'linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))' backgroundImage: 'linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))'
}} }}
@@ -403,20 +408,49 @@ const EventForm: React.FC = () => {
variant="outlined" variant="outlined"
placeholder="email1@example.com, email2@example.com" placeholder="email1@example.com, email2@example.com"
helperText="Enter email addresses separated by commas" helperText="Enter email addresses separated by commas"
sx={{ mt: 2 }} // Added margin top for spacing
/> />
)} )}
<DarkTextField <FormControlLabel
fullWidth control={
label="Thank You Message (for email notifications)" <Checkbox
name="thank_you_message" checked={formData.event_conclusion_email_enabled}
value={formData.thank_you_message} onChange={(e) => {
onChange={handleChange} setFormData((prev) => ({
variant="outlined" ...prev,
multiline event_conclusion_email_enabled: e.target.checked,
rows={4} }));
helperText="This message will be sent to attendees who opted for email notifications the day after the event." }}
sx={{
color: 'rgba(255, 255, 255, 0.7)',
'&.Mui-checked': {
color: '#90caf9',
},
}}
/>
}
label="Enable Event Conclusion Email"
sx={{
color: 'rgba(255, 255, 255, 0.9)',
mt: 2, // Added margin top for spacing
}}
/> />
{formData.event_conclusion_email_enabled && (
<DarkTextField
fullWidth
label="Event conclusion message"
name="thank_you_message"
value={formData.thank_you_message}
onChange={handleChange}
variant="outlined"
multiline
rows={4}
helperText="This message will be sent to attendees who opted for email notifications the day after the event."
sx={{ mt: 2 }} // Added margin top for spacing
/>
)}
</Box> </Box>
</Box> </Box>