Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 15 additions & 13 deletions src/components/features/evaluator/applicant-scoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { useDebouncedSave } from "@/hooks/use-debounce-save";
import type { ApplicantScoreItem } from "@/lib/firebase/types";
import type { ApplicantScoreItem, ScoringCriteria } from "@/lib/firebase/types";
import { useAuth } from "@/providers/auth-provider";
import { useEvaluator } from "@/providers/evaluator-provider";
import { updateApplicant } from "@/services/evaluator";
import { Timestamp } from "firebase/firestore";
import { useCallback, useEffect, useState } from "react";
import { SCORING_CRITERIA, type ScoringCriteria } from "./constants";

export function ApplicantScoring() {
const { user } = useAuth();
const { hackathon, focusedApplicant } = useEvaluator();
const { hackathon, focusedApplicant, scoringCriteria } = useEvaluator();

const [scores, setScores] = useState<Record<string, ApplicantScoreItem>>({});
const [comment, setComment] = useState<string>("");
Expand Down Expand Up @@ -65,7 +64,7 @@ export function ApplicantScoring() {
[field]: newScore,
},
...newMetadata,
totalScore: SCORING_CRITERIA.reduce((sum, criteria) => {
totalScore: scoringCriteria.reduce((sum, criteria) => {
const scoreItem = updatedScores[criteria.field];
const scoreValue = typeof scoreItem?.score === "number" ? scoreItem.score : 0;
return sum + scoreValue * criteria.weight;
Expand All @@ -78,7 +77,7 @@ export function ApplicantScoring() {
const areAllCategoriesScored = () => {
if (!scores || Object.keys(scores).length === 0) return false;

return SCORING_CRITERIA.every((criteria) => {
return scoringCriteria.every((criteria) => {
const score = scores[criteria.field];
return score && typeof score.score === "number";
});
Expand Down Expand Up @@ -142,14 +141,17 @@ export function ApplicantScoring() {
<CardTitle>Scoring</CardTitle>
</CardHeader>
<CardContent className="flex flex-grow flex-col gap-5 overflow-auto">
{SCORING_CRITERIA?.map((criteria) => (
<ScoringItem
key={criteria.field}
{...criteria}
currentScore={scores[criteria.field]}
onChange={handleScoreChange}
/>
))}
{scoringCriteria?.map(
(criteria) =>
!criteria.isDisabled && (
<ScoringItem
key={criteria.field}
{...criteria}
currentScore={scores[criteria.field]}
onChange={handleScoreChange}
/>
),
)}
<div className="flex flex-col gap-2 pb-0.5">
<Label>Comments</Label>
<Textarea
Expand Down
87 changes: 22 additions & 65 deletions src/components/features/evaluator/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ApplicantEducationLevel } from "@/lib/firebase/types";
import type { MultiSelectOption } from "@/components/ui/multi-select";
import type { ApplicantEducationLevel } from "@/lib/firebase/types";

/**
* ====================================================================
Expand All @@ -15,74 +15,28 @@ export const RESPONSE_VISIBLE_FIELDS = [
{ field: "skills.contributionRole", type: "booleanMap", label: "Role" },
{ field: "basicInfo.educationLevel", type: "short", label: "Year Level" },
{ field: "skills.numHackathonsAttended", type: "short", label: "Number of Hackathons Attended" },
{ field: "skills.longAnswers1", type: "long", label: "Long Answer 1" },
{ field: "skills.longAnswers2", type: "long", label: "Long Answer 2" },
{ field: "skills.longAnswers3", type: "long", label: "Long Answer 3" },
// { field: "skills.longAnswers4", type: "long", label: "Long Answer 4" },
{ field: "skills.portfolio", type: "link", label: "Portfolio" },
{ field: "skills.github", type: "link", label: "GitHub" },
{ field: "skills.linkedin", type: "link", label: "LinkedIn" },
{ field: "skills.resume", type: "resume", label: "Resume" },
];

export interface ScoringCriteria {
label: string;
field: string;
minScore: number;
maxScore: number;
increments: number;
weight: number;
}

export const SCORING_CRITERIA: ScoringCriteria[] = [
{
label: "Resume",
field: "ResumeScore",
minScore: 0,
maxScore: 1,
increments: 1,
weight: 1.0,
},
// {
// label: "Experience",
// field: "NumExperiences",
// minScore: 0,
// maxScore: 5,
// increments: 1,
// weight: 1.0,
// },
{
label: "Response 1 Score",
field: "ResponseOneScore",
minScore: 0,
maxScore: 4,
increments: 1,
weight: 1.0,
field: "skills.longAnswers1",
type: "long",
label: "Long Answer 1",
scoreName: "ResponseOneScore",
},
{
label: "Response 2 Score",
field: "ResponseTwoScore",
minScore: 0,
maxScore: 4,
increments: 1,
weight: 1.0,
field: "skills.longAnswers2",
type: "long",
label: "Long Answer 2",
scoreName: "ResponseTwoScore",
},
{
label: "Response 3 Score",
field: "ResponseThreeScore",
minScore: 0,
maxScore: 4,
increments: 1,
weight: 1.0,
field: "skills.longAnswers3",
type: "long",
label: "Long Answer 3",
scoreName: "ResponseThreeScore",
},
// {
// label: "Response 4 Score",
// field: "ResponseFourScore",
// minScore: -1,
// maxScore: 5,
// increments: 1,
// weight: 1.0,
// },
{ field: "skills.portfolio", type: "link", label: "Portfolio" },
{ field: "skills.github", type: "link", label: "GitHub" },
{ field: "skills.linkedin", type: "link", label: "LinkedIn" },
{ field: "skills.resume", type: "resume", label: "Resume", scoreName: "ResumeScore" },
];

export const CONTRIBUTION_ROLE_OPTIONS: MultiSelectOption[] = [
Expand All @@ -104,7 +58,10 @@ export const CONTRIBUTION_ROLE_OPTIONS: MultiSelectOption[] = [
},
];

export const YEAR_LEVEL_OPTIONS: Array<{ label: ApplicantEducationLevel; value: ApplicantEducationLevel }> = [
export const YEAR_LEVEL_OPTIONS: Array<{
label: ApplicantEducationLevel;
value: ApplicantEducationLevel;
}> = [
{ label: "Less than Secondary / High School", value: "Less than Secondary / High School" },
{ label: "Secondary / High School", value: "Secondary / High School" },
{
Expand All @@ -124,4 +81,4 @@ export const YEAR_LEVEL_OPTIONS: Array<{ label: ApplicantEducationLevel; value:
{ label: "Post-Doctorate", value: "Post-Doctorate" },
{ label: "I'm not currently a student", value: "I'm not currently a student" },
{ label: "Prefer not to answer", value: "Prefer not to answer" },
];
];
Loading