Commit ·
4b49912
1
Parent(s): 2b48478
Hot Fixes.
Browse files- frontend/app/components/question-card.tsx +6 -6
- frontend/app/routes.ts +1 -1
- frontend/app/routes/jobs.$jid.assessments.$aid.applications.$id.tsx +2 -3
- frontend/app/routes/{jobs.$jid.assessment.$aid.applications.tsx → jobs.$jid.assessments.$aid.applications.tsx} +1 -1
- frontend/app/routes/jobs.$jid.assessments.$id.tsx +1 -1
frontend/app/components/question-card.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
|
|
| 1 |
import { Label } from "radix-ui";
|
| 2 |
import { Checkbox } from "./ui/checkbox";
|
| 3 |
import { Textarea } from "./ui/textarea";
|
| 4 |
import { RadioGroup, RadioGroupItem } from "./ui/radio-group";
|
| 5 |
import type { Assessment } from "~/services/useGetJobAssessments";
|
| 6 |
-
import { cn } from "~/lib/utils";
|
| 7 |
|
| 8 |
export function QuestionCard({
|
| 9 |
answers,
|
|
@@ -12,22 +12,22 @@ export function QuestionCard({
|
|
| 12 |
setAnswers,
|
| 13 |
totalWeights,
|
| 14 |
isStatic = false,
|
|
|
|
| 15 |
} : {
|
| 16 |
isStatic?: boolean;
|
| 17 |
rationale?: string;
|
| 18 |
totalWeights: number;
|
| 19 |
answers: Record<string, any>;
|
|
|
|
| 20 |
question: Assessment["questions"][number];
|
| 21 |
setAnswers: React.Dispatch<React.SetStateAction<Record<string, any>>>;
|
| 22 |
}) {
|
| 23 |
-
console.log({answers})
|
| 24 |
-
|
| 25 |
return (
|
| 26 |
<div className="border p-4 flex flex-col gap-2 rounded bg-indigo-100 dark:bg-gray-800">
|
| 27 |
<header className="flex place-content-between gap-4 place-items-start">
|
| 28 |
<h4 className="font-semibold mb-2">{question.text}</h4>
|
| 29 |
<span className="inline-flex gap-2 place-items-center px-3 py-1.5 rounded-xl bg-indigo-50 dark:bg-gray-700">
|
| 30 |
-
{totalWeights > 0 ? `~${Math.floor((question.weight / totalWeights) * 100)
|
| 31 |
</span>
|
| 32 |
</header>
|
| 33 |
{{
|
|
@@ -75,8 +75,8 @@ export function QuestionCard({
|
|
| 75 |
) : "cursor-pointer")}>{option.text}</Label.Label>
|
| 76 |
</div>
|
| 77 |
))}
|
| 78 |
-
{isStatic && question.correct_options && question.correct_options.some(co => !(answers[question.id] || []).includes(co)) &&
|
| 79 |
-
<div className="text-red-600 dark:text-red-400 mt-2">(
|
| 80 |
</div>
|
| 81 |
),
|
| 82 |
}[question.type]}
|
|
|
|
| 1 |
+
import { cn } from "~/lib/utils";
|
| 2 |
import { Label } from "radix-ui";
|
| 3 |
import { Checkbox } from "./ui/checkbox";
|
| 4 |
import { Textarea } from "./ui/textarea";
|
| 5 |
import { RadioGroup, RadioGroupItem } from "./ui/radio-group";
|
| 6 |
import type { Assessment } from "~/services/useGetJobAssessments";
|
|
|
|
| 7 |
|
| 8 |
export function QuestionCard({
|
| 9 |
answers,
|
|
|
|
| 12 |
setAnswers,
|
| 13 |
totalWeights,
|
| 14 |
isStatic = false,
|
| 15 |
+
displayCheckboxMessage = false,
|
| 16 |
} : {
|
| 17 |
isStatic?: boolean;
|
| 18 |
rationale?: string;
|
| 19 |
totalWeights: number;
|
| 20 |
answers: Record<string, any>;
|
| 21 |
+
displayCheckboxMessage?: boolean;
|
| 22 |
question: Assessment["questions"][number];
|
| 23 |
setAnswers: React.Dispatch<React.SetStateAction<Record<string, any>>>;
|
| 24 |
}) {
|
|
|
|
|
|
|
| 25 |
return (
|
| 26 |
<div className="border p-4 flex flex-col gap-2 rounded bg-indigo-100 dark:bg-gray-800">
|
| 27 |
<header className="flex place-content-between gap-4 place-items-start">
|
| 28 |
<h4 className="font-semibold mb-2">{question.text}</h4>
|
| 29 |
<span className="inline-flex gap-2 place-items-center px-3 py-1.5 rounded-xl bg-indigo-50 dark:bg-gray-700">
|
| 30 |
+
{totalWeights > 0 ? `~${Math.floor((question.weight / totalWeights) * 100)}%` : "0%"}
|
| 31 |
</span>
|
| 32 |
</header>
|
| 33 |
{{
|
|
|
|
| 75 |
) : "cursor-pointer")}>{option.text}</Label.Label>
|
| 76 |
</div>
|
| 77 |
))}
|
| 78 |
+
{isStatic && displayCheckboxMessage && question.correct_options && question.correct_options.some(co => !(answers[question.id] || []).includes(co)) &&
|
| 79 |
+
<div className="text-red-600 dark:text-red-400 mt-2">(Not all correct answers are selected)</div>}
|
| 80 |
</div>
|
| 81 |
),
|
| 82 |
}[question.type]}
|
frontend/app/routes.ts
CHANGED
|
@@ -7,7 +7,7 @@ export default [
|
|
| 7 |
route("jobs/:id", "routes/jobs.$id.tsx"),
|
| 8 |
route("jobs/:jid/assessments/generate", "routes/jobs.$jid.assessments.generate.tsx"),
|
| 9 |
route("jobs/:jid/assessments/:id", "routes/jobs.$jid.assessments.$id.tsx"),
|
| 10 |
-
route("jobs/:jid/
|
| 11 |
route("jobs/:jid/assessments/:aid/applications/:id", "routes/jobs.$jid.assessments.$aid.applications.$id.tsx"),
|
| 12 |
route("dashboard", "routes/dashboard.tsx"),
|
| 13 |
route("registration", "routes/registration.tsx"),
|
|
|
|
| 7 |
route("jobs/:id", "routes/jobs.$id.tsx"),
|
| 8 |
route("jobs/:jid/assessments/generate", "routes/jobs.$jid.assessments.generate.tsx"),
|
| 9 |
route("jobs/:jid/assessments/:id", "routes/jobs.$jid.assessments.$id.tsx"),
|
| 10 |
+
route("jobs/:jid/assessments/:aid/applications", "routes/jobs.$jid.assessments.$aid.applications.tsx"),
|
| 11 |
route("jobs/:jid/assessments/:aid/applications/:id", "routes/jobs.$jid.assessments.$aid.applications.$id.tsx"),
|
| 12 |
route("dashboard", "routes/dashboard.tsx"),
|
| 13 |
route("registration", "routes/registration.tsx"),
|
frontend/app/routes/jobs.$jid.assessments.$aid.applications.$id.tsx
CHANGED
|
@@ -48,15 +48,14 @@ export default function ApplicationDetailsRoute() {
|
|
| 48 |
|
| 49 |
const totalWeights = application.answers.reduce((weights, answer) => weights + answer.weight, 0);
|
| 50 |
|
| 51 |
-
console.log(application)
|
| 52 |
-
|
| 53 |
return (
|
| 54 |
-
<main className="container mx-auto p-4 flex flex-col gap-
|
| 55 |
<ApplicationCard application={application} aid={aid || ""} jid={jid || ""} isStatic />
|
| 56 |
{application.answers.map((answer: DetailedApplication["answers"][number]) => (
|
| 57 |
<QuestionCard
|
| 58 |
key={answer.question_id}
|
| 59 |
isStatic
|
|
|
|
| 60 |
question={{
|
| 61 |
type: answer.type,
|
| 62 |
weight: answer.weight,
|
|
|
|
| 48 |
|
| 49 |
const totalWeights = application.answers.reduce((weights, answer) => weights + answer.weight, 0);
|
| 50 |
|
|
|
|
|
|
|
| 51 |
return (
|
| 52 |
+
<main className="container mx-auto p-4 flex flex-col gap-4">
|
| 53 |
<ApplicationCard application={application} aid={aid || ""} jid={jid || ""} isStatic />
|
| 54 |
{application.answers.map((answer: DetailedApplication["answers"][number]) => (
|
| 55 |
<QuestionCard
|
| 56 |
key={answer.question_id}
|
| 57 |
isStatic
|
| 58 |
+
displayCheckboxMessage
|
| 59 |
question={{
|
| 60 |
type: answer.type,
|
| 61 |
weight: answer.weight,
|
frontend/app/routes/{jobs.$jid.assessment.$aid.applications.tsx → jobs.$jid.assessments.$aid.applications.tsx}
RENAMED
|
@@ -6,7 +6,7 @@ import { useGetJobByID } from "~/services/useGetJobsByID";
|
|
| 6 |
import { AssessmentCard } from "~/components/assessment-card";
|
| 7 |
import { ApplicationCard } from "~/components/application-card";
|
| 8 |
import { useGetJobAssessmentByID } from "~/services/useGetJobAssessmentByID";
|
| 9 |
-
import type { Route } from "./+types/jobs.$jid.
|
| 10 |
import { useGetJobAssessmentApplications } from "~/services/useGetJobAssessmentApplications";
|
| 11 |
|
| 12 |
export function meta({}: Route.MetaArgs) {
|
|
|
|
| 6 |
import { AssessmentCard } from "~/components/assessment-card";
|
| 7 |
import { ApplicationCard } from "~/components/application-card";
|
| 8 |
import { useGetJobAssessmentByID } from "~/services/useGetJobAssessmentByID";
|
| 9 |
+
import type { Route } from "./+types/jobs.$jid.assessments.$aid.applications";
|
| 10 |
import { useGetJobAssessmentApplications } from "~/services/useGetJobAssessmentApplications";
|
| 11 |
|
| 12 |
export function meta({}: Route.MetaArgs) {
|
frontend/app/routes/jobs.$jid.assessments.$id.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export default function AssessmentDetailRoute() {
|
|
| 91 |
<main className="container mx-auto p-4 flex flex-col gap-8">
|
| 92 |
<AssessmentCard jid={jid || ""} assessment={assessment} isStatic />
|
| 93 |
{myUser.role == "hr" && (
|
| 94 |
-
<Link to={`/jobs/${jid}/
|
| 95 |
View Applications for this Assessment
|
| 96 |
<ExternalLinkIcon className="inline -translate-y-1 mx-2" />
|
| 97 |
</Link>
|
|
|
|
| 91 |
<main className="container mx-auto p-4 flex flex-col gap-8">
|
| 92 |
<AssessmentCard jid={jid || ""} assessment={assessment} isStatic />
|
| 93 |
{myUser.role == "hr" && (
|
| 94 |
+
<Link to={`/jobs/${jid}/assessments/${id}/applications`} className="text-indigo-600 hover:underline">
|
| 95 |
View Applications for this Assessment
|
| 96 |
<ExternalLinkIcon className="inline -translate-y-1 mx-2" />
|
| 97 |
</Link>
|