handle request in modal filters, selector sort, search city with one function and field-search & handle change all data in doctors filter with one function & change modal search location in home page & set data with diffrent key in url of page doctors

This commit is contained in:
Ehsan
2025-09-12 20:51:50 +03:30
parent dbef29b9d9
commit 6414293d1c
19 changed files with 385 additions and 409 deletions
+29 -17
View File
@@ -5,32 +5,44 @@ import CloseModalD from "@/components/icons/CloseModalD";
import ArrowLeftM from "@/components/icons/ArrowLeftM";
import { useState } from "react";
import AddressSelector from "./AddressSelector";
import { getStateInfoClient } from "@/lib/getStateInfoClient";
function Content({
state,
states,
filter,
sendReq,
setFilter,
handleClose,
modalLocate,
setDataInURL,
filteredCities,
}) {
const [loading, setLoading] = useState(false);
const { matchedState } = getStateInfoClient();
const handleClick = () => {
setLoading(true);
sendReq().finally(() => {
console.log("asd");
setLoading(false);
handleClose();
});
};
const updateData = (name, value) => {
setFilter((prev) => {
if (name === "state") {
return {
...prev,
state: value,
city: null,
};
}
return {
...prev,
[name]: value,
};
});
const newFilter =
name === "state"
? {
...filter,
state: value,
city: null,
}
: {
...filter,
[name]: value,
};
setDataInURL(newFilter);
setFilter(newFilter);
};
return (
@@ -49,7 +61,7 @@ function Content({
name="state"
list={states}
label="استان"
disabled={state}
disabled={matchedState}
value={filter.state}
updateData={updateData}
/>
@@ -66,7 +78,7 @@ function Content({
<Button
loading={loading}
className="!w-full md:!w-fit !flex !px-3 items-center justify-center gap-1 mr-auto"
onClick={modalLocate}
onClick={handleClick}
variant="contained"
color="primary"
disabled={!filter.city || !filter.state}