From a348dcae5fea2a57b0323e5e3baa542daada2716 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Mon, 15 Jun 2026 22:27:42 +0330 Subject: [PATCH] fix(admin): render medical history with each section's real shape The medical sections in other are structured objects, not flat strings: allergies {substance,reaction,severity}, medications {name,dose,frequency}, surgeries {type,year,hospital}, family_history {relation,disease}, disease {id,name,status}. The admin view printed raw JSON for all but disease. Give each section a formatter, and for disease show only entries marked active (status true) instead of the full 30-item checklist. Co-Authored-By: Claude Opus 4.8 --- assets/admin/pages/UserDetailPage.tsx | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/assets/admin/pages/UserDetailPage.tsx b/assets/admin/pages/UserDetailPage.tsx index 407d1071..c0843832 100644 --- a/assets/admin/pages/UserDetailPage.tsx +++ b/assets/admin/pages/UserDetailPage.tsx @@ -53,12 +53,19 @@ interface UserProfileData { const GENDER_LABELS: Record = { male: 'مرد', female: 'زن' }; const MARITAL_LABELS: Record = { married: 'متاهل', single: 'مجرد' }; -const MEDICAL_SECTIONS: { key: string; label: string }[] = [ - { key: 'allergies', label: 'آلرژی‌ها' }, - { key: 'medications', label: 'داروهای مصرفی' }, - { key: 'surgeries', label: 'جراحی‌ها' }, - { key: 'family_history', label: 'سابقه خانوادگی بیماری' }, - { key: 'disease', label: 'بیماری‌ها' }, +// Each medical section stores objects with its own shape; format an item to a label. +const MEDICAL_SECTIONS: { + key: string; + label: string; + format: (item: any) => string; + filter?: (item: any) => boolean; +}[] = [ + { key: 'allergies', label: 'آلرژی‌ها', format: (i) => [i.substance, i.reaction, i.severity].filter(Boolean).join(' — ') }, + { key: 'medications', label: 'داروهای مصرفی', format: (i) => [i.name, i.dose, i.frequency].filter(Boolean).join(' — ') }, + { key: 'surgeries', label: 'جراحی‌ها', format: (i) => [i.type, i.year && `سال ${i.year}`, i.hospital].filter(Boolean).join(' — ') }, + { key: 'family_history', label: 'سابقه خانوادگی بیماری', format: (i) => [i.relation, i.disease].filter(Boolean).join(': ') }, + // disease is a fixed checklist; only show the ones marked active + { key: 'disease', label: 'بیماری‌ها', format: (i) => i.name, filter: (i) => i.status === 'true' || i.status === true }, ]; // ── Helpers ─────────────────────────────────────────────────────────────── @@ -548,8 +555,11 @@ export default function UserDetailPage() {

سوابق پزشکی

- {MEDICAL_SECTIONS.map(({ key, label }) => { - const items = Array.isArray(profile.other?.[key]) ? (profile.other![key] as unknown[]) : []; + {MEDICAL_SECTIONS.map(({ key, label, format, filter }) => { + const raw = Array.isArray(profile.other?.[key]) ? (profile.other![key] as any[]) : []; + const items = (filter ? raw.filter(filter) : raw) + .map(format) + .filter((s) => s && s.trim()); return (

{label}

@@ -557,9 +567,9 @@ export default function UserDetailPage() {

موردی ثبت نشده

) : (
    - {items.map((it, i) => ( + {items.map((text, i) => (
  • - {typeof it === 'string' ? it : (it as any)?.name ?? (it as any)?.title ?? JSON.stringify(it)} + {text}
  • ))}