fix(doctors): improve filter performance and resolve modal closing issues
This commit is contained in:
@@ -6,13 +6,14 @@ function Content({ filter, setFilter, updateData, setDataInURL }) {
|
||||
const newFilter = { ...filter, [name]: value };
|
||||
|
||||
if (name === "category") {
|
||||
const childrenList = specialties.filter((item) => item.parent);
|
||||
const filteredChildrenList = childrenList.filter(
|
||||
(item) => item.parent === value.id
|
||||
);
|
||||
const firstChildren = filteredChildrenList[0];
|
||||
|
||||
newFilter.specialty = firstChildren || "";
|
||||
if (value) {
|
||||
const filtered = specialties
|
||||
.filter((item) => item.parent_id)
|
||||
.filter((item) => String(item.parent_id) === String(value.id));
|
||||
newFilter.specialty = filtered[0] || null;
|
||||
} else {
|
||||
newFilter.specialty = null;
|
||||
}
|
||||
}
|
||||
|
||||
setFilter(newFilter);
|
||||
|
||||
Reference in New Issue
Block a user