From 93e017986d6f667a860223dfb88d185f67d458d1 Mon Sep 17 00:00:00 2001 From: chark1es Date: Tue, 18 Feb 2025 04:45:41 -0800 Subject: [PATCH] added events checker --- .../dashboard/EventsSection/EventLoad.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/dashboard/EventsSection/EventLoad.tsx b/src/components/dashboard/EventsSection/EventLoad.tsx index 20a680b..263476d 100644 --- a/src/components/dashboard/EventsSection/EventLoad.tsx +++ b/src/components/dashboard/EventsSection/EventLoad.tsx @@ -1,6 +1,7 @@ import { useEffect, useState } from "react"; import { Icon } from "@iconify/react"; import { Get } from "../../../scripts/pocketbase/Get"; +import { Authentication } from "../../../scripts/pocketbase/Authentication"; interface Event { id: string; @@ -82,6 +83,11 @@ const EventLoad = () => { const now = new Date(); const isPastEvent = endDate < now; + // Get current user to check attendance + const auth = Authentication.getInstance(); + const currentUser = auth.getCurrentUser(); + const hasAttended = currentUser && event.attendees?.some(entry => entry.user_id === currentUser.id); + // Store event data in window object with unique ID const eventDataId = `event_${event.id}`; window[eventDataId] = event; @@ -126,7 +132,13 @@ const EventLoad = () => { )} {isPastEvent && ( -
Past Event
+
+ + {hasAttended ? 'Attended' : 'Not Attended'} +
)}
{event.location}