feat(clinic): enhance doctor data handling with improved pagination and default values
This commit is contained in:
@@ -48,7 +48,10 @@ async function Clinic({ params, searchParams }) {
|
||||
|
||||
const clinic = reqClinics?.data?.data || null;
|
||||
const doctors = reqDoctors?.data?.data || [];
|
||||
const pagedoctors = reqDoctors?.data?.meta;
|
||||
const meta = reqDoctors?.data?.meta;
|
||||
const pagedoctors = meta
|
||||
? { current: meta.currentPage, total_pages: meta.totalPages }
|
||||
: { current: 1, total_pages: 1 };
|
||||
|
||||
const jsonLd = clinic
|
||||
? {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { FormControlLabel, Radio, RadioGroup } from "@mui/material";
|
||||
function Radios({ group, value, updateData, name }) {
|
||||
return (
|
||||
<RadioGroup
|
||||
value={value}
|
||||
value={value ?? ""}
|
||||
className="radio-mui"
|
||||
onChange={(e) => updateData(name, e.target.value)}
|
||||
sx={{
|
||||
|
||||
@@ -32,7 +32,7 @@ function Form({ filter, changeSpecialty, updateData }) {
|
||||
<div className="mt-[40px] mb-[32px]">
|
||||
<RadioContent
|
||||
updateData={updateData}
|
||||
value={filter.gender}
|
||||
value={filter.gender ?? "هر دو"}
|
||||
text="جنسیت پزشک"
|
||||
group={gender}
|
||||
name="gender"
|
||||
@@ -40,7 +40,7 @@ function Form({ filter, changeSpecialty, updateData }) {
|
||||
<span className="block mt-[16px] mb-[24px] w-full h-px bg-[#EFEFEF]"></span>
|
||||
<RadioContent
|
||||
updateData={updateData}
|
||||
value={filter.degree}
|
||||
value={filter.degree ?? "همه موارد"}
|
||||
text="درجه علمی"
|
||||
group={degree}
|
||||
name="degree"
|
||||
|
||||
@@ -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