From aeef59fe0d02ed78b1d0e31c18da4e512a1a7e5f Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Fri, 19 Jun 2026 13:27:11 +0330 Subject: [PATCH] feat(doctors-page): enhance doctor data mapping for representation role and improve rate handling --- assets/admin/pages/DoctorsPage.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/assets/admin/pages/DoctorsPage.tsx b/assets/admin/pages/DoctorsPage.tsx index e9862b3d..e4276a22 100644 --- a/assets/admin/pages/DoctorsPage.tsx +++ b/assets/admin/pages/DoctorsPage.tsx @@ -141,7 +141,26 @@ export default function DoctorsPage() { const stats: DoctorStats | undefined = useMemo( () => (statsQ.data?.data as any)?.data ?? statsQ.data?.data, [statsQ.data] ); - const items: AdminDoctor[] = doctorsQ.data?.data ?? []; + // endpoint عمومی /doctors شکل متفاوتی دارد؛ به شکل AdminDoctor نگاشت می‌شود تا جدول کرش نکند. + const rawItems = doctorsQ.data?.data ?? []; + const items: AdminDoctor[] = isRepresentation + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ? (rawItems as any[]).map((d) => ({ + uuid: d.uuid, + id: d.id, + name: d.name, + gender: d.gender ?? null, + degree: d.degree ?? null, + medical_code: d.medical_code ?? null, + mobile: d.mobile ?? null, + email: d.email ?? null, + is_active: d.is_active ?? d.active ?? false, + rate: Number(d.rate ?? d.point ?? 0) || 0, + specialties: d.specialties ?? [], + profile_image: d.profile_image ?? d.img?.[0]?.url ?? null, + created_at: d.created_at ?? null, + }) as AdminDoctor) + : (rawItems as AdminDoctor[]); const total = doctorsQ.data?.meta?.totalRecords ?? 0; const specialties: SpecialtyOption[] = useMemo( () => (specialtiesQ.data?.data as any)?.data ?? specialtiesQ.data?.data ?? [], @@ -325,7 +344,7 @@ export default function DoctorsPage() { )} - {doc.rate.toFixed(1)} + {(doc.rate ?? 0).toFixed(1)} {doc.mobile ?? '—'} @@ -401,7 +420,7 @@ export default function DoctorsPage() {
- {doc.rate.toFixed(1)} + {(doc.rate ?? 0).toFixed(1)} {formatDate(doc.created_at)}