add state of page in url, add location and working_days on list in clinics page, fix update list clinic with page and limit value, hide pagination when list of clinic is empty, round image of doctor and appo in doctor item
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@mui/material";
|
||||
import SearchD from "@/components/icons/SearchD";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
function FilterButton({ filterData }) {
|
||||
function FilterButton({ limit, selected, filterData }) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const sendReq = () => {
|
||||
setLoading(true);
|
||||
filterData().finally(() => setLoading(false));
|
||||
const newSelected = { ...selected, page: 1, limit };
|
||||
filterData(newSelected).finally(() => {
|
||||
setLoading(false);
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
searchParams.set("page", 1);
|
||||
router.push(`?${searchParams.toString()}`);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,6 +12,7 @@ import { request } from "@/services/response";
|
||||
|
||||
function SearchBar({
|
||||
state,
|
||||
limit,
|
||||
selected,
|
||||
specialties,
|
||||
setSelected,
|
||||
@@ -59,6 +60,7 @@ function SearchBar({
|
||||
>
|
||||
<ModalSearchCity
|
||||
open={open}
|
||||
limit={limit}
|
||||
state={state}
|
||||
setOpen={setOpen}
|
||||
selected={selected}
|
||||
@@ -73,7 +75,7 @@ function SearchBar({
|
||||
placeholder="جستجوی تخصص"
|
||||
handleSearch={handleSearch}
|
||||
/>
|
||||
<FilterButton filterData={filterData} />
|
||||
<FilterButton limit={limit} selected={selected} filterData={filterData} />
|
||||
</ButtonGroup>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { Button } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
|
||||
// Icon
|
||||
import { Button } from "@mui/material";
|
||||
import CloseModalD from "@/components/icons/CloseModalD";
|
||||
import ArrowLeftM from "@/components/icons/ArrowLeftM";
|
||||
import AutoComplete from "./AutoComplete";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
function Content({
|
||||
state,
|
||||
limit,
|
||||
states,
|
||||
selected,
|
||||
updateData,
|
||||
@@ -16,6 +17,7 @@ function Content({
|
||||
filteredCities,
|
||||
handleSearch,
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const listboxProps = {
|
||||
style: {
|
||||
@@ -27,8 +29,12 @@ function Content({
|
||||
const handleFilter = () => {
|
||||
handleSearch && handleSearch("");
|
||||
setLoading(true);
|
||||
filterData().finally(() => {
|
||||
const newSelected = { ...selected, page: 1, limit };
|
||||
filterData(newSelected).finally(() => {
|
||||
handleClose();
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
searchParams.set("page", 1);
|
||||
router.push(`?${searchParams.toString()}`);
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ import { useRouter } from "next/navigation";
|
||||
function ModalSearchCity({
|
||||
open,
|
||||
state,
|
||||
limit,
|
||||
setOpen,
|
||||
children,
|
||||
selected,
|
||||
@@ -67,6 +68,7 @@ function ModalSearchCity({
|
||||
<Modal open={open} onClose={handleClose}>
|
||||
<Box sx={styleDefault} className="!w-full !h-full md:!w-fit md:!h-fit">
|
||||
<Content
|
||||
limit={limit}
|
||||
state={state}
|
||||
states={states}
|
||||
selected={selected}
|
||||
|
||||
Reference in New Issue
Block a user