From 50dd157cbe7fdcc0f18059a12c898d3738461f36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?=
<80620802+burakboduroglu@users.noreply.github.com>
Date: Wed, 23 Sep 2026 16:49:08 +0300
Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=AA=AA=20show=20available=20studen?=
=?UTF-8?q?t=20and=20parent=20record=20details?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- show all permitted personal fields and preserve long values in the info panel
- cover student and linked-parent views with component tests
- clarify the panel description in Turkish and English
---
src/components/ui/detail-field.tsx | 4 +-
.../users/student-info-panel.test.tsx | 94 +++++++++++++++++++
src/components/users/student-info-panel.tsx | 79 +++++++++-------
src/i18n/locales/en.ts | 2 +-
src/i18n/locales/tr.ts | 2 +-
src/pages/profile-page.tsx | 2 +-
src/pages/students-roster-page.tsx | 2 +-
7 files changed, 144 insertions(+), 41 deletions(-)
create mode 100644 src/components/users/student-info-panel.test.tsx
diff --git a/src/components/ui/detail-field.tsx b/src/components/ui/detail-field.tsx
index ebfda5a..2704b28 100644
--- a/src/components/ui/detail-field.tsx
+++ b/src/components/ui/detail-field.tsx
@@ -1,10 +1,10 @@
import { cn } from "@/lib/cn";
-export function DetailField(props: { label: string; value: string; mono?: boolean }) {
+export function DetailField(props: { label: string; value: string; mono?: boolean; wrap?: boolean }) {
return (
{props.label}
-
{props.value}
+
{props.value}
);
}
diff --git a/src/components/users/student-info-panel.test.tsx b/src/components/users/student-info-panel.test.tsx
new file mode 100644
index 0000000..9229862
--- /dev/null
+++ b/src/components/users/student-info-panel.test.tsx
@@ -0,0 +1,94 @@
+import { render, screen } from "@solidjs/testing-library";
+import type { User } from "@/api/client";
+import { StudentInfoPanel } from "@/components/users/student-info-panel";
+import { PreferencesProvider } from "@/stores/preferences-context";
+
+let currentUser: User;
+const getMyStudents = vi.fn();
+const getUserById = vi.fn();
+
+vi.mock("@/stores/auth-context", () => ({
+ useAuth: () => ({ user: () => currentUser }),
+}));
+vi.mock("@/api/parents", () => ({ getMyStudents: (...args: unknown[]) => getMyStudents(...args) }));
+vi.mock("@/api/users", () => ({
+ getUserById: (...args: unknown[]) => getUserById(...args),
+ getUserSearch: vi.fn(),
+}));
+vi.mock("@/components/ui/side-panel", () => ({
+ SidePanel: (props: { children: unknown }) => {props.children as never}
,
+}));
+
+const student: User = {
+ id: "student-1",
+ username: "ada",
+ role: "student",
+ name: "Ada",
+ surname: "Yılmaz",
+ display_name: "Ada Yılmaz",
+ email: "ada@example.com",
+ phone: "+90 555 123 45 67",
+ birth_date: "2013-01-02",
+ gender: "female",
+ address: "Çamlık Mahallesi, İzmir",
+ emergency_contact_name: "Ayşe Yılmaz",
+ emergency_contact_phone: "+90 555 222 33 44",
+ bio: "Satranç kulübü",
+ student_number: "1234",
+ theme: null,
+ language: null,
+ palette_color: null,
+};
+
+function renderPanel(source: "self" | "parent") {
+ return render(() => (
+
+ {}}
+ source={source}
+ student={{ id: student.id, username: student.username, displayName: student.display_name }}
+ />
+
+ ));
+}
+
+afterEach(() => {
+ getMyStudents.mockReset();
+ getUserById.mockReset();
+});
+
+describe("StudentInfoPanel record details", () => {
+ it("shows the complete available student record, including dates and gender", async () => {
+ currentUser = student;
+ renderPanel("self");
+
+ expect(await screen.findByText("Çamlık Mahallesi, İzmir")).toBeTruthy();
+ for (const value of ["Ada", "Yılmaz", "January 2, 2013", "Female", "ada@example.com", "Ayşe Yılmaz", "1234"]) {
+ expect(screen.getByText(value)).toBeTruthy();
+ }
+ expect(getUserById).not.toHaveBeenCalled();
+ });
+
+ it("shows the linked parent's own record without inventing private student details", async () => {
+ currentUser = {
+ ...student,
+ id: "parent-1",
+ username: "ayse",
+ role: "parent",
+ name: "Ayşe",
+ surname: "Yılmaz",
+ birth_date: "1985-05-06",
+ address: "Veli adresi",
+ student_number: null,
+ };
+ getMyStudents.mockResolvedValue({ items: [{ id: student.id, username: student.username, student_number: "1234" }] });
+ renderPanel("parent");
+
+ expect(await screen.findByText("Veli adresi")).toBeTruthy();
+ expect(screen.getByText("1234")).toBeTruthy();
+ expect(screen.getByText("May 6, 1985")).toBeTruthy();
+ expect(screen.queryByText("January 2, 2013")).toBeNull();
+ expect(getUserById).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/components/users/student-info-panel.tsx b/src/components/users/student-info-panel.tsx
index 74ad76c..fc0d13d 100644
--- a/src/components/users/student-info-panel.tsx
+++ b/src/components/users/student-info-panel.tsx
@@ -8,6 +8,7 @@ import { EmptyInline } from "@/components/ui/empty-inline";
import { ErrorAlert } from "@/components/ui/error-alert";
import { PageSpinner } from "@/components/ui/page-spinner";
import { SidePanel } from "@/components/ui/side-panel";
+import { genderLabel } from "@/lib/gender";
import type { StudentInfoSource } from "@/lib/student-info-access";
import { useAuth } from "@/stores/auth-context";
import { usePreferences, useT } from "@/stores/preferences-context";
@@ -17,7 +18,7 @@ type Section = { title: string; hint?: string; fields: Field[] };
/** What each source can actually read; fields no endpoint fills stay out. */
type Loaded = {
- student: Partial> | null;
+ student: Partial | null;
guardian: User | null;
};
@@ -25,17 +26,15 @@ const forbidden = (err: unknown) => err instanceof ApiError && err.status === 40
/**
* Record details about a student — and, for a linked parent, about the parent —
- * that the public profile never carries (legal name, student number, contact,
- * birth date). Each viewer only reads what the backend already grants them; see
+ * that the public profile never carries. Each viewer only reads what the backend
+ * already grants them; see
* `studentInfoSource`.
*/
export function StudentInfoPanel(props: {
open: boolean;
onOpenChange: (open: boolean) => void;
source: StudentInfoSource;
- /** `name` is what the profile heading already shows; a legal name equal to
- * it is not repeated here. */
- student: { id: string; username: string; name: string };
+ student: { id: string; username: string; displayName?: string | null };
}) {
const t = useT();
const prefs = usePreferences();
@@ -70,7 +69,7 @@ export function StudentInfoPanel(props: {
case "parent": {
let ref: PersonRef | undefined;
try {
- ref = (await getMyStudents({ limit: 100 })).items.find((p) => p.id === props.student.id);
+ ref = (await getMyStudents()).items.find((p) => p.id === props.student.id);
} catch (err) {
if (!forbidden(err)) throw err;
}
@@ -80,9 +79,6 @@ export function StudentInfoPanel(props: {
},
);
- const fullName = (u: { name?: string | null; surname?: string | null } | null) =>
- [u?.name, u?.surname].map((s) => s?.trim()).filter(Boolean).join(" ");
-
// birth_date is a calendar date ("1990-01-02"); read it as local midnight so
// no time zone shifts it a day.
const birthDate = (raw: string) => {
@@ -93,35 +89,48 @@ export function StudentInfoPanel(props: {
);
};
- const present = (fields: { label: string; value: string | null | undefined }[]): Field[] =>
- fields
- .map((f) => ({ label: f.label, value: f.value?.trim() ?? "" }))
- .filter((f) => f.value !== "");
+ const field = (label: string, value: string | null | undefined): Field => ({
+ label,
+ value: value?.trim() || "—",
+ });
+
+ const personalFields = (u: Partial): Field[] => [
+ field(t("admin.username"), u.username),
+ field(t("profile.name"), u.name),
+ field(t("profile.surname"), u.surname),
+ field(t("profile.displayName"), u.display_name),
+ field(t("profile.birthDate"), u.birth_date ? birthDate(u.birth_date) : null),
+ field(t("profile.gender"), genderLabel(u.gender ?? null, t)),
+ field(t("profile.email"), u.email),
+ field(t("profile.phone"), u.phone),
+ field(t("profile.address"), u.address),
+ field(t("profile.emergencyContactName"), u.emergency_contact_name),
+ field(t("profile.emergencyContactPhone"), u.emergency_contact_phone),
+ field(t("profile.bio"), u.bio),
+ ];
const sections = (d: Loaded): Section[] => {
const out: Section[] = [];
const s = d.student;
- if (s) {
- const fields = present([
- { label: t("profile.fullName"), value: fullName(s) === props.student.name ? null : fullName(s) },
- { label: t("roster.studentNumber"), value: s.student_number },
- { label: t("profile.birthDate"), value: s.birth_date ? birthDate(s.birth_date) : null },
- { label: t("profile.email"), value: s.email },
- { label: t("profile.phone"), value: s.phone },
- ]);
- if (fields.length) out.push({ title: t("profile.studentInfoStudent"), fields });
- }
+ if (s) out.push({
+ title: t("profile.studentInfoStudent"),
+ fields: props.source === "self" || props.source === "admin"
+ ? [
+ ...personalFields(s),
+ field(t("roster.studentNumber"), s.student_number),
+ ]
+ : [
+ field(t("profile.displayName"), props.student.displayName),
+ field(t("admin.username"), props.student.username),
+ field(t("roster.studentNumber"), s.student_number),
+ ],
+ });
const g = d.guardian;
- if (g) {
- const fields = present([
- { label: t("profile.fullName"), value: fullName(g) || g.display_name },
- { label: t("profile.email"), value: g.email },
- { label: t("profile.phone"), value: g.phone },
- ]);
- if (fields.length) {
- out.push({ title: t("profile.studentInfoGuardian"), hint: t("profile.studentInfoGuardianHint"), fields });
- }
- }
+ if (g) out.push({
+ title: t("profile.studentInfoGuardian"),
+ hint: t("profile.studentInfoGuardianHint"),
+ fields: personalFields(g),
+ });
return out;
};
@@ -160,7 +169,7 @@ export function StudentInfoPanel(props: {
- {(f) => }
+ {(f) => }
diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts
index a7b2e40..95ab650 100644
--- a/src/i18n/locales/en.ts
+++ b/src/i18n/locales/en.ts
@@ -1955,7 +1955,7 @@ export const en: Dict = {
"profile.birthDate": "Birth date",
"profile.fullName": "Full name",
"profile.studentInfo": "Student info",
- "profile.studentInfoHint": "Record details the profile does not show.",
+ "profile.studentInfoHint": "Student and parent record details available to you.",
"profile.studentInfoStudent": "Student",
"profile.studentInfoGuardian": "Parent",
"profile.studentInfoGuardianHint": "Your details as the school has them.",
diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts
index 3b8a39b..c3f911b 100644
--- a/src/i18n/locales/tr.ts
+++ b/src/i18n/locales/tr.ts
@@ -1951,7 +1951,7 @@ export const tr: Dict = {
"profile.birthDate": "Doğum tarihi",
"profile.fullName": "Ad soyad",
"profile.studentInfo": "Öğrenci bilgileri",
- "profile.studentInfoHint": "Profilde yer almayan kayıt bilgileri.",
+ "profile.studentInfoHint": "Erişebildiğiniz öğrenci ve veli kayıt bilgileri.",
"profile.studentInfoStudent": "Öğrenci",
"profile.studentInfoGuardian": "Veli",
"profile.studentInfoGuardianHint": "Okulun kayıtlarındaki sizin bilgileriniz.",
diff --git a/src/pages/profile-page.tsx b/src/pages/profile-page.tsx
index 9b73fcc..c435f51 100644
--- a/src/pages/profile-page.tsx
+++ b/src/pages/profile-page.tsx
@@ -260,7 +260,7 @@ function ProfileContent() {
open={infoOpen()}
onOpenChange={setInfoOpen}
source={source()}
- student={{ id: p().id, username: p().username, name: name(p()) }}
+ student={{ id: p().id, username: p().username, displayName: p().display_name }}
/>
)}
diff --git a/src/pages/students-roster-page.tsx b/src/pages/students-roster-page.tsx
index 248189d..c238962 100644
--- a/src/pages/students-roster-page.tsx
+++ b/src/pages/students-roster-page.tsx
@@ -188,7 +188,7 @@ function StudentsRosterContent() {
open
onOpenChange={(open) => { if (!open) setInfoTarget(null); }}
source={source()}
- student={{ id: person.id, username: person.username, name: person.display_name || person.username }}
+ student={{ id: person.id, username: person.username, displayName: person.display_name }}
/>
)}