import { useState } from "react"; import ItemDoctor from "@/app/component/ItemDoctor"; import PaginationContent from "@/app/component/PaginationContent"; import { QueryForDoctorsReq } from "@/helper"; import { request } from "@/services/response"; import { useRouter } from "next/navigation"; function ListDoctors({ data, page, limit, filter, doctors, setPage, setDoctors, }) { const [loading, setLoading] = useState(false); const router = useRouter(); const changePage =async (_, num) => { setLoading(true); // 👇 اسکرول به بالا با انیمیشن window.scrollTo({ top: 0, behavior: "smooth" }); // 👇 کمی تاخیر برای نمایش نرم‌تر await new Promise((res) => setTimeout(res, 300)); const searchParams = new URLSearchParams(window.location.search); searchParams.set("page", num); router.push(`?${searchParams.toString()}`); setPage(num); let params = { ...QueryForDoctorsReq(filter), page: num, limit, }; if ( data?.name === data.specialty?.name || data?.name === data.category?.name ) { params.name = ""; delete params.name; } request .getDoctors(params) .then((res) => { if (res.data) setDoctors(res.data); }) .catch((err) => {}) .finally(() => setLoading(false)); }; return ( <>
{doctors && doctors.length ? ( ) : (

دکتری برای نمایش وجود ندارد.

)}
); } export default ListDoctors;