add loading for redirect button from home to doctors page && change filter for field search in name or specialty and set in url && fix bug select city in home page

This commit is contained in:
ehsan
2025-09-21 23:12:47 +03:30
parent dfc8492afa
commit e11f4ed3c5
8 changed files with 75 additions and 22 deletions
+19 -6
View File
@@ -2,14 +2,17 @@
import SearchD from "@/components/icons/SearchD";
import { Search } from "@mui/icons-material";
import { Button } from "@mui/material";
import { Button, CircularProgress } from "@mui/material";
import { useRouter } from "next/navigation";
import specialties from "@/data/specialties.json";
import { useState } from "react";
function RedirectLink({ data }) {
const router = useRouter();
const [loading, setLoading] = useState(false);
const handleRedirect = () => {
const handleRedirect = (e) => {
loading && e.preventDefault()
const filters = {};
if (data.city && data.city !== "نوبت 724") filters.city = data.city;
if (data.province) filters.state = data.province;
@@ -25,18 +28,28 @@ function RedirectLink({ data }) {
}
const queryParams = new URLSearchParams(filters).toString();
setLoading(true);
router.push(`/doctors?${queryParams}`);
};
return (
<>
{/* <div className="min-w-[20px] min-h-[20px]">
<Search />
</div> */}
<Button
className="!hidden lg:!flex !rounded-[4px] !h-[40px] sm:!h-[42px] md:!h-[45px] lg:!h-[48px] !gap-2.5 !min-w-[114px]"
onClick={handleRedirect}
className="!hidden lg:!flex !rounded-[4px] !h-[40px] sm:!h-[42px] md:!h-[45px] lg:!h-[48px] !gap-2.5 !min-w-[114px]"
>
<div className="min-w-[20px] min-h-[20px]">
<Search />
<div className="min-w-[20px] min-h-[20px] grid place-items-center">
{loading ? (
<CircularProgress
className="!w-[24px] !h-[24px]"
sx={{ color: "#FFFFFF" }}
/>
) : (
<Search />
)}
</div>
<p>جستجو</p>
</Button>
+2 -2
View File
@@ -45,8 +45,8 @@ function ModalSearchCity({
}, [provinceSelected]);
const updateData = (event, name) => {
if (name === "province" && event !== provinceSelected) {
setSelected({ province: event, city: "" });
if (name === "province") {
setSelected({ ...selected, province: event, city: "" });
} else {
setSelected({ ...selected, [name]: event });
}