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}
  • ))}