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