add auto-selecotr to home page and handle set in data, search in specialties and send req for filter && add locations and change text

This commit is contained in:
Ehsan
2025-09-15 19:45:39 +03:30
parent 153cb5bc9f
commit 41ba7aa709
14 changed files with 88 additions and 62 deletions
+31 -2
View File
@@ -1,14 +1,43 @@
import { Button } from "@mui/material";
import SearchD from "@/components/icons/SearchD";
import { useState } from "react";
import specialties from "@/data/specialties.json";
function SendReq({ sendReq }) {
function SendReq({ filter, setFilter, setDataInURL, sendReq }) {
const [loading, setLoading] = useState(false);
const checkName = () => {
let newFilter = filter;
let reqData = filter;
const specialtyItem = specialties.find((item) =>
item.name.includes(filter.name)
);
if (specialtyItem) {
if (specialtyItem.parent) {
newFilter.specialty = specialtyItem;
newFilter.category = specialties.find(
(item) => item.id === specialtyItem.parent
);
} else {
newFilter.specialty = specialtyItem;
}
reqData = newFilter;
reqData.name = "";
} else {
reqData = newFilter;
}
setFilter(newFilter);
setDataInURL(newFilter);
return reqData;
};
const filterData = () => {
setLoading(true);
const reqData = checkName();
sendReq().finally(() => {
sendReq(reqData).finally(() => {
setLoading(false);
});
};