feat(clinic): enhance doctor data handling with improved pagination and default values
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user