diff --git a/assets/admin/pages/UserDetailPage.tsx b/assets/admin/pages/UserDetailPage.tsx index 1ec8f911..407d1071 100644 --- a/assets/admin/pages/UserDetailPage.tsx +++ b/assets/admin/pages/UserDetailPage.tsx @@ -32,6 +32,35 @@ interface AdminUserDetail { updated_at: string; } +interface UserProfileData { + uuid: string; + national_code: string | null; + gender: string | null; + date_of_birth: number | null; + blood_type: string | null; + marital_status: string | null; + education: string | null; + job: string | null; + fathers_name: string | null; + address: string | null; + home_phone: string | null; + work_phone: string | null; + basic_insurance_id: number | null; + supplementary_insurance_id: number | null; + other: Record | null; +} + +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: 'بیماری‌ها' }, +]; + // ── Helpers ─────────────────────────────────────────────────────────────── const ROLE_META: Record = { @@ -192,6 +221,15 @@ export default function UserDetailPage() { const user: AdminUserDetail | undefined = (data?.data as any)?.data ?? data?.data; + const profileQ = useQuery({ + queryKey: ['admin-user-profile', uuid], + queryFn: () => api.get>(`/api/v1/user-profile/${uuid}`), + enabled: !!uuid, + retry: false, + }); + const profile: UserProfileData | undefined = + (profileQ.data as any)?.data?.data ?? (profileQ.data as any)?.data; + // ── Edit form ── const { register, handleSubmit, reset, formState: { errors } } = useForm({ @@ -476,6 +514,65 @@ export default function UserDetailPage() { + {/* ── User Profile (read-only) ──────────────────────────── */} +
+

پروفایل کاربر

+ + {profileQ.isLoading ? ( +
+ {Array.from({ length: 6 }).map((_, i) =>
)} +
+ ) : !profile ? ( +

+ این کاربر هنوز پروفایلی تکمیل نکرده است. +

+ ) : ( + <> +
+ + + + + + + + + + + + + +
+ + {/* Medical history */} +
+

سوابق پزشکی

+
+ {MEDICAL_SECTIONS.map(({ key, label }) => { + const items = Array.isArray(profile.other?.[key]) ? (profile.other![key] as unknown[]) : []; + return ( +
+

{label}

+ {items.length === 0 ? ( +

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

+ ) : ( +
    + {items.map((it, i) => ( +
  • + {typeof it === 'string' ? it : (it as any)?.name ?? (it as any)?.title ?? JSON.stringify(it)} +
  • + ))} +
+ )} +
+ ); + })} +
+
+ + )} +
+ {/* ── Edit Modal ────────────────────────────────────────── */}