loading added
This commit is contained in:
@@ -2,7 +2,6 @@ import ItemDoctor from "@/app/component/ItemDoctor";
|
|||||||
import Pagination from "@/app/component/Pagination";
|
import Pagination from "@/app/component/Pagination";
|
||||||
import { QueryForDoctorsClinicReq } from "@/helper";
|
import { QueryForDoctorsClinicReq } from "@/helper";
|
||||||
import { getClinicDoctors } from "@/services/clinicApi";
|
import { getClinicDoctors } from "@/services/clinicApi";
|
||||||
import { request } from "@/services/response";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
@@ -32,15 +31,23 @@ function List({
|
|||||||
current: num,
|
current: num,
|
||||||
limit,
|
limit,
|
||||||
};
|
};
|
||||||
const doctors = await getClinicDoctors(slug, params);
|
try {
|
||||||
setDoctors(doctors.data);
|
const doctors = await getClinicDoctors(slug, params);
|
||||||
setTotalPage(doctors?.page?.total_pages || 1);
|
setDoctors(doctors.data);
|
||||||
setPage(num);
|
setTotalPage(doctors?.page?.total_pages || 1);
|
||||||
|
setPage(num);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const doctorList = Array.isArray(doctors?.data) ? doctors.data : doctors;
|
const doctorList = Array.isArray(doctors?.data) ? doctors.data : doctors;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{doctorList?.length === 0 ? (
|
{loading ? (
|
||||||
|
<div className="flex justify-center items-center py-20">
|
||||||
|
<div className="w-10 h-10 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"></div>
|
||||||
|
</div>
|
||||||
|
) : doctorList?.length === 0 ? (
|
||||||
<div className="text-center text-gray-500 mt-10">
|
<div className="text-center text-gray-500 mt-10">
|
||||||
دکتری مطابق فیلتر شما یافت نشد
|
دکتری مطابق فیلتر شما یافت نشد
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function Fields({ city, state }) {
|
|||||||
data={specialtiesData}
|
data={specialtiesData}
|
||||||
inputValue={data.search}
|
inputValue={data.search}
|
||||||
handleSearch={(e) => setData({ data, search: e })}
|
handleSearch={(e) => setData({ data, search: e })}
|
||||||
placeholder="جستجوی نام پزشک، تخصص، بیماری ..."
|
placeholder="جستجوی نام پزشک، تخصص "
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<RedirectLink data={data} />
|
<RedirectLink data={data} />
|
||||||
|
|||||||
Reference in New Issue
Block a user