From a641a8d128c8575eb2c15fb91c24c08f0888a4da Mon Sep 17 00:00:00 2001 From: Starstrike Date: Thu, 1 May 2025 13:21:45 -0400 Subject: [PATCH] Feature: Add Update Info button and dialog for editing event details --- frontend/src/components/EventAdmin.tsx | 89 ++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/frontend/src/components/EventAdmin.tsx b/frontend/src/components/EventAdmin.tsx index 1d8cd28..2213e2e 100644 --- a/frontend/src/components/EventAdmin.tsx +++ b/frontend/src/components/EventAdmin.tsx @@ -81,6 +81,12 @@ const EventAdmin: React.FC = () => { const [manageItemsDialogOpen, setManageItemsDialogOpen] = useState(false); const [newItem, setNewItem] = useState(''); const [itemToDelete, setItemToDelete] = useState(null); + const [updateInfoDialogOpen, setUpdateInfoDialogOpen] = useState(false); + const [updateForm, setUpdateForm] = useState({ + description: '', + location: '', + date: '' + }); useEffect(() => { fetchEventAndRsvps(); @@ -363,6 +369,41 @@ const EventAdmin: React.FC = () => { } }; + const handleUpdateInfoSubmit = async () => { + if (!event) return; + + try { + await axios.put(`/api/events/${slug}`, { + ...event, + description: updateForm.description, + location: updateForm.location, + date: updateForm.date + }); + + setEvent(prev => prev ? { + ...prev, + description: updateForm.description, + location: updateForm.location, + date: updateForm.date + } : null); + + setUpdateInfoDialogOpen(false); + } catch (error) { + setError('Failed to update event information'); + } + }; + + 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 ( @@ -411,6 +452,13 @@ const EventAdmin: React.FC = () => { > Back to Events + + + setUpdateInfoDialogOpen(false)} + maxWidth="sm" + fullWidth + > + Update Event Information + + + setUpdateForm(prev => ({ ...prev, description: e.target.value }))} + fullWidth + multiline + rows={3} + /> + setUpdateForm(prev => ({ ...prev, location: e.target.value }))} + fullWidth + /> + setUpdateForm(prev => ({ ...prev, date: e.target.value }))} + fullWidth + InputLabelProps={{ + shrink: true, + }} + /> + + + + + + + );