change bg of auto-selector, remove value of search from url when click on x button on autoselector, remove to set data of search field in clinics page, fix remove data and update state filter after click on clearAll text in autoselector of doctors age

This commit is contained in:
ehsan
2025-09-17 20:08:42 +03:30
parent 41ba7aa709
commit a6386e693f
8 changed files with 57 additions and 41 deletions
+8 -14
View File
@@ -7,10 +7,9 @@ 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)
);
const specialtyItem =
filter.name &&
specialties.find((item) => item.name.includes(filter.name));
if (specialtyItem) {
if (specialtyItem.parent) {
@@ -21,23 +20,18 @@ function SendReq({ filter, setFilter, setDataInURL, sendReq }) {
} else {
newFilter.specialty = specialtyItem;
}
reqData = newFilter;
reqData.name = "";
} else {
reqData = newFilter;
}
setFilter(newFilter);
setDataInURL(newFilter);
return reqData;
return newFilter;
};
const filterData = () => {
setLoading(true);
const reqData = checkName();
const newFilter = checkName();
setFilter(newFilter);
setDataInURL(newFilter);
sendReq(reqData).finally(() => {
sendReq(newFilter).finally(() => {
setLoading(false);
});
};