diff --git a/apps/site/src/app/admin/applicants/hackers/HackerApplicants.tsx b/apps/site/src/app/admin/applicants/hackers/HackerApplicants.tsx index 9a7e32f2..713c4562 100644 --- a/apps/site/src/app/admin/applicants/hackers/HackerApplicants.tsx +++ b/apps/site/src/app/admin/applicants/hackers/HackerApplicants.tsx @@ -1,9 +1,7 @@ "use client"; import { useRouter } from "next/navigation"; - -import { useContext, useState } from "react"; - +import { useContext, useState, useEffect } from "react"; import Box from "@cloudscape-design/components/box"; import Cards from "@cloudscape-design/components/cards"; import Header from "@cloudscape-design/components/header"; @@ -24,9 +22,10 @@ import { isHackerReviewer } from "@/lib/admin/authorization"; import HackerThresholdInputs from "../components/HackerThresholdInputs"; import ApplicantReviewerIndicator from "../components/ApplicantReviewerIndicator"; +import useHackerThresholds from "@/lib/admin/useHackerThresholds"; + function HackerApplicants() { const router = useRouter(); - const { roles } = useContext(UserContext); if (!isHackerReviewer(roles)) { @@ -40,6 +39,14 @@ function HackerApplicants() { const selectedStatusValues = selectedStatuses.map(({ value }) => value); const selectedDecisionValues = selectedDecisions.map(({ value }) => value); + const [acceptedCount, setAcceptedCount] = useState(0); + const [waitlistedCount, setWaitlistedCount] = useState(0); + const [rejectedCount, setRejectCount] = useState(0); + + const { thresholds } = useHackerThresholds(); + const acceptThreshold = thresholds?.accept; + const waitlistThreshold = thresholds?.waitlist; + const filteredApplicants = applicantList.filter( (applicant) => (selectedStatuses.length === 0 || @@ -48,6 +55,27 @@ function HackerApplicants() { selectedDecisionValues.includes(applicant.decision || "-")), ); + useEffect(() => { + const accepted = acceptThreshold ? acceptThreshold : 0; + const waitlisted = waitlistThreshold ? waitlistThreshold : 0; + + const acceptedCount = applicantList.filter( + (applicant) => applicant.avg_score >= accepted, + ).length; + setAcceptedCount(acceptedCount); + + const waitlistedCount = applicantList.filter( + (applicant) => + applicant.avg_score >= waitlisted && applicant.avg_score < accepted, + ).length; + setWaitlistedCount(waitlistedCount); + + const rejectedCount = applicantList.filter( + (applicant) => applicant.avg_score < waitlisted, + ).length; + setRejectCount(rejectedCount); + }, [applicantList, acceptThreshold, waitlistThreshold]); + const items = filteredApplicants; const counter = @@ -104,7 +132,6 @@ function HackerApplicants() { }, ], }} - // visibleSections={preferences.visibleContent} loading={loading} loadingText="Loading applicants" items={items} @@ -120,8 +147,23 @@ function HackerApplicants() { } empty={emptyContent} header={ -
}> - Hacker Applicants +
}> + Hacker Applicants {counter} +
+ {acceptedCount} applicants with "accepted" status +
+
+ {waitlistedCount} applicants with "waitlisted" status +
+
+ {rejectedCount} applicants with "rejected" status +
} />