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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user