forge
Explore
Log in

Don't you dare go Hollow

Extend profile with gender, address and emergency contact

Browse files at this commit

969013cc323c5c142b1bf9c69057c262afcd7460Ahmet Kaan GümüşParent: 4e99344
  • feat
    • extend profile with gender, address and emergency contact
Show full message
feat: extend profile with gender, address and emergency contact

User and ProfileUpdate gain gender/address/emergency_contact_name/
emergency_contact_phone; the form gets a gender picker, address textarea
and emergency contact inputs with the same three-state PATCH merge
(absent=keep, ""=clear, value=set). Self profile page and the admin
user detail grid show the new fields; gender renders through i18n labels,
never the raw enum. limits.user gains max_address_len and genders.
src/api/client/types.tsmodified+16 -0
@@ -1,6 +1,7 @@
1 export type { Page, PageParams } from "./page";1 export type { Page, PageParams } from "./page";
2 2
3 export type Role = "student" | "parent" | "teacher" | "manager" | "admin";3 export type Role = "student" | "parent" | "teacher" | "manager" | "admin";
4+export type Gender = "female" | "male" | "other" | "undisclosed";
4 export type UserTheme = "light" | "dark";5 export type UserTheme = "light" | "dark";
5 export type UserLanguage = "tr" | "en";6 export type UserLanguage = "tr" | "en";
6 export type CourseKind = "course" | "study" | "club" | string;7 export type CourseKind = "course" | "study" | "club" | string;
@@ -21,6 +22,11 @@ export type User = {
21 email: string | null;22 email: string | null;
22 phone: string | null;23 phone: string | null;
23 birth_date: string | null;24 birth_date: string | null;
25+ gender: Gender | null;
26+ // Trimmed; at most limits.user.max_address_len characters when set.
27+ address: string | null;
28+ emergency_contact_name: string | null;
29+ emergency_contact_phone: string | null;
24 display_name?: string | null;30 display_name?: string | null;
25 bio?: string | null;31 bio?: string | null;
26 theme: UserTheme | null;32 theme: UserTheme | null;
@@ -39,6 +45,12 @@ export type ProfileUpdate = {
39 email?: string | null;45 email?: string | null;
40 phone?: string | null;46 phone?: string | null;
41 birth_date?: string | null;47 birth_date?: string | null;
48+ // Omitted = keep, "" = clear, a value = set. `gender` must be one of the
49+ // limits.user.genders values; anything else is a 400.
50+ gender?: Gender | null;
51+ address?: string | null;
52+ emergency_contact_name?: string | null;
53+ emergency_contact_phone?: string | null;
42 display_name?: string | null;54 display_name?: string | null;
43 bio?: string | null;55 bio?: string | null;
44 // The teacher's branş, by name from settings.branches.56 // The teacher's branş, by name from settings.branches.
@@ -847,6 +859,10 @@ export type Limits = {
847 max_email_len: number;859 max_email_len: number;
848 min_phone_digits: number;860 min_phone_digits: number;
849 max_phone_digits: number;861 max_phone_digits: number;
862+ // Personal-data caps the profile form mirrors: address length and the
863+ // accepted gender vocabulary.
864+ max_address_len: number;
865+ genders: Gender[];
850 palette_color_len: number;866 palette_color_len: number;
851 palette_color_pattern: string;867 palette_color_pattern: string;
852 roles: Role[];868 roles: Role[];
src/components/users/admin-user-edit-panel.tsxmodified+1 -0
@@ -46,6 +46,7 @@ export function AdminUserEditPanel(props: {
46 branches={settings.latest?.branches}46 branches={settings.latest?.branches}
47 editStudentNumber47 editStudentNumber
48 maxStudentNumberLen={limits.latest?.user.max_student_number_len}48 maxStudentNumberLen={limits.latest?.user.max_student_number_len}
49+ maxAddressLen={limits.latest?.user.max_address_len}
49 onSave={(body) => patchUserProfile(user.id, body)}50 onSave={(body) => patchUserProfile(user.id, body)}
50 onSaved={() => void props.onSaved()}51 onSaved={() => void props.onSaved()}
51 />52 />
src/components/users/profile-form.test.tsxadded+114 -0
@@ -0,0 +1,114 @@
1+import { fireEvent, render, screen, waitFor } from "@solidjs/testing-library";
2+import type { ProfileUpdate, User } from "@/api/client";
3+import { ProfileForm } from "@/components/users/profile-form";
4+import { PreferencesProvider } from "@/stores/preferences-context";
5+
6+const baseUser: User = {
7+ id: "u1",
8+ username: "ada",
9+ role: "student",
10+ name: "Ada",
11+ surname: "Yılmaz",
12+ email: null,
13+ phone: null,
14+ birth_date: null,
15+ gender: null,
16+ address: null,
17+ emergency_contact_name: null,
18+ emergency_contact_phone: null,
19+ theme: null,
20+ language: null,
21+ palette_color: null,
22+};
23+
24+function renderForm(user: User, onSave: (body: ProfileUpdate) => Promise<User>) {
25+ return render(() => (
26+ <PreferencesProvider>
27+ <ProfileForm user={user} onSaved={() => {}} onSave={onSave} maxAddressLen={500} />
28+ </PreferencesProvider>
29+ ));
30+}
31+
32+function setField(label: string, value: string) {
33+ fireEvent.input(screen.getByLabelText(label), { target: { value } });
34+}
35+
36+describe("ProfileForm personal data fields", () => {
37+ it("sends gender, address and emergency contact on save", async () => {
38+ const onSave = vi.fn(async () => baseUser);
39+ renderForm(baseUser, onSave);
40+
41+ fireEvent.change(screen.getByLabelText("Gender"), { target: { value: "female" } });
42+ setField("Address", " Çamlık Mah. 4. Sokak No 12, Kadıköy ");
43+ setField("Emergency contact name", "Veli Yılmaz");
44+ setField("Emergency contact phone", "+90 532 000 00 00");
45+
46+ fireEvent.click(screen.getByRole("button", { name: "Save" }));
47+
48+ await waitFor(() =>
49+ expect(onSave).toHaveBeenCalledWith({
50+ gender: "female",
51+ address: "Çamlık Mah. 4. Sokak No 12, Kadıköy",
52+ emergency_contact_name: "Veli Yılmaz",
53+ emergency_contact_phone: "+90 532 000 00 00",
54+ }),
55+ );
56+ });
57+
58+ it("clears set fields: gender with null, text fields with empty string", async () => {
59+ const saved: User = {
60+ ...baseUser,
61+ gender: "other",
62+ address: "Eski adres",
63+ emergency_contact_name: "Veli Yılmaz",
64+ emergency_contact_phone: "+90 532 000 00 00",
65+ };
66+ const onSave = vi.fn(async () => saved);
67+ renderForm(saved, onSave);
68+
69+ fireEvent.change(screen.getByLabelText("Gender"), { target: { value: "" } });
70+ setField("Address", "");
71+ setField("Emergency contact name", "");
72+ setField("Emergency contact phone", "");
73+
74+ fireEvent.click(screen.getByRole("button", { name: "Save" }));
75+
76+ await waitFor(() =>
77+ expect(onSave).toHaveBeenCalledWith({
78+ gender: null,
79+ address: "",
80+ emergency_contact_name: "",
81+ emergency_contact_phone: "",
82+ }),
83+ );
84+ });
85+
86+ it("skips the PATCH entirely when nothing changed", async () => {
87+ const onSave = vi.fn(async () => baseUser);
88+ renderForm(baseUser, onSave);
89+
90+ fireEvent.click(screen.getByRole("button", { name: "Save" }));
91+
92+ expect(onSave).not.toHaveBeenCalled();
93+ });
94+
95+ it("refuses an emergency phone that fails the phone pattern", async () => {
96+ const onSave = vi.fn(async () => baseUser);
97+ renderForm(baseUser, onSave);
98+
99+ setField("Emergency contact phone", "not-a-phone");
100+ fireEvent.click(screen.getByRole("button", { name: "Save" }));
101+
102+ expect(await screen.findByText(/valid phone number/i)).toBeTruthy();
103+ expect(onSave).not.toHaveBeenCalled();
104+ });
105+
106+ it("renders gender through the localized label, never the raw enum", () => {
107+ renderForm({ ...baseUser, gender: "undisclosed" }, async () => baseUser);
108+ const select = screen.getByLabelText("Gender") as HTMLSelectElement;
109+ expect(select.value).toBe("undisclosed");
110+ const labels = Array.from(select.options).map((o) => o.textContent);
111+ expect(labels).toContain("Prefer not to say");
112+ expect(labels).not.toContain("undisclosed");
113+ });
114+});
src/components/users/profile-form.tsxmodified+52 -1
@@ -1,6 +1,6 @@
1 import { For, Show, createSignal } from "solid-js";1 import { For, Show, createSignal } from "solid-js";
2 import { patchMe } from "@/api/users";2 import { patchMe } from "@/api/users";
3-import type { ProfileUpdate, User } from "@/api/client";3+import type { Gender, ProfileUpdate, User } from "@/api/client";
4 import { formatApiError } from "@/api/client";4 import { formatApiError } from "@/api/client";
5 import { Alert } from "@/components/ui/alert";5 import { Alert } from "@/components/ui/alert";
6 import { Button } from "@/components/ui/button";6 import { Button } from "@/components/ui/button";
@@ -10,12 +10,15 @@ import { Label } from "@/components/ui/label";
10 import { Select } from "@/components/ui/select";10 import { Select } from "@/components/ui/select";
11 import { Textarea } from "@/components/ui/textarea";11 import { Textarea } from "@/components/ui/textarea";
12 import { createFlash } from "@/lib/flash";12 import { createFlash } from "@/lib/flash";
13+import { GENDER_LABEL_KEYS } from "@/lib/gender";
13 import { hasMinRole } from "@/lib/roles";14 import { hasMinRole } from "@/lib/roles";
14 import { useT } from "@/stores/preferences-context";15 import { useT } from "@/stores/preferences-context";
15 16
16 const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;17 const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
17 const PHONE_RE = /^\+?[\d\s().-]{7,20}$/;18 const PHONE_RE = /^\+?[\d\s().-]{7,20}$/;
18 const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;19 const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
20+// The closed gender vocabulary the backend accepts (limits.user.genders).
21+const GENDERS: Gender[] = ["female", "male", "other", "undisclosed"];
19 22
20 function isFutureDate(iso: string) {23 function isFutureDate(iso: string) {
21 const d = new Date(`${iso}T00:00:00Z`);24 const d = new Date(`${iso}T00:00:00Z`);
@@ -54,6 +57,8 @@ export function ProfileForm(props: {
54 branches?: string[];57 branches?: string[];
55 maxDisplayNameLen?: number;58 maxDisplayNameLen?: number;
56 maxBioLen?: number;59 maxBioLen?: number;
60+ /** Cap for the address field, from limits.user.max_address_len. */
61+ maxAddressLen?: number;
57 /**62 /**
58 * Offer the school-issued student number. It is the office's field, not the63 * Offer the school-issued student number. It is the office's field, not the
59 * account holder's, so only the admin surface passes this; it stays hidden64 * account holder's, so only the admin surface passes this; it stays hidden
@@ -71,6 +76,10 @@ export function ProfileForm(props: {
71 const [email, setEmail] = createSignal(props.user.email ?? "");76 const [email, setEmail] = createSignal(props.user.email ?? "");
72 const [phone, setPhone] = createSignal(props.user.phone ?? "");77 const [phone, setPhone] = createSignal(props.user.phone ?? "");
73 const [birthDate, setBirthDate] = createSignal(dateInputFromIso(props.user.birth_date));78 const [birthDate, setBirthDate] = createSignal(dateInputFromIso(props.user.birth_date));
79+ const [gender, setGender] = createSignal(props.user.gender ?? "");
80+ const [address, setAddress] = createSignal(props.user.address ?? "");
81+ const [emergencyName, setEmergencyName] = createSignal(props.user.emergency_contact_name ?? "");
82+ const [emergencyPhone, setEmergencyPhone] = createSignal(props.user.emergency_contact_phone ?? "");
74 const [displayName, setDisplayName] = createSignal(props.profile?.display_name ?? "");83 const [displayName, setDisplayName] = createSignal(props.profile?.display_name ?? "");
75 const [bio, setBio] = createSignal(props.profile?.bio ?? "");84 const [bio, setBio] = createSignal(props.profile?.bio ?? "");
76 const [branch, setBranch] = createSignal(props.profile?.branch ?? "");85 const [branch, setBranch] = createSignal(props.profile?.branch ?? "");
@@ -92,8 +101,10 @@ export function ProfileForm(props: {
92 const e = email().trim();101 const e = email().trim();
93 const p = phone().trim();102 const p = phone().trim();
94 const b = isoFromDateInput(birthDate());103 const b = isoFromDateInput(birthDate());
104+ const ep = emergencyPhone().trim();
95 if (e && !EMAIL_RE.test(e)) return t("profile.emailInvalid");105 if (e && !EMAIL_RE.test(e)) return t("profile.emailInvalid");
96 if (p && !PHONE_RE.test(p)) return t("profile.phoneInvalid");106 if (p && !PHONE_RE.test(p)) return t("profile.phoneInvalid");
107+ if (ep && !PHONE_RE.test(ep)) return t("profile.phoneInvalid");
97 if (b && (!DATE_RE.test(b) || isFutureDate(b))) return t("profile.dateInvalid");108 if (b && (!DATE_RE.test(b) || isFutureDate(b))) return t("profile.dateInvalid");
98 return null;109 return null;
99 };110 };
@@ -110,6 +121,16 @@ export function ProfileForm(props: {
110 if (e !== (props.user.email ?? "")) b.email = e;121 if (e !== (props.user.email ?? "")) b.email = e;
111 if (p !== (props.user.phone ?? "")) b.phone = p;122 if (p !== (props.user.phone ?? "")) b.phone = p;
112 if (d !== (props.user.birth_date ?? "")) b.birth_date = d;123 if (d !== (props.user.birth_date ?? "")) b.birth_date = d;
124+ // Same omitted=keep / ""=clear / value=set merge the backend applies. An
125+ // empty gender select sends an explicit null (clear); a pick sends the enum.
126+ const g = gender();
127+ if (g !== (props.user.gender ?? "")) b.gender = g === "" ? null : (g as Gender);
128+ const a = address().trim();
129+ if (a !== (props.user.address ?? "")) b.address = a;
130+ const em = emergencyName().trim();
131+ if (em !== (props.user.emergency_contact_name ?? "")) b.emergency_contact_name = em;
132+ const ep = emergencyPhone().trim();
133+ if (ep !== (props.user.emergency_contact_phone ?? "")) b.emergency_contact_phone = ep;
113 // Blank clears it server-side, which is how the office un-numbers a student.134 // Blank clears it server-side, which is how the office un-numbers a student.
114 if (showStudentNumber() && studentNumber().trim() !== (props.user.student_number ?? "")) {135 if (showStudentNumber() && studentNumber().trim() !== (props.user.student_number ?? "")) {
115 b.student_number = studentNumber().trim();136 b.student_number = studentNumber().trim();
@@ -222,6 +243,36 @@ export function ProfileForm(props: {
222 <Label for="pf-birth">{t("profile.birthDate")}</Label>243 <Label for="pf-birth">{t("profile.birthDate")}</Label>
223 <DatePicker id="pf-birth" class="h-10" placeholder={t("form.datePlaceholder")} value={birthDate()} onChange={setBirthDate} />244 <DatePicker id="pf-birth" class="h-10" placeholder={t("form.datePlaceholder")} value={birthDate()} onChange={setBirthDate} />
224 </div>245 </div>
246+ <div class="space-y-1.5">
247+ <Label for="pf-gender">{t("profile.gender")}</Label>
248+ <Select id="pf-gender" class="h-10" value={gender()} onChange={(e) => setGender(e.currentTarget.value)}>
249+ <option value="">{t("profile.genderNone")}</option>
250+ <For each={GENDERS}>{(g) => <option value={g}>{t(GENDER_LABEL_KEYS[g])}</option>}</For>
251+ </Select>
252+ </div>
253+ <div class="space-y-1.5">
254+ <Label for="pf-address">{t("profile.address")}</Label>
255+ <Textarea
256+ id="pf-address"
257+ rows={2}
258+ maxlength={props.maxAddressLen}
259+ value={address()}
260+ onInput={(e) => setAddress(e.currentTarget.value)}
261+ />
262+ <Show when={props.maxAddressLen}>
263+ {(max) => <p class="text-xs text-muted-foreground">{address().length} / {max()}</p>}
264+ </Show>
265+ </div>
266+ <div class="grid gap-3 sm:grid-cols-2">
267+ <div class="space-y-1.5">
268+ <Label for="pf-emergency-name">{t("profile.emergencyContactName")}</Label>
269+ <Input id="pf-emergency-name" class="h-10" value={emergencyName()} onInput={(e) => setEmergencyName(e.currentTarget.value)} />
270+ </div>
271+ <div class="space-y-1.5">
272+ <Label for="pf-emergency-phone">{t("profile.emergencyContactPhone")}</Label>
273+ <Input id="pf-emergency-phone" class="h-10" type="tel" value={emergencyPhone()} onInput={(e) => setEmergencyPhone(e.currentTarget.value)} />
274+ </div>
275+ </div>
225 {error() && <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>}276 {error() && <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>}
226 <div class="!mt-auto sticky bottom-0 -mx-5 flex justify-end border-t border-border-hairline bg-surface-base px-5 pb-1 pt-4">277 <div class="!mt-auto sticky bottom-0 -mx-5 flex justify-end border-t border-border-hairline bg-surface-base px-5 pb-1 pt-4">
227 <Button type="submit" class="w-full sm:w-auto" disabled={pending()}>{t("common.save")}</Button>278 <Button type="submit" class="w-full sm:w-auto" disabled={pending()}>{t("common.save")}</Button>
src/i18n/locales/en.tsmodified+9 -0
@@ -1961,6 +1961,15 @@ export const en: Dict = {
1961 "profile.studentInfoGuardianHint": "Your details as the school has them.",1961 "profile.studentInfoGuardianHint": "Your details as the school has them.",
1962 "profile.studentInfoEmpty": "No further details to show",1962 "profile.studentInfoEmpty": "No further details to show",
1963 "profile.studentInfoEmptyHint": "The school may not have filled these in yet.",1963 "profile.studentInfoEmptyHint": "The school may not have filled these in yet.",
1964+ "profile.gender": "Gender",
1965+ "profile.genderNone": "Not set",
1966+ "profile.genderFemale": "Female",
1967+ "profile.genderMale": "Male",
1968+ "profile.genderOther": "Other",
1969+ "profile.genderUndisclosed": "Prefer not to say",
1970+ "profile.address": "Address",
1971+ "profile.emergencyContactName": "Emergency contact name",
1972+ "profile.emergencyContactPhone": "Emergency contact phone",
1964 "profile.edit": "Edit profile",1973 "profile.edit": "Edit profile",
1965 "profile.saved": "Profile saved",1974 "profile.saved": "Profile saved",
1966 "profile.emailInvalid": "Enter a valid email address (e.g. name@example.com)",1975 "profile.emailInvalid": "Enter a valid email address (e.g. name@example.com)",
src/i18n/locales/tr.tsmodified+9 -0
@@ -1957,6 +1957,15 @@ export const tr: Dict = {
1957 "profile.studentInfoGuardianHint": "Okulun kayıtlarındaki sizin bilgileriniz.",1957 "profile.studentInfoGuardianHint": "Okulun kayıtlarındaki sizin bilgileriniz.",
1958 "profile.studentInfoEmpty": "Gösterilecek ek bilgi yok",1958 "profile.studentInfoEmpty": "Gösterilecek ek bilgi yok",
1959 "profile.studentInfoEmptyHint": "Okul bu bilgileri henüz girmemiş olabilir.",1959 "profile.studentInfoEmptyHint": "Okul bu bilgileri henüz girmemiş olabilir.",
1960+ "profile.gender": "Cinsiyet",
1961+ "profile.genderNone": "Belirtilmedi",
1962+ "profile.genderFemale": "Kadın",
1963+ "profile.genderMale": "Erkek",
1964+ "profile.genderOther": "Diğer",
1965+ "profile.genderUndisclosed": "Belirtmek istemiyorum",
1966+ "profile.address": "Adres",
1967+ "profile.emergencyContactName": "Acil durum kişisi",
1968+ "profile.emergencyContactPhone": "Acil durum telefonu",
1960 "profile.edit": "Profili düzenle",1969 "profile.edit": "Profili düzenle",
1961 "profile.saved": "Profil kaydedildi",1970 "profile.saved": "Profil kaydedildi",
1962 "profile.emailInvalid": "Geçerli bir e-posta adresi girin (örn. ad@ornek.com)",1971 "profile.emailInvalid": "Geçerli bir e-posta adresi girin (örn. ad@ornek.com)",
src/i18n/messages.tsmodified+9 -0
@@ -1853,6 +1853,15 @@ export type MessageKey =
1853 | "profile.studentInfoGuardianHint"1853 | "profile.studentInfoGuardianHint"
1854 | "profile.studentInfoEmpty"1854 | "profile.studentInfoEmpty"
1855 | "profile.studentInfoEmptyHint"1855 | "profile.studentInfoEmptyHint"
1856+ | "profile.gender"
1857+ | "profile.genderNone"
1858+ | "profile.genderFemale"
1859+ | "profile.genderMale"
1860+ | "profile.genderOther"
1861+ | "profile.genderUndisclosed"
1862+ | "profile.address"
1863+ | "profile.emergencyContactName"
1864+ | "profile.emergencyContactPhone"
1856 | "profile.edit"1865 | "profile.edit"
1857 | "profile.saved"1866 | "profile.saved"
1858 | "profile.emailInvalid"1867 | "profile.emailInvalid"
src/lib/gender.tsadded+18 -0
@@ -0,0 +1,18 @@
1+import type { Gender } from "@/api/client";
2+import type { MessageKey } from "@/i18n/messages";
3+
4+// Backend gender enum → i18n key. The raw enum string never reaches the UI.
5+export const GENDER_LABEL_KEYS: Record<Gender, MessageKey> = {
6+ female: "profile.genderFemale",
7+ male: "profile.genderMale",
8+ other: "profile.genderOther",
9+ undisclosed: "profile.genderUndisclosed",
10+};
11+
12+type Translate = (key: MessageKey) => string;
13+
14+/** Gender → localized label; null renders the em-dash placeholder. Shared by
15+ * the profile page and the admin user detail grid. */
16+export function genderLabel(g: Gender | null, t: Translate): string {
17+ return g ? t(GENDER_LABEL_KEYS[g]) : "—";
18+}
src/pages/admin-user-detail-page.tsxmodified+5 -0
@@ -17,6 +17,7 @@ import { IconEdit, IconExternalLink, IconUsers } from "@/components/ui/icons";
17 import { PageSpinner } from "@/components/ui/page-spinner";17 import { PageSpinner } from "@/components/ui/page-spinner";
18 import { Select } from "@/components/ui/select";18 import { Select } from "@/components/ui/select";
19 import { ROLES, hasMinRole } from "@/lib/roles";19 import { ROLES, hasMinRole } from "@/lib/roles";
20+import { genderLabel } from "@/lib/gender";
20 import { useAuth } from "@/stores/auth-context";21 import { useAuth } from "@/stores/auth-context";
21 import { useT } from "@/stores/preferences-context";22 import { useT } from "@/stores/preferences-context";
22 23
@@ -104,6 +105,10 @@ function AdminUserDetailContent() {
104 <DetailField label={t("profile.email")} value={current().email || "—"} />105 <DetailField label={t("profile.email")} value={current().email || "—"} />
105 <DetailField label={t("profile.phone")} value={current().phone || "—"} />106 <DetailField label={t("profile.phone")} value={current().phone || "—"} />
106 <DetailField label={t("profile.birthDate")} value={current().birth_date || "—"} />107 <DetailField label={t("profile.birthDate")} value={current().birth_date || "—"} />
108+ <DetailField label={t("profile.gender")} value={genderLabel(current().gender, t)} />
109+ <DetailField label={t("profile.address")} value={current().address || "—"} />
110+ <DetailField label={t("profile.emergencyContactName")} value={current().emergency_contact_name || "—"} />
111+ <DetailField label={t("profile.emergencyContactPhone")} value={current().emergency_contact_phone || "—"} />
107 <Show when={current().role === "student"}>112 <Show when={current().role === "student"}>
108 <DetailField label={t("roster.studentNumber")} value={current().student_number || "—"} />113 <DetailField label={t("roster.studentNumber")} value={current().student_number || "—"} />
109 </Show>114 </Show>
src/pages/profile-page.tsxmodified+16 -0
@@ -10,6 +10,7 @@ import { RouteGuard } from "@/components/layout/route-guard";
10 import { RoleBadge } from "@/components/layout/role-badge";10 import { RoleBadge } from "@/components/layout/role-badge";
11 import { Badge } from "@/components/ui/badge";11 import { Badge } from "@/components/ui/badge";
12 import { Button } from "@/components/ui/button";12 import { Button } from "@/components/ui/button";
13+import { DetailField } from "@/components/ui/detail-field";
13 import { ErrorAlert } from "@/components/ui/error-alert";14 import { ErrorAlert } from "@/components/ui/error-alert";
14 import { IconEdit, IconSchool, IconUserCircle } from "@/components/ui/icons";15 import { IconEdit, IconSchool, IconUserCircle } from "@/components/ui/icons";
15 import { PageSpinner } from "@/components/ui/page-spinner";16 import { PageSpinner } from "@/components/ui/page-spinner";
@@ -21,6 +22,7 @@ import { ProfileForm } from "@/components/users/profile-form";
21 import { ProfileMemberships } from "@/components/users/profile-memberships";22 import { ProfileMemberships } from "@/components/users/profile-memberships";
22 import { StudentInfoPanel } from "@/components/users/student-info-panel";23 import { StudentInfoPanel } from "@/components/users/student-info-panel";
23 import { UserAvatar } from "@/components/users/user-avatar";24 import { UserAvatar } from "@/components/users/user-avatar";
25+import { genderLabel } from "@/lib/gender";
24 import { personLabel } from "@/lib/person";26 import { personLabel } from "@/lib/person";
25 import { studentInfoSource } from "@/lib/student-info-access";27 import { studentInfoSource } from "@/lib/student-info-access";
26 import { useAuth } from "@/stores/auth-context";28 import { useAuth } from "@/stores/auth-context";
@@ -218,6 +220,19 @@ function ProfileContent() {
218 </div>220 </div>
219 </section>221 </section>
220 222
223+ {/* Personal contact data lives on the User payload, not the
224+ public profile — rows render for the owner only. */}
225+ <Show when={isSelf(p()) && auth.user()}>
226+ {(u) => (
227+ <section class="data-shell grid gap-4 p-4 sm:grid-cols-2 lg:grid-cols-4">
228+ <DetailField label={t("profile.gender")} value={genderLabel(u().gender, t)} />
229+ <DetailField label={t("profile.address")} value={u().address || "—"} />
230+ <DetailField label={t("profile.emergencyContactName")} value={u().emergency_contact_name || "—"} />
231+ <DetailField label={t("profile.emergencyContactPhone")} value={u().emergency_contact_phone || "—"} />
232+ </section>
233+ )}
234+ </Show>
235+
221 <section class="grid gap-3 sm:grid-cols-3 lg:grid-cols-5">236 <section class="grid gap-3 sm:grid-cols-3 lg:grid-cols-5">
222 <For each={profileStats(p())}>237 <For each={profileStats(p())}>
223 {(stat) => <StatCard icon={stat.icon} label={stat.label} value={stat.value} />}238 {(stat) => <StatCard icon={stat.icon} label={stat.label} value={stat.value} />}
@@ -259,6 +274,7 @@ function ProfileContent() {
259 branches={settings.latest?.branches}274 branches={settings.latest?.branches}
260 maxDisplayNameLen={limits.latest?.user.max_display_name_len}275 maxDisplayNameLen={limits.latest?.user.max_display_name_len}
261 maxBioLen={limits.latest?.user.max_bio_len}276 maxBioLen={limits.latest?.user.max_bio_len}
277+ maxAddressLen={limits.latest?.user.max_address_len}
262 onSaved={() => {278 onSaved={() => {
263 setEditing(false);279 setEditing(false);
264 void auth.refresh();280 void auth.refresh();