From b618766889e662ed4dfafca4b57498580bc00770 Mon Sep 17 00:00:00 2001 From: tdanielles Date: Wed, 18 Dec 2024 20:59:55 +0800 Subject: [PATCH] add calc z-score btn, n/a score status, and status tag updates --- components/Evaluator/CalcZScoreButton.js | 16 +++++++++++++++ components/Evaluator/HackerEntry.js | 9 ++++++-- components/Evaluator/Scoring.js | 26 +++++++++++++++++++++++- constants.js | 12 +++++++++++ pages/eval.js | 4 +++- 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 components/Evaluator/CalcZScoreButton.js diff --git a/components/Evaluator/CalcZScoreButton.js b/components/Evaluator/CalcZScoreButton.js new file mode 100644 index 00000000..97e77a17 --- /dev/null +++ b/components/Evaluator/CalcZScoreButton.js @@ -0,0 +1,16 @@ +import React from 'react' +import styled from 'styled-components' +import { COLOR } from '../../constants' +import Button from '../button' + +const StyledButton = styled(Button)` + background: ${COLOR.MIDNIGHT_PURPLE_LIGHT}; + color: white; + display: inline-flex; + justify-content: center; + align-items: center; +` + +export default function CalcZScoreButton() { + return Calculate z-score +} diff --git a/components/Evaluator/HackerEntry.js b/components/Evaluator/HackerEntry.js index 25074249..c8f424eb 100644 --- a/components/Evaluator/HackerEntry.js +++ b/components/Evaluator/HackerEntry.js @@ -59,6 +59,8 @@ const StyledTag = styled.div` ? `background: ${ASSESSMENT_COLOR.YELLOW};` : p.status === APPLICATION_STATUS.scored.text ? `background: ${ASSESSMENT_COLOR.BLUE};` + : p.status === APPLICATION_STATUS.gradinginprog.text + ? `background: ${ASSESSMENT_COLOR.DARK_GRAY};` : `background: ${ASSESSMENT_COLOR.RED};`} padding: 0px 5px; border-radius: 4px; @@ -93,8 +95,11 @@ export default function HackerEntry({ return {APPLICATION_STATUS.waitlisted.displayText} case APPLICATION_STATUS.rejected.text: return {APPLICATION_STATUS.rejected.displayText} + case APPLICATION_STATUS.gradinginprog.text: + return {APPLICATION_STATUS.gradinginprog.displayText} + case APPLICATION_STATUS.ungraded.text: default: - return Ungraded + return {APPLICATION_STATUS.ungraded.displayText} } } @@ -107,7 +112,7 @@ export default function HackerEntry({ Applicant {index} - Score: {score?.totalScore ?? '?'}/{MAX_SCORE} + Score: {score?.totalScore !== undefined ? `${score.totalScore}/${MAX_SCORE}` : 'n/a'} {getStyleTag()} diff --git a/components/Evaluator/Scoring.js b/components/Evaluator/Scoring.js index 3c282aeb..8a3293c4 100644 --- a/components/Evaluator/Scoring.js +++ b/components/Evaluator/Scoring.js @@ -95,6 +95,28 @@ export default function Scoring({ shouldDisplay, applicant }) { setTotalScore(calculateTotalScore(newScores)) } + // if none of the required fields are in scores or if scores doesnt even exist, set APPLICATION_STATUS.ungraded.text + // if one of the reuiqred fields are in scores and not all, set APPLICATION_STATUS.gradinginprog.text + // if all required fields are in, set APPLICATION_STATUS.scored.text + const getStatus = scores => { + // TODO: UPDATE REQUIRED FIELDS PER HACKATHON + const requiredFields = ['ResumeScore', 'ResponseOneScore', 'ResponseTwoScore', 'ResponseThreeScore'] + + if (!scores) { + return APPLICATION_STATUS.ungraded.text + } + + const filledFields = requiredFields.filter(field => scores[field] !== null && scores[field] !== undefined) + + if (filledFields.length === 0) { + return APPLICATION_STATUS.ungraded.text + } else if (filledFields.length < requiredFields.length) { + return APPLICATION_STATUS.gradinginprog.text + } else { + return APPLICATION_STATUS.scored.text + } + } + const handleSave = async () => { const updatedScores = await updateApplicantScore( applicant._id, @@ -103,7 +125,9 @@ export default function Scoring({ shouldDisplay, applicant }) { comment, user.email ) - await updateApplicantStatus(applicant._id, APPLICATION_STATUS.scored.text) + // checks if all fields have scores and update accordingly + const newStatus = getStatus(updatedScores) + await updateApplicantStatus(applicant._id, newStatus) setScores(updatedScores) } diff --git a/constants.js b/constants.js index 56b73a5f..8ee9fff9 100644 --- a/constants.js +++ b/constants.js @@ -134,6 +134,18 @@ export const APPLICATION_STATUS = { text: 'rejected', displayText: 'Rejected', }, + gradinginprog: { + color: ASSESSMENT_COLOR.DARK_GRAY, + textColor: 'white', + text: 'gradinginprog', + displayText: 'In progress', + }, + ungraded: { + color: ASSESSMENT_COLOR.RED, + textColor: 'white', + text: 'ungraded', + displayText: 'Ungraded', + }, scored: { color: ASSESSMENT_COLOR.BLUE, textColor: 'white', diff --git a/pages/eval.js b/pages/eval.js index cf2bde4c..2c2808fc 100644 --- a/pages/eval.js +++ b/pages/eval.js @@ -6,6 +6,7 @@ import Rubric from '../components/Evaluator/Rubric' import Scoring from '../components/Evaluator/Scoring' import Page from '../components/page' import { getAllApplicants, getHackathons } from '../utility/firebase' +import CalcZScoreButton from '../components/Evaluator/CalcZScoreButton' const Container = styled.div` display: grid; @@ -45,7 +46,8 @@ export default function Eval({ hackathons }) { return ( - + +