feat(clinic): enhance doctor data handling with improved pagination and default values

This commit is contained in:
hamed
2026-06-18 19:16:52 +03:30
parent fdb5866562
commit 4dca516598
4 changed files with 15 additions and 6 deletions
+8 -2
View File
@@ -17,10 +17,16 @@ export async function getClinicDoctors(slug, params = {}) {
const json = await response.json();
// پاسخ دو لایه nested است: آرایه‌ی پزشکان در json.data.data و صفحه‌بندی در json.data.meta
const doctors = json?.data?.data || [];
const meta = json?.data?.meta;
// ✅ خروجی همیشه ساختار ثابت دارد
return {
data: json?.data || [],
page: json?.page || json?.pages || { total_pages: 1, current: 1 },
data: doctors,
page: meta
? { total_pages: meta.totalPages, current: meta.currentPage }
: { total_pages: 1, current: 1 },
};
} catch (error) {
console.error("❌ خطا در دریافت دکترهای کلینیک:", error);