Feature: Add RSVP cut-off date functionality

This commit is contained in:
Starstrike
2025-05-01 13:44:29 -04:00
parent 3ac630bcc2
commit e1d23eeb32
6 changed files with 142 additions and 83 deletions

View File

@@ -54,6 +54,7 @@ interface Event {
slug: string;
needed_items?: string[] | string;
wallpaper?: string;
rsvp_cutoff_date?: string;
}
const EventAdmin: React.FC = () => {
@@ -85,7 +86,8 @@ const EventAdmin: React.FC = () => {
const [updateForm, setUpdateForm] = useState({
description: '',
location: '',
date: ''
date: '',
rsvp_cutoff_date: ''
});
useEffect(() => {
@@ -369,6 +371,18 @@ const EventAdmin: React.FC = () => {
}
};
const handleUpdateInfoClick = () => {
if (!event) return;
setUpdateForm({
description: event.description,
location: event.location,
date: event.date.slice(0, 16), // Format date for datetime-local input
rsvp_cutoff_date: event.rsvp_cutoff_date ? event.rsvp_cutoff_date.slice(0, 16) : ''
});
setUpdateInfoDialogOpen(true);
};
const handleUpdateInfoSubmit = async () => {
if (!event) return;
@@ -377,14 +391,16 @@ const EventAdmin: React.FC = () => {
...event,
description: updateForm.description,
location: updateForm.location,
date: updateForm.date
date: updateForm.date,
rsvp_cutoff_date: updateForm.rsvp_cutoff_date
});
setEvent(prev => prev ? {
...prev,
description: updateForm.description,
location: updateForm.location,
date: updateForm.date
date: updateForm.date,
rsvp_cutoff_date: updateForm.rsvp_cutoff_date
} : null);
setUpdateInfoDialogOpen(false);
@@ -393,17 +409,6 @@ const EventAdmin: React.FC = () => {
}
};
const handleUpdateInfoClick = () => {
if (!event) return;
setUpdateForm({
description: event.description,
location: event.location,
date: event.date.slice(0, 16) // Format date for datetime-local input
});
setUpdateInfoDialogOpen(true);
};
if (loading) {
return (
<Container maxWidth="lg">
@@ -487,6 +492,11 @@ const EventAdmin: React.FC = () => {
<Typography variant="subtitle1" gutterBottom>
<strong>Date:</strong> {new Date(event.date).toLocaleString()}
</Typography>
{event.rsvp_cutoff_date && (
<Typography variant="subtitle1" gutterBottom>
<strong>RSVP cut-off date:</strong> {new Date(event.rsvp_cutoff_date).toLocaleString()}
</Typography>
)}
</Box>
{/* Add items status section */}
@@ -837,6 +847,16 @@ const EventAdmin: React.FC = () => {
shrink: true,
}}
/>
<TextField
label="RSVP Cut-off Date"
type="datetime-local"
value={updateForm.rsvp_cutoff_date}
onChange={(e) => setUpdateForm(prev => ({ ...prev, rsvp_cutoff_date: e.target.value }))}
fullWidth
InputLabelProps={{
shrink: true,
}}
/>
</Box>
</DialogContent>
<DialogActions>