loading added
This commit is contained in:
@@ -2,7 +2,6 @@ import ItemDoctor from "@/app/component/ItemDoctor";
|
||||
import Pagination from "@/app/component/Pagination";
|
||||
import { QueryForDoctorsClinicReq } from "@/helper";
|
||||
import { getClinicDoctors } from "@/services/clinicApi";
|
||||
import { request } from "@/services/response";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -32,15 +31,23 @@ function List({
|
||||
current: num,
|
||||
limit,
|
||||
};
|
||||
const doctors = await getClinicDoctors(slug, params);
|
||||
setDoctors(doctors.data);
|
||||
setTotalPage(doctors?.page?.total_pages || 1);
|
||||
setPage(num);
|
||||
try {
|
||||
const doctors = await getClinicDoctors(slug, params);
|
||||
setDoctors(doctors.data);
|
||||
setTotalPage(doctors?.page?.total_pages || 1);
|
||||
setPage(num);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
const doctorList = Array.isArray(doctors?.data) ? doctors.data : doctors;
|
||||
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>
|
||||
|
||||
@@ -34,7 +34,7 @@ function Fields({ city, state }) {
|
||||
data={specialtiesData}
|
||||
inputValue={data.search}
|
||||
handleSearch={(e) => setData({ data, search: e })}
|
||||
placeholder="جستجوی نام پزشک، تخصص، بیماری ..."
|
||||
placeholder="جستجوی نام پزشک، تخصص "
|
||||
/>
|
||||
</div>
|
||||
<RedirectLink data={data} />
|
||||
|
||||
Reference in New Issue
Block a user