From 701854e6339ed6a9ba2e24aa67211fc5abe271ff Mon Sep 17 00:00:00 2001 From: chark1es Date: Fri, 28 Feb 2025 18:27:59 -0800 Subject: [PATCH] update the files using the appropriate schema --- src/components/dashboard/EventsSection.astro | 2 - .../dashboard/EventsSection/EventCheckIn.tsx | 50 ++++++----- .../dashboard/EventsSection/EventLoad.tsx | 28 ++----- .../dashboard/Officer_EventManagement.astro | 24 +----- .../Officer_EventManagement/Attendees.tsx | 29 ++----- .../Officer_EventManagement/EventEditor.tsx | 28 ++----- .../dashboard/Officer_EventRequestForm.astro | 4 - .../ASFundingSection.tsx | 1 + .../EventDetailsSection.tsx | 1 + .../EventRequestForm.tsx | 29 ++++--- .../EventRequestFormPreview.tsx | 1 + .../Officer_EventRequestForm/PRSection.tsx | 1 + .../TAPFormSection.tsx | 1 + .../UserEventRequests.tsx | 27 +----- .../Officer_EventRequestManagement.astro | 68 +++++++-------- .../EventRequestDetails.tsx | 32 ++------ .../EventRequestManagementTable.tsx | 46 +++-------- .../ProfileSection/ShowProfileLogs.tsx | 9 +- .../dashboard/ProfileSection/Stats.tsx | 20 +---- .../dashboard/reimbursement/ReceiptForm.tsx | 13 +-- .../reimbursement/ReimbursementForm.tsx | 14 +--- .../reimbursement/ReimbursementList.tsx | 35 ++------ .../ReimbursementManagementPortal.tsx | 82 +++++++------------ src/scripts/pocketbase/SendLog.ts | 75 +++++++++++------ 24 files changed, 222 insertions(+), 398 deletions(-) diff --git a/src/components/dashboard/EventsSection.astro b/src/components/dashboard/EventsSection.astro index a9a393a..5b4a94e 100644 --- a/src/components/dashboard/EventsSection.astro +++ b/src/components/dashboard/EventsSection.astro @@ -1,6 +1,4 @@ --- -import { Icon } from "@iconify/react"; -import JSZip from "jszip"; import FilePreview from "./universal/FilePreview"; import EventCheckIn from "./EventsSection/EventCheckIn"; import EventLoad from "./EventsSection/EventLoad"; diff --git a/src/components/dashboard/EventsSection/EventCheckIn.tsx b/src/components/dashboard/EventsSection/EventCheckIn.tsx index f2b48ab..bb9b2bd 100644 --- a/src/components/dashboard/EventsSection/EventCheckIn.tsx +++ b/src/components/dashboard/EventsSection/EventCheckIn.tsx @@ -4,26 +4,11 @@ import { Authentication } from "../../../scripts/pocketbase/Authentication"; import { Update } from "../../../scripts/pocketbase/Update"; import { SendLog } from "../../../scripts/pocketbase/SendLog"; import { Icon } from "@iconify/react"; +import type { Event, AttendeeEntry } from "../../../schemas/pocketbase"; - -interface Event { - id: string; - event_name: string; - event_code: string; - location: string; - points_to_reward: number; - attendees: AttendeeEntry[]; - start_date: string; - end_date: string; - has_food: boolean; - description: string; - files: string[]; -} - -interface AttendeeEntry { - user_id: string; - time_checked_in: string; - food: string; +// Extended Event interface with additional properties needed for this component +interface ExtendedEvent extends Event { + description?: string; // This component uses 'description' but schema has 'event_description' } // Toast management system @@ -109,7 +94,8 @@ const EventCheckIn = () => { const currentUser = auth.getCurrentUser(); if (!currentUser) { - throw new Error("You must be logged in to check in to events"); + createToast("You must be logged in to check in to events", "error"); + return; } // Find the event with the given code @@ -122,7 +108,8 @@ const EventCheckIn = () => { } // Check if user is already checked in - if (event.attendees.some((entry) => entry.user_id === currentUser.id)) { + const attendees = event.attendees || []; + if (attendees.some((entry) => entry.user_id === currentUser.id)) { throw new Error("You have already checked in to this event"); } @@ -157,6 +144,27 @@ const EventCheckIn = () => { throw new Error("You must be logged in to check in to events"); } + // Check if user is already checked in + const userId = auth.getUserId(); + + if (!userId) { + createToast("You must be logged in to check in to an event", "error"); + return; + } + + // Initialize attendees array if it doesn't exist + const attendees = event.attendees || []; + + // Check if user is already checked in + const isAlreadyCheckedIn = attendees.some( + (attendee) => attendee.user_id === userId + ); + + if (isAlreadyCheckedIn) { + createToast("You are already checked in to this event", "warning"); + return; + } + // Create attendee entry with check-in details const attendeeEntry: AttendeeEntry = { user_id: currentUser.id, diff --git a/src/components/dashboard/EventsSection/EventLoad.tsx b/src/components/dashboard/EventsSection/EventLoad.tsx index 263476d..5b009dc 100644 --- a/src/components/dashboard/EventsSection/EventLoad.tsx +++ b/src/components/dashboard/EventsSection/EventLoad.tsx @@ -2,30 +2,16 @@ import { useEffect, useState } from "react"; import { Icon } from "@iconify/react"; import { Get } from "../../../scripts/pocketbase/Get"; import { Authentication } from "../../../scripts/pocketbase/Authentication"; +import type { Event, AttendeeEntry } from "../../../schemas/pocketbase"; -interface Event { - id: string; - event_name: string; - event_code: string; - location: string; - points_to_reward: number; - attendees: AttendeeEntry[]; - start_date: string; - end_date: string; - has_food: boolean; - description: string; - files: string[]; -} - -interface AttendeeEntry { - user_id: string; - time_checked_in: string; - food: string; +// Extended Event interface with additional properties needed for this component +interface ExtendedEvent extends Event { + description?: string; // This component uses 'description' but schema has 'event_description' } declare global { interface Window { - openDetailsModal: (event: Event) => void; + openDetailsModal: (event: ExtendedEvent) => void; downloadAllFiles: () => Promise; currentEventId: string; [key: string]: any; @@ -118,13 +104,13 @@ const EventLoad = () => {
- {event.description || "No description available"} + {event.event_description || "No description available"}
{event.files && event.files.length > 0 && (