diff --git a/app/clinic/[slug]/page.js b/app/clinic/[slug]/page.js
index 7eb7352..b7c485a 100644
--- a/app/clinic/[slug]/page.js
+++ b/app/clinic/[slug]/page.js
@@ -8,17 +8,19 @@ async function Clinic({ params: { slug } }) {
const reqClinics = await fetchReq(
`${API_URL}/api/v1/clinic/${slug}`
);
-
+const limit=50
const reqDoctors = await fetchReq(
- `${API_URL}/api/v1/clinic/doctor-list/${slug}`
+ `${API_URL}/api/v1/clinic/doctor-list/${slug}?page=1&limit=${limit}`
);
+
const clinic = reqClinics;
const doctors = reqDoctors?.data || [];
+ const pagedoctors=reqDoctors?.page
return (
-
+
);
}
diff --git a/app/component/Pagination.js b/app/component/Pagination.js
index d99dd39..fe06905 100644
--- a/app/component/Pagination.js
+++ b/app/component/Pagination.js
@@ -1,27 +1,30 @@
-import { Pagination as PaginationMUI } from "@mui/material";
+import { Pagination as PaginationMUI, useMediaQuery, useTheme } from "@mui/material";
+
+function Pagination({ page, totalPages, onPageChange}) {
+ const theme=useTheme()
+ const isSmall=useMediaQuery(theme.breakpoints.down("sm"))
+ const handleChange = (event, value) => {
+ onPageChange(event, value);
+ };
+ const count = totalPages||1
-function Pagination({ page, setPage, list, itemsPerPage }) {
- const handleChange = (_, value) => setPage(value);
- const count =
- list && itemsPerPage ? Math.ceil(list.length / itemsPerPage) : 20;
return (
{
+ setLoading(true);
+ const searchParams = new URLSearchParams(window.location.search);
+ searchParams.set("page", num);
+ router.push(`/clinic/${slug}?${searchParams.toString()}`);
+
+ setPage(num);
+
+ let params = {
+ ...QueryForDoctorsClinicReq(filter),
+ current: num,
+ limit,
+ };
+ const doctors = await getClinicDoctors(slug, params);
+ setDoctors(doctors);
+ };
+ const doctorList = Array.isArray(doctors?.data) ? doctors.data : doctors;
return (
<>
- {doctors?.map((doctor) => (
+ {doctorList?.map((doctor) => (
))}
>
);
diff --git a/components/clinic/components/doctors/head/index.js b/components/clinic/components/doctors/head/index.js
index 4ff9490..a7917ba 100644
--- a/components/clinic/components/doctors/head/index.js
+++ b/components/clinic/components/doctors/head/index.js
@@ -1,5 +1,5 @@
"use client ";
-import { useState } from "react";
+
import SearchBar from "./search";
import SortList from "./sortlist";
import { useRouter, useSearchParams } from "next/navigation";
@@ -8,9 +8,9 @@ import { QueryForClinicDoctorFilter, QueryForDoctorsClinicReq } from "@/helper";
import { getClinicDoctors } from "@/services/clinicApi";
-function Head({ setDoctors, slug, filter, setFilter }) {
+function Head({ setDoctors, slug, filter, setFilter,setPage,setTotalPage }) {
const searchParams = useSearchParams();
- const [page, setPage] = useState(1);
+
const router = useRouter();
const fieldName = searchParams.get("specialty");
@@ -63,8 +63,10 @@ function Head({ setDoctors, slug, filter, setFilter }) {
}
params.page = 1;
- params.limit = 12;
- setPage(1);
+ params.limit =50;
+ setTotalPage(data?.pages?.total_pages)
+
+ setPage(data?.pages?.current);
const doctors = await getClinicDoctors(slug, params);
setDoctors(doctors);
@@ -73,6 +75,7 @@ function Head({ setDoctors, slug, filter, setFilter }) {
return (
{
setLoading(true);
- clearFilterParams(router, [
+ clearDoctorClinicParams(router,slug, [
"category",
"specialty",
"active",
diff --git a/components/clinic/components/doctors/head/modal/FilterModal.js b/components/clinic/components/doctors/head/modal/FilterModal.js
index bfdaaa3..4de0c7c 100644
--- a/components/clinic/components/doctors/head/modal/FilterModal.js
+++ b/components/clinic/components/doctors/head/modal/FilterModal.js
@@ -8,6 +8,7 @@ import ButtonApply from "./ButtonApply";
import DeleteAllButton from "./DeleteAllButton";
function FilterModal({
+ slug,
filter,
sendReq,
children,
@@ -36,6 +37,7 @@ function FilterModal({
>
-
-
+
+
);
}
diff --git a/components/clinic/index.js b/components/clinic/index.js
index a819557..750cd0c 100644
--- a/components/clinic/index.js
+++ b/components/clinic/index.js
@@ -9,14 +9,15 @@ import Tabs from "@/app/component/Tabs";
const listTab = ["درباره کلینیک", "اطلاعات تماس", "پزشک ها"];
-function ClinicPage({ data, doctors,slug }) {
+function ClinicPage({ data, doctors,slug ,pages}) {
const [value, setValue] = useState(0);
const handleChange = (_, newValue) => setValue(newValue);
+
const Components = [
,
,
- ,
+ ,
];
return (
diff --git a/helper/index.js b/helper/index.js
index 74948d0..f07a45b 100644
--- a/helper/index.js
+++ b/helper/index.js
@@ -153,7 +153,15 @@ export function clearFilterParams(router, listRemove) {
router.push(newUrl);
}
-
+export function clearDoctorClinicParams(router,slug,listRemove){
+ const currentParams=new URLSearchParams(window.location.search);
+ const clinicslug=slug;
+ const keysToRemove=listRemove;
+ keysToRemove.forEach((key)=>currentParams.delete(key));
+ const queryString=currentParams.toString();
+ const newUrl=queryString? `/clinic/${clinicslug}?${queryString}`:`/clinic/${clinicslug}`;
+ router.push(newUrl)
+}
export const filterList = (data) => {
const parentList = specialties.filter((item) => !item.parent);
const childrenList = specialties.filter((item) => item.parent);
diff --git a/services/clinicApi.js b/services/clinicApi.js
index 7424295..71a74b7 100644
--- a/services/clinicApi.js
+++ b/services/clinicApi.js
@@ -8,8 +8,6 @@ export async function getClinicDoctors(slug, params = {}) {
const query = new URLSearchParams(params).toString();
const finalUrl = `${baseUrl}/api/v1/clinic/doctor-list/${slug}?${query}`;
- console.log("Final API URL:", finalUrl);
-
const response = await fetch(finalUrl, { method: "GET" });
if (!response.ok) {
@@ -18,7 +16,6 @@ export async function getClinicDoctors(slug, params = {}) {
}
const json = await response.json();
- console.log("✅ raw API result:", json);
const doctorsList = json?.data || json || [];
return Array.isArray(doctorsList) ? doctorsList : [];