forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

student-directory-columns.tsx35 lines, 1.5 KiBHistoryRawDownload
1import type { ColumnDef } from "@tanstack/solid-table";
2import type { StudentDirectoryRow } from "@/lib/student-directory";
3import type { useT } from "@/stores/preferences-context";
4
5/**
6 * The three identifying columns every teacher-facing tracking table opens with —
7 * student number, name, class — so Yoklamalar, Sınav Notları and Pomodorolar
8 * read the same row the same way. Each page appends its own columns after these.
9 */
10export function studentDirectoryColumns(t: ReturnType<typeof useT>): ColumnDef<StudentDirectoryRow>[] {
11 return [
12 {
13 id: "studentNumber",
14 // Sorts as text: the backend stores a free-text number, not an integer.
15 accessorFn: (row) => row.person.student_number ?? "",
16 header: t("roster.studentNumber"),
17 meta: { headerClass: "w-32 min-w-32 whitespace-nowrap" },
18 cell: (cell) => (
19 <span class="tabular-nums text-muted-foreground">{cell.row.original.person.student_number || "—"}</span>
20 ),
21 },
22 {
23 id: "student",
24 accessorFn: (row) => row.person.display_name || row.person.username,
25 header: t("roster.name"),
26 cell: (cell) => <span class="font-medium">{cell.row.original.person.display_name || t("exams.nameless")}</span>,
27 },
28 {
29 id: "class",
30 accessorFn: (row) => row.classes.map((cls) => cls.name).join(", "),
31 header: t("roster.studentClass"),
32 cell: (cell) => <span>{cell.row.original.classes.map((cls) => cls.name).join(", ") || "—"}</span>,
33 },
34 ];
35}