diff --git a/src/components/insights/insight-students-table.tsx b/src/components/insights/insight-students-table.tsx index b475119..3e7c319 100644 --- a/src/components/insights/insight-students-table.tsx +++ b/src/components/insights/insight-students-table.tsx @@ -54,8 +54,15 @@ export function InsightStudentsTable(props: { const muted = "text-muted-foreground"; // The app-wide "18 Eyl 2026" date, not a numeric 18.09.2026. const calculatedDate = (value: number | null | undefined) => formatDate(value, locale()); + // A cell with no value to show wears the same quiet pill as "Analiz yok", + // so the empty states read as one kind of thing across the row. + const emptyPill = (row: StudentSignal) => ( + + {row.state === "not_loaded" ? rt("notLoaded") : t("insights.noData")} + + ); - // Widths sum to ~1095px with the action column, so the grid fits a 1440px + // Widths sum to ~1105px with the action column, so the grid fits a 1440px // screen beside the sidebar; at the 120px default every column got, the // last one slid under the sticky actions and the table asked to scroll. const columns = createMemo[]>(() => [ @@ -73,24 +80,30 @@ export function InsightStudentsTable(props: { }, { id: "status", - size: 108, + size: 118, accessorFn: (row) => row.state, header: rt("status" as never), meta: { align: "center" }, cell: (cell) => { const row = cell.row.original; + // The badge is one 20px line: the full "no analysis computed" sentence + // wrapped inside it and spilled over the rows above and below, so the + // cell shows a short label and the sentence rides in the tooltip. + const label = row.state === "error" + ? t("insights.readFailed") + : row.state === "no_summary" ? t("insights.noAnalysis") : studentStatusText(locale(), row); return ( - {row.state === "error" ? t("insights.readFailed") : studentStatusText(locale(), row)} + {label} ); }, @@ -121,7 +134,9 @@ export function InsightStudentsTable(props: { accessorFn: (row) => row.marks.average ?? -1, header: rt("marksAverage"), meta: { align: "center" }, - cell: (cell) => {studentMarksText(locale(), cell.row.original)}, + cell: (cell) => loaded(cell.row.original) + ? {studentMarksText(locale(), cell.row.original)} + : emptyPill(cell.row.original), }, { id: "attendance", @@ -131,8 +146,9 @@ export function InsightStudentsTable(props: { meta: { align: "center" }, cell: (cell) => { const row = cell.row.original; - const low = loaded(row) && row.attendance.observed > 0 && (row.attendance.rate ?? 1) < 0.85; - return {studentAttendanceText(locale(), row)}; + if (!loaded(row) || row.attendance.observed === 0) return emptyPill(row); + const low = (row.attendance.rate ?? 1) < 0.85; + return {studentAttendanceText(locale(), row)}; }, }, { diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 1d4668e..ffd6047 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -680,6 +680,8 @@ export const en: Dict = { "common.saved": "Saved successfully.", "common.loadAll": "Load all", "insights.readFailed": "Could not read", + "insights.noAnalysis": "No analysis", + "insights.noData": "No data", "insights.studyStints": "Focus", "insights.filter.all": "All", "insights.filter.attention": "Needs attention", @@ -1116,6 +1118,7 @@ export const en: Dict = { "insights.recompute": "Recompute", "insights.recomputing": "Queuing…", "insights.recomputeQueued": "Analysis for {student} was queued.", + "insights.recomputeQueuedUnnamed": "The analysis was queued.", "insights.summary": "Summary", "insights.noSummary": "No analysis yet", "insights.noSummaryHint": "Queue a computation to create the first analysis.", diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts index a864a47..617997b 100644 --- a/src/i18n/locales/tr.ts +++ b/src/i18n/locales/tr.ts @@ -676,6 +676,8 @@ export const tr: Dict = { "common.saved": "Başarıyla kaydedildi.", "common.loadAll": "Tümünü yükle", "insights.readFailed": "Okunamadı", + "insights.noAnalysis": "Analiz yok", + "insights.noData": "Veri yok", "insights.studyStints": "Odak", "insights.filter.all": "Tümü", "insights.filter.attention": "Dikkat gerekenler", @@ -1112,6 +1114,7 @@ export const tr: Dict = { "insights.recompute": "Yeniden hesapla", "insights.recomputing": "Sıraya alınıyor…", "insights.recomputeQueued": "{student} için analiz sıraya alındı.", + "insights.recomputeQueuedUnnamed": "Analiz sıraya alındı.", "insights.summary": "Özet", "insights.noSummary": "Henüz analiz yok", "insights.noSummaryHint": "İlk analizi oluşturmak için hesaplamayı sıraya alın.", diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 6420990..9749000 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -664,6 +664,8 @@ export type MessageKey = | "common.saved" | "common.loadAll" | "insights.readFailed" + | "insights.noAnalysis" + | "insights.noData" | "insights.studyStints" | "insights.filter.all" | "insights.filter.attention" @@ -1103,6 +1105,7 @@ export type MessageKey = | "insights.recompute" | "insights.recomputing" | "insights.recomputeQueued" + | "insights.recomputeQueuedUnnamed" | "insights.summary" | "insights.noSummary" | "insights.noSummaryHint" diff --git a/src/pages/ai-insight-student-page.tsx b/src/pages/ai-insight-student-page.tsx index f898658..2b7ae27 100644 --- a/src/pages/ai-insight-student-page.tsx +++ b/src/pages/ai-insight-student-page.tsx @@ -16,6 +16,7 @@ import { createFlash } from "@/lib/flash"; import { loadInsightStudents } from "@/lib/insight-students"; import { personLabel } from "@/lib/person"; import { hasMinRole } from "@/lib/roles"; +import { runReportText } from "@/i18n/insights-run-report"; import { useAuth } from "@/stores/auth-context"; import { formatDate } from "@/lib/format"; import { usePreferences } from "@/stores/preferences-context"; @@ -53,11 +54,24 @@ function AiInsightStudentContent() { const [actionError, setActionError] = createSignal(""); const [flash, setFlash] = createFlash(); - const [students] = createResource(() => role() ?? null, (viewerRole) => loadInsightStudents(viewerRole).catch(() => [])); - const person = createMemo(() => (students() ?? []).find((student) => student.id === userId()) ?? null); + // A failed roster read is kept apart from an empty one: swallowing it into + // `[]` told a rate-limited viewer the student was "not in your list" and + // put the raw account id where the name goes. + const [roster, { refetch: refetchRoster }] = createResource( + () => role() ?? null, + (viewerRole) => loadInsightStudents(viewerRole).then( + (list) => ({ list, error: null as unknown }), + (error: unknown) => ({ list: null, error }), + ), + ); + const person = createMemo(() => roster()?.list?.find((student) => student.id === userId()) ?? null); + const notInList = () => roster()?.list != null && !person(); const [insight, { refetch }] = createResource(userId, (id) => getInsightByUserId(id)); - const studentName = () => person() ? personLabel(person()!) : userId(); - const initials = () => studentName() + const studentName = () => { + const current = person(); + return current ? personLabel(current) : null; + }; + const initials = () => (studentName() ?? "") .split(/\s+/) .filter(Boolean) .slice(0, 2) @@ -77,7 +91,7 @@ function AiInsightStudentContent() { setActionError(""); try { await postInsightComputeByUserId(userId()); - setFlash(t("insights.recomputeQueued", { student: current ? personLabel(current) : userId() })); + setFlash(current ? t("insights.recomputeQueued", { student: personLabel(current) }) : t("insights.recomputeQueuedUnnamed")); } catch (error) { setActionError(formatApiError(error)); } finally { @@ -86,9 +100,9 @@ function AiInsightStudentContent() { }; return ( -
+
- +
{flash()} @@ -96,7 +110,15 @@ function AiInsightStudentContent() { {actionError()} - + + {(error) => ( + void refetchRoster()} + /> + )} + + {t("insights.notFound")} @@ -115,7 +137,7 @@ function AiInsightStudentContent() {

{t("insights.title")}

-

{studentName()}

+

{studentName() ?? t("insights.studentAnalysis")}

{t("insights.noSummary")}} @@ -131,7 +153,9 @@ function AiInsightStudentContent() { )}
-

{t("insights.studentAnalysis")}

+ +

{t("insights.studentAnalysis")}

+