From 01c0f792484f8f52606eae0e58abe528acef3086 Mon Sep 17 00:00:00 2001 From: Leo Goetz Date: Thu, 22 Jan 2026 09:10:15 +0100 Subject: feat: completed course, added some types and changed output to dist folder --- frontend/src/components/Events.js | 105 -------------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 frontend/src/components/Events.js (limited to 'frontend/src/components/Events.js') diff --git a/frontend/src/components/Events.js b/frontend/src/components/Events.js deleted file mode 100644 index a84d291..0000000 --- a/frontend/src/components/Events.js +++ /dev/null @@ -1,105 +0,0 @@ -import { Calendar } from './Icons.js'; - -const API_URL = import.meta.env.VITE_API_URL; - -const loadEventsData = async () => { - try { - const response = await fetch(`${API_URL}/events`); - return response.json(); - } catch (e) { - console.error(e); - } -} - - -export const EventModal = (event) => { - const formId = `rsvp-form-${event.ID}`; - const modalId = `modal-event-${event.id}` - return ` -
-
- -

RSVP to ${event.title}

-
-
- - - -
-
- - - - -
-
-
` -} - -export const EventCard = (e) => { - const eventDate = new Date(e.date); - const isPast = eventDate < new Date(); - return ` -
-
- ${e.image_url && `${e.title} thumbnail`} -
-
-

${e.title}

-

${Calendar} ${eventDate.toLocaleDateString()}

-

Host: ${e.host?.name || `User ${e.host_id}`}

- - ${e.description && `

${e.description}

`} -
-
- - ${e.rsvps?.length || 0} ${isPast ? 'went' : 'going'} - - ${!isPast ? ` - `: ''} -
- ${EventModal(e)} -
- ` -} - -export const EventsSection = (title, events) => { - return ` -
-

${title} events

-
- ${events.map((e) => EventCard(e)).join('') || 'No events'} -
-
`; -} - -// IIFE to asynchronously load the Event data before exporting the component -// https://developer.mozilla.org/en-US/docs/Glossary/IIFE -export const Events = await (async () => { - const all = await loadEventsData(); - const past = all.filter((e) => (new Date(e.date) < new Date())); - const upcoming = all.filter((e) => (new Date(e.date) > new Date())); - return ` - ${EventsSection('Upcoming', upcoming)} - ${EventsSection('Past', past)} -`})() \ No newline at end of file -- cgit v1.3