Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added numbers of apps above accepted and waitlisted threshold #549

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions apps/site/src/app/admin/applicants/hackers/HackerApplicants.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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)) {
Expand All @@ -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 ||
Expand All @@ -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 =
Expand Down Expand Up @@ -104,7 +132,6 @@ function HackerApplicants() {
},
],
}}
// visibleSections={preferences.visibleContent}
loading={loading}
loadingText="Loading applicants"
items={items}
Expand All @@ -120,8 +147,23 @@ function HackerApplicants() {
}
empty={emptyContent}
header={
<Header counter={counter} actions={<HackerThresholdInputs />}>
Hacker Applicants
<Header actions={<HackerThresholdInputs />}>
Hacker Applicants {counter}
<div
style={{ fontSize: "0.875rem", color: "#5f6b7a", marginTop: "4px" }}
>
{acceptedCount} applicants with &quot;accepted&quot; status
</div>
<div
style={{ fontSize: "0.875rem", color: "#5f6b7a", marginTop: "4px" }}
>
{waitlistedCount} applicants with &quot;waitlisted&quot; status
</div>
<div
style={{ fontSize: "0.875rem", color: "#5f6b7a", marginTop: "4px" }}
>
{rejectedCount} applicants with &quot;rejected&quot; status
</div>
</Header>
}
/>
Expand Down
Loading