change function of fliter sort, modal and locate set new data and change it and update

This commit is contained in:
Ehsan
2025-09-12 09:39:48 +03:30
parent d04aa8568d
commit dbef29b9d9
18 changed files with 371 additions and 235 deletions
+12 -8
View File
@@ -1,27 +1,31 @@
import specialties from "@/data/specialties.json";
import Form from "./form";
function Content({ data, setData }) {
const changeData = (value, name, isCategory, key) => {
const newData = { ...data, [name]: value };
function Content({ filter, setFilter, updateData }) {
const changeSpecialty = (name, value) => {
const newFilter = { ...filter, [name]: value };
if (isCategory) {
if (name === "category") {
const childrenList = specialties.filter((item) => item.parent);
const filteredChildrenList = childrenList.filter(
(item) => item.parent === value.id
);
const firstChildren = filteredChildrenList[0];
newData.specialties = firstChildren || "";
newFilter.specialty = firstChildren || "";
}
setData(newData);
return newData;
setFilter(newFilter);
return newFilter;
};
return (
<div className="mt-[50px] px-[0px] md:px-[19px] lg:px-[38px] mb-[32px]">
<Form data={data} changeData={changeData} />
<Form
filter={filter}
updateData={updateData}
changeSpecialty={changeSpecialty}
/>
</div>
);
}