From 431427931fd5d2aa0905c3f946cfd2a51d57b827 Mon Sep 17 00:00:00 2001 From: Khai Ta Date: Wed, 4 Feb 2026 17:11:39 -0500 Subject: [PATCH] add accept and reject buttons --- src/app/organizer-applications/page.tsx | 151 +++++++++++++++++++++--- 1 file changed, 136 insertions(+), 15 deletions(-) diff --git a/src/app/organizer-applications/page.tsx b/src/app/organizer-applications/page.tsx index 3c55756..b2a0662 100644 --- a/src/app/organizer-applications/page.tsx +++ b/src/app/organizer-applications/page.tsx @@ -7,16 +7,20 @@ import { useRejectApplication, } from "@/common/api/organizer_applications"; import { useState } from "react"; -import { Eye } from "lucide-react"; -import { OrganizerApplicationEntity, OrganizerTeam } from "@/common/api/organizer_applications"; +import { Eye, Check, X } from "lucide-react"; +import { OrganizerApplicationEntity, OrganizerTeam, ApplicationStatus } from "@/common/api/organizer_applications"; import ViewApplicationModal from "@/components/modal/ViewApplicationModal"; export default function OrganizerApplicationsPage() { const {data: applications = [], isLoading, refetch } = useAllApplications(); - // I don't think we need mutations here for now, if we're simply just pasting the data onto the table const acceptApplicationMutation = useAcceptApplication(); const rejectApplicationMutation = useRejectApplication(); const [selectedApplication, setSelectedApplication] = useState(null); + const [rejectModalData, setRejectModalData] = useState<{ + id: number; + team: OrganizerTeam; + name: string; + } | null>(null); // Define columns - all static (not editable) const columns: DataTableColumn[] = [ @@ -64,21 +68,99 @@ export default function OrganizerApplicationsPage() { { accessorKey: "id", header: "Actions", - cell: (_, row) => ( - - ), + cell: (_, row) => { + const canAcceptFirst = + row.firstChoiceStatus === ApplicationStatus.PENDING && + !row.assignedTeam; + + const canAcceptSecond = + row.firstChoiceStatus === ApplicationStatus.REJECTED && + row.secondChoiceStatus === ApplicationStatus.PENDING && + !row.assignedTeam; + + const firstChoiceTeam = row.firstChoiceTeam as OrganizerTeam; + const secondChoiceTeam = row.secondChoiceTeam as OrganizerTeam; + + return ( +
+ + + {canAcceptFirst && ( + <> + + + + )} + + {canAcceptSecond && ( + <> + + + + )} +
+ ); + }, }, ]; const handleRefresh = async () => { - await refetch(); - }; + await refetch(); + }; if (isLoading) { return ( @@ -92,6 +174,7 @@ export default function OrganizerApplicationsPage() { ); } + return (
@@ -107,7 +190,7 @@ export default function OrganizerApplicationsPage() { data={applications} columns={columns} onRefresh={handleRefresh} - idField ="id" + idField="id" /> + + {/* Reject Confirmation Modal */} + {rejectModalData && ( +
+
+

Confirm Rejection

+

+ Are you sure you want to reject this application for{" "} + {rejectModalData.team}? +

+

+ Applicant: {rejectModalData.name} +

+
+ + +
+
+
+ )}
); } \ No newline at end of file