From e9095bea1be6dbfeefa6948a220f5f74434e6e3c Mon Sep 17 00:00:00 2001 From: trista-chen-29 Date: Tue, 31 Mar 2026 22:07:41 -0700 Subject: [PATCH 1/3] Add initial SCEvents landing page --- src/APIFunctions/SCEvents.js | 34 ++++++++++++ src/Pages/Events/Events.js | 104 ++++++++++++++++++++++++++++++++++- 2 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 src/APIFunctions/SCEvents.js diff --git a/src/APIFunctions/SCEvents.js b/src/APIFunctions/SCEvents.js new file mode 100644 index 000000000..0e10bc035 --- /dev/null +++ b/src/APIFunctions/SCEvents.js @@ -0,0 +1,34 @@ +import { ApiResponse } from './ApiResponses'; + +/* + #2067: + Clark should communicate with a locally running SCEvents instance. + From SCEvents/cmd/server/main.go, local GET /events/ is exposed by Gin. +*/ +const SCEVENTS_API_URL = 'http://localhost:8080'; + +export async function getAllSCEvents() { + let status = new ApiResponse(); + + try { + const url = new URL('/events/', SCEVENTS_API_URL); + const res = await fetch(url.href, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }); + + if (res.ok) { + const result = await res.json(); + status.responseData = result; + } else { + status.error = true; + } + } catch (err) { + status.error = true; + status.responseData = err; + } + + return status; +} diff --git a/src/Pages/Events/Events.js b/src/Pages/Events/Events.js index 0da2fb2ff..3ed5060dd 100644 --- a/src/Pages/Events/Events.js +++ b/src/Pages/Events/Events.js @@ -1,8 +1,106 @@ - +import React, { useEffect, useState } from 'react'; import config from '../../config/config.json'; -import NotFoundPage from '../NotFoundPage/NotFoundPage.js'; import { Redirect } from 'react-router-dom'; +import { getAllSCEvents } from '../../APIFunctions/SCEvents'; + + +function EventCard({ event }) { + return ( +
+

+ {event.name || 'Untitled Event'} +

+ +
+ {event.date &&

{event.date}

} + {event.time &&

{event.time}

} + {event.location &&

{event.location}

} +
+ + {event.description && ( +

+ {event.description} +

+ )} +
+ ); +} export default function EventsPage() { - return config.SCEvents.ENABLED ?

Events Page

: ; + const [events, setEvents] = useState([]); + const [isLoading, setIsLoading] = useState(true); + const [hasError, setHasError] = useState(false); + const isSCEventsEnabled = config.SCEvents?.ENABLED; + + useEffect(() => { + if (!isSCEventsEnabled) { + return; + } + + async function fetchEvents() { + setIsLoading(true); + setHasError(false); + + const response = await getAllSCEvents(); + + if (!response.error) { + setEvents(Array.isArray(response.responseData) ? response.responseData : []); + } else { + setHasError(true); + } + + setIsLoading(false); + } + + fetchEvents(); + }, [isSCEventsEnabled]); + + if (!isSCEventsEnabled) { + return ; + } + + return ( +
+
+

+ SCEvents +

+
+

+ Discover upcoming SCE events and activities. +

+
+ +
+ {isLoading && ( +
+ Loading events... +
+ )} + + {!isLoading && hasError && ( +
+ Failed to load events. Please make sure SCEvents is running locally. +
+ )} + + {!isLoading && !hasError && events.length === 0 && ( +
+ No events available right now. +
+ )} + + {!isLoading && !hasError && events.length > 0 && ( +
+ {events.map((event) => ( + + ))} +
+ )} +
+
+ ); } From ccc2e6eaa1356cd05931798aab976e3cf92d82f5 Mon Sep 17 00:00:00 2001 From: trista-chen-29 Date: Tue, 31 Mar 2026 22:09:03 -0700 Subject: [PATCH 2/3] Add initial SCEvents landing page --- src/APIFunctions/SCEvents.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/APIFunctions/SCEvents.js b/src/APIFunctions/SCEvents.js index 0e10bc035..154d6e9d6 100644 --- a/src/APIFunctions/SCEvents.js +++ b/src/APIFunctions/SCEvents.js @@ -1,10 +1,5 @@ import { ApiResponse } from './ApiResponses'; -/* - #2067: - Clark should communicate with a locally running SCEvents instance. - From SCEvents/cmd/server/main.go, local GET /events/ is exposed by Gin. -*/ const SCEVENTS_API_URL = 'http://localhost:8080'; export async function getAllSCEvents() { From 8d3132dbe6652e6aafd9ac317165badb1ddd34ad Mon Sep 17 00:00:00 2001 From: trista-chen-29 Date: Tue, 31 Mar 2026 23:30:48 -0700 Subject: [PATCH 3/3] Polish SCEvents landing page UI --- src/Pages/Events/Events.js | 79 +++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/src/Pages/Events/Events.js b/src/Pages/Events/Events.js index 3ed5060dd..9e0ad3db7 100644 --- a/src/Pages/Events/Events.js +++ b/src/Pages/Events/Events.js @@ -3,18 +3,67 @@ import config from '../../config/config.json'; import { Redirect } from 'react-router-dom'; import { getAllSCEvents } from '../../APIFunctions/SCEvents'; +function CalendarIcon() { + return ( + + ); +} + +function PinIcon() { + return ( + + ); +} function EventCard({ event }) { return ( -
+

{event.name || 'Untitled Event'}

-
- {event.date &&

{event.date}

} - {event.time &&

{event.time}

} - {event.location &&

{event.location}

} +
+ {(event.date || event.time) && ( +
+ + + + {[event.date, event.time].filter(Boolean).join(' ยท ')} +
+ )} + + {event.location && ( +
+ + + + {event.location} +
+ )}
{event.description && ( @@ -60,18 +109,25 @@ export default function EventsPage() { } return ( -
-
+
+
+
+
+
+ +

SCEvents

-
+ +
+

Discover upcoming SCE events and activities.

-
+
{isLoading && (
Loading events... @@ -93,10 +149,7 @@ export default function EventsPage() { {!isLoading && !hasError && events.length > 0 && (
{events.map((event) => ( - + ))}
)}