From ffcf959992f7bfa3b5ce4cf58baee67e86b25c22 Mon Sep 17 00:00:00 2001 From: Starstrike Date: Wed, 30 Apr 2025 14:26:04 -0400 Subject: [PATCH] Add view-only RSVPs page and View RSVPs button --- frontend/src/App.tsx | 2 + frontend/src/components/EventList.tsx | 12 ++ frontend/src/components/EventView.tsx | 267 ++++++++++++++++++++++++++ 3 files changed, 281 insertions(+) create mode 100644 frontend/src/components/EventView.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index fd2835b..ca9ca96 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,6 +7,7 @@ import EventList from './components/EventList'; import EventForm from './components/EventForm'; import RSVPForm from './components/RSVPForm'; import EventAdmin from './components/EventAdmin'; +import EventView from './components/EventView'; import './App.css'; const darkTheme = createTheme({ @@ -72,6 +73,7 @@ const App: React.FC = () => { } /> } /> } /> + } /> diff --git a/frontend/src/components/EventList.tsx b/frontend/src/components/EventList.tsx index f6b8de4..5054096 100644 --- a/frontend/src/components/EventList.tsx +++ b/frontend/src/components/EventList.tsx @@ -86,6 +86,18 @@ const EventList: React.FC = () => { + + + + + + Items Status + + + + + Still Needed: + + + {neededItems.map((item: string, index: number) => ( + + ))} + {neededItems.length === 0 && ( + + All items have been claimed + + )} + + + + + Claimed Items: + + + {claimedItems.map((item: string, index: number) => ( + + ))} + {claimedItems.length === 0 && ( + + No items have been claimed yet + + )} + + + + + + + RSVPs ({rsvps.length}) + + + + + + + Name + Attending + Guests + Items Bringing + + + + {rsvps.map((rsvp: RSVP) => ( + + {rsvp.name} + {rsvp.attending.charAt(0).toUpperCase() + rsvp.attending.slice(1)} + + {rsvp.bringing_guests === 'yes' ? + `${rsvp.guest_count} (${rsvp.guest_names.replace(/\s+/g, ', ')})` : + 'No' + } + + + + {(() => { + let items: string[] = []; + try { + if (typeof rsvp.items_bringing === 'string') { + try { + const parsed = JSON.parse(rsvp.items_bringing); + items = Array.isArray(parsed) ? parsed : []; + } catch (e) { + console.error('Error parsing items_bringing JSON in table:', e); + } + } else if (Array.isArray(rsvp.items_bringing)) { + items = rsvp.items_bringing; + } + } catch (e) { + console.error('Error processing items in table:', e); + } + + return items.length > 0 ? items.map((item: string, index: number) => ( + + )) : ( + + No items + + ); + })()} + + + + ))} + +
+
+ + + ); +}; + +export default EventView; \ No newline at end of file