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