fix(doctors): improve filter performance and resolve modal closing issues

This commit is contained in:
hamed
2026-06-21 15:47:37 +03:30
parent 2fc74a664e
commit cb13ba3f45
10 changed files with 232 additions and 58 deletions
@@ -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);
+1 -1
View File
@@ -17,7 +17,7 @@ function DoctorsPage({ matchedCity, matchedState, list }) {
const findItem = (key, name) =>
specialties.find((item) => item[key] === name);
const isParent =
findItem("name", fieldName) && findItem("name", fieldName).parent;
findItem("name", fieldName) && findItem("name", fieldName).parent_id;
const selectedState = searchParams.get("state") || matchedState?.name;
const selectedCity =
+2 -10
View File
@@ -1,22 +1,14 @@
import { Button } from "@mui/material";
import { useState } from "react";
function ButtonApply({ sendReq, setOpen }) {
const [loading, setLoading] = useState(false);
const handleClick = () => {
setLoading(true);
sendReq().finally(() => {
setOpen(false);
setLoading(false);
});
setOpen(false);
sendReq();
};
return (
<div className="flex justify-end w-full">
<Button
disabled={loading}
variant="contained"
onClick={handleClick}
className="!px-3 !py-2 !text-[16px] !font-medium"
+8 -7
View File
@@ -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);
+1 -1
View File
@@ -3,7 +3,7 @@ import specialties from "@/data/specialties.json";
import Link from "next/link";
function FrequentSearches() {
const childrenList = specialties.filter((item) => item.parent);
const childrenList = specialties.filter((item) => item.parent_id);
return (
<div className="flex items-center justify-center gap-[8px] sm:gap-[10px] md:gap-[13px] lg:gap-[16px] w-full">