hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 2 | import type { StudentDirectoryRow } from "@/lib/student-directory"; |
| 3 | import 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 | */ |
| 10 | export 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 | } |