show only the first item in appo list & update appo item text && change key in /doctors page URL && handle setting and updating data on first modal filter load

This commit is contained in:
Ehsan
2025-08-26 22:35:05 +03:30
parent 8e4f182868
commit 09867bf84a
13 changed files with 137 additions and 85 deletions
+16 -13
View File
@@ -12,27 +12,30 @@ function Content({ data, setData }) {
router.push(`/doctors?${queryString}`);
};
const changeData = (value, name, isCategory) => {
changeUrl(value, name);
const newData = data;
newData[name] = value;
const childrenList = specialties.filter((item) => item.parent);
const filteredChildrenList = childrenList.filter(
(item) => item.parent === value.id
);
const changeData = (value, name, isCategory, key) => {
const newData = { ...data, [name]: value };
if (isCategory) {
newData.specialties = "";
newData.specialties = filteredChildrenList[0];
const childrenList = specialties.filter((item) => item.parent);
const filteredChildrenList = childrenList.filter(
(item) => item.parent === value.id
);
const firstChildren = filteredChildrenList[0];
console.log(firstChildren);
newData.specialties = firstChildren || "";
changeUrl(firstChildren || value, key);
} else {
changeUrl(value, key);
}
setData(newData);
return newData;
};
console.log(data);
return (
<div className="mt-[50px] px-[0px] md:px-[19px] lg:px-[38px] mb-[32px]">
<Form data={data} changeUrl={changeUrl} changeData={changeData} />
<Form data={data} changeData={changeData} />
</div>
);
}