loading added

This commit is contained in:
Arezoo
2025-10-25 19:26:25 +03:30
parent 3c2b44a65f
commit 7c320d3c22
2 changed files with 15 additions and 8 deletions
+14 -7
View File
@@ -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>
+1 -1
View File
@@ -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} />