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 1 commit
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
54 changes: 45 additions & 9 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,13 @@ 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 { thresholds } = useHackerThresholds();
const acceptThreshold = thresholds?.accept;
const waitlistThreshold = thresholds?.waitlist;

const filteredApplicants = applicantList.filter(
(applicant) =>
(selectedStatuses.length === 0 ||
Expand All @@ -48,12 +54,30 @@ function HackerApplicants() {
selectedDecisionValues.includes(applicant.decision || "-")),
);

useEffect(() => {
const accepted = acceptThreshold ? acceptThreshold : 0;
const acceptedCount = applicantList.filter(
(applicant) => applicant.avg_score >= accepted,
).length;
setAcceptedCount(acceptedCount);
}, [applicantList, acceptThreshold]);

useEffect(() => {
const accepted = acceptThreshold ? acceptThreshold : 0;
const waitlisted = waitlistThreshold ? waitlistThreshold : 0;
const waitlistedCount = applicantList.filter(
(applicant) =>
applicant.avg_score >= waitlisted && applicant.avg_score < accepted,
).length;
setWaitlistedCount(waitlistedCount);
}, [applicantList, acceptThreshold, waitlistThreshold]);

waalbert marked this conversation as resolved.
Show resolved Hide resolved
const items = filteredApplicants;

const counter =
selectedStatuses.length > 0 || selectedDecisions.length > 0
? `(${items.length}/${applicantList.length})`
: `(${applicantList.length})`;
? `${items.length}/${applicantList.length}`
: `${applicantList.length}`;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relating to my other comment about the counter, this change isn't needed if you leave the counter as it was written before your commits

const emptyContent = (
<Box textAlign="center" color="inherit">
Expand Down Expand Up @@ -104,7 +128,6 @@ function HackerApplicants() {
},
],
}}
// visibleSections={preferences.visibleContent}
loading={loading}
loadingText="Loading applicants"
items={items}
Expand All @@ -120,8 +143,21 @@ function HackerApplicants() {
}
empty={emptyContent}
header={
<Header counter={counter} actions={<HackerThresholdInputs />}>
Hacker Applicants
<Header actions={<HackerThresholdInputs />}>
<div style={{ display: "flex", alignItems: "baseline", gap: "8px" }}>
<div>Hacker Applicants</div>
<div>({counter})</div>
waalbert marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div
style={{ fontSize: "0.875rem", color: "#5f6b7a", marginTop: "4px" }}
>
{acceptedCount} applicants above acceptance threshold
</div>
<div
style={{ fontSize: "0.875rem", color: "#5f6b7a", marginTop: "4px" }}
>
{waitlistedCount} applicants above waitlist threshold
</div>
waalbert marked this conversation as resolved.
Show resolved Hide resolved
</Header>
}
/>
Expand Down
Loading