-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add staff evaluations page and component * Refactor staff evaluations page and component * add: simple evaluation slots page * Refactor staff evaluations page and component * Refactor evaluation slots page link URL * chore: bump version * Add fish shell feature to dev container * Refactor link URL for staff evaluations page * Refactor link URL for staff evaluations page * Refactor link URL for staff evaluations page * Refactor link URL for staff evaluations page
- Loading branch information
Showing
46 changed files
with
5,190 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Link from "next/link"; | ||
import { BackBtn } from "@/components/back-btn"; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/table"; | ||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import { getEvaluatedSlots, transformEvaluationSlots } from "./utils"; | ||
|
||
export default async function Page() { | ||
const dbEvaluationSlots = await getEvaluatedSlots(); | ||
const evaluationSlots = transformEvaluationSlots(dbEvaluationSlots); | ||
|
||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<BackBtn /> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Evaluated Slots</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>Action</TableHead> | ||
<TableHead>Project</TableHead> | ||
<TableHead>Date</TableHead> | ||
<TableHead>Status</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{evaluationSlots.map((slot) => ( | ||
<TableRow key={slot.id}> | ||
<TableCell> | ||
<Link | ||
href={`/staff/evaluations?evaluationSlotId=${slot.id}`} | ||
className="text-blue-600 hover:underline" | ||
> | ||
View | ||
</Link> | ||
</TableCell> | ||
<TableCell>{slot.project}</TableCell> | ||
<TableCell>{new Date(slot.date).toLocaleString()}</TableCell> | ||
<TableCell>{slot.status}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { db } from "@/lib/db/clients"; | ||
import { evaluationSlots } from "@/drizzle/schemas"; | ||
import { and, desc, isNotNull } from "drizzle-orm"; | ||
|
||
type DbEvaluationSlot = { | ||
id: string; | ||
startDateTime: Date; | ||
project: string | null; | ||
isEvaluated: boolean; | ||
}; | ||
|
||
type EvaluationSlot = { | ||
id: string; | ||
project: string; | ||
date: string; | ||
status: string; | ||
}; | ||
|
||
export async function getEvaluatedSlots(): Promise<DbEvaluationSlot[]> { | ||
return await db.query.evaluationSlots.findMany({ | ||
where: and( | ||
isNotNull(evaluationSlots.isEvaluated), | ||
evaluationSlots.isEvaluated | ||
), | ||
columns: { | ||
id: true, | ||
startDateTime: true, | ||
project: true, | ||
isEvaluated: true, | ||
}, | ||
orderBy: desc(evaluationSlots.startDateTime), | ||
}); | ||
} | ||
|
||
export function transformEvaluationSlots( | ||
dbSlots: DbEvaluationSlot[] | ||
): EvaluationSlot[] { | ||
return dbSlots.map((slot) => ({ | ||
id: slot.id, | ||
project: slot.project || "Unknown", | ||
date: slot.startDateTime.toISOString(), | ||
status: slot.isEvaluated ? "Completed" : "Pending", | ||
})); | ||
} |
52 changes: 52 additions & 0 deletions
52
app/app/(staff)/staff/evaluations/_components/staff-evaluations/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { BackBtn } from "@/components/back-btn"; | ||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/table"; | ||
import { transformEvaluations } from "../../utils"; | ||
|
||
export function StaffEvaluations({ | ||
evaluations, | ||
}: { | ||
evaluations: Awaited<ReturnType<typeof transformEvaluations>>; | ||
}) { | ||
return ( | ||
<main className="flex flex-col gap-4"> | ||
<BackBtn /> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Evaluations</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
<TableHead>Project</TableHead> | ||
<TableHead>Student</TableHead> | ||
<TableHead>Comment</TableHead> | ||
<TableHead>Evaluator</TableHead> | ||
<TableHead>Date</TableHead> | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{evaluations.map((evaluation) => ( | ||
<TableRow key={evaluation.id}> | ||
<TableCell>{evaluation.project}</TableCell> | ||
<TableCell>{evaluation.student}</TableCell> | ||
<TableHead>{evaluation.comment}</TableHead> | ||
<TableCell>{evaluation.evaluator}</TableCell> | ||
<TableCell>{evaluation.date}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</CardContent> | ||
</Card> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { StaffEvaluations } from "./_components/staff-evaluations"; | ||
import { getAllEvaluations, transformEvaluations } from "./utils"; | ||
|
||
export default async function Page({ | ||
searchParams, | ||
}: { | ||
searchParams?: { | ||
evaluationSlotId?: string; | ||
}; | ||
}) { | ||
const dbEvaluations = await getAllEvaluations({ | ||
evaluationSlotId: searchParams?.evaluationSlotId || "", | ||
}); | ||
const evaluationsData = transformEvaluations(dbEvaluations); | ||
|
||
return <StaffEvaluations evaluations={evaluationsData} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { db } from "@/lib/db/clients"; | ||
import { evaluationSlots, accounts } from "@/drizzle/schemas"; | ||
import { eq } from "drizzle-orm"; | ||
|
||
export function transformEvaluations( | ||
dbEvaluations: Awaited<ReturnType<typeof getAllEvaluations>> | ||
) { | ||
return dbEvaluations.flatMap((slot) => | ||
slot.evaluatees.map((evaluatee) => ({ | ||
id: evaluatee.id, | ||
student: evaluatee.user.name || "Unknown", | ||
evaluator: slot.evaluator ? slot.evaluator.name : "Unknown", | ||
project: slot.project || "Unknown", | ||
date: slot.startDateTime.toISOString(), | ||
comment: evaluatee.comment, | ||
})) | ||
); | ||
} | ||
|
||
export async function getAllEvaluations({ | ||
evaluationSlotId, | ||
}: { | ||
evaluationSlotId: string; | ||
}) { | ||
return await db.query.evaluationSlots.findMany({ | ||
where: eq(evaluationSlots.id, evaluationSlotId), | ||
with: { | ||
evaluator: true, | ||
evaluatees: { | ||
columns: { | ||
id: true, | ||
comment: true, | ||
isTeamLeader: true, | ||
}, | ||
with: { | ||
user: { | ||
with: { | ||
accounts: { | ||
where: eq(accounts.provider, "42-school"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as AccordionPrimitive from "@radix-ui/react-accordion" | ||
import { ChevronDownIcon } from "@radix-ui/react-icons" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Accordion = AccordionPrimitive.Root | ||
|
||
const AccordionItem = React.forwardRef< | ||
React.ElementRef<typeof AccordionPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> | ||
>(({ className, ...props }, ref) => ( | ||
<AccordionPrimitive.Item | ||
ref={ref} | ||
className={cn("border-b", className)} | ||
{...props} | ||
/> | ||
)) | ||
AccordionItem.displayName = "AccordionItem" | ||
|
||
const AccordionTrigger = React.forwardRef< | ||
React.ElementRef<typeof AccordionPrimitive.Trigger>, | ||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> | ||
>(({ className, children, ...props }, ref) => ( | ||
<AccordionPrimitive.Header className="flex"> | ||
<AccordionPrimitive.Trigger | ||
ref={ref} | ||
className={cn( | ||
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180", | ||
className | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
<ChevronDownIcon className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" /> | ||
</AccordionPrimitive.Trigger> | ||
</AccordionPrimitive.Header> | ||
)) | ||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName | ||
|
||
const AccordionContent = React.forwardRef< | ||
React.ElementRef<typeof AccordionPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content> | ||
>(({ className, children, ...props }, ref) => ( | ||
<AccordionPrimitive.Content | ||
ref={ref} | ||
className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down" | ||
{...props} | ||
> | ||
<div className={cn("pb-4 pt-0", className)}>{children}</div> | ||
</AccordionPrimitive.Content> | ||
)) | ||
AccordionContent.displayName = AccordionPrimitive.Content.displayName | ||
|
||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } |
Oops, something went wrong.