change function and design page doctors & signin & signup & home & specialties & helper
This commit is contained in:
@@ -18,19 +18,18 @@ function DoctorsPage({ params, matchedCity, matchedState }) {
|
||||
province: matchedState?.name || params?.province,
|
||||
city: matchedCity?.name || params?.city,
|
||||
});
|
||||
const findItem = (name, value) =>
|
||||
specialties.find((item) => item[name] === value);
|
||||
const itemCategory = findItem("id", params.category);
|
||||
const itemSpecialties = findItem("id", params.specialties);
|
||||
const findSpecial = (id) => specialties.find((item) => item.id === id);
|
||||
|
||||
const [data, setData] = useState({
|
||||
category: itemCategory || "",
|
||||
specialties: itemSpecialties
|
||||
? { ...itemSpecialties, label: itemSpecialties.name }
|
||||
category: findSpecial(params.specialties)?.parent
|
||||
? findSpecial(findSpecial(params.specialties)?.parent)
|
||||
: findSpecial(params.specialties) || "",
|
||||
specialties: findSpecial(params.specialties)?.parent
|
||||
? findSpecial(params.specialties)
|
||||
: "",
|
||||
turn: params && params.hasOwnProperty("turn") ? JSON.parse(params.turn) : 1,
|
||||
gender: params.gender || "هر دو",
|
||||
degree: params.degree || "متخصص",
|
||||
degree: params.degree || "همه موارد",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -3,25 +3,22 @@ import RadioContent from "./RadioContent";
|
||||
import { FormControlLabel, Switch } from "@mui/material";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { filterList } from "@/helper";
|
||||
const group1 = ["خانم", "آقا", "هر دو"];
|
||||
const group2 = ["فوق تخصص", "دکترای تخصصی", "متخصص", "دکتری"];
|
||||
const gender = ["زن", "مرد", "هر دو"];
|
||||
const degree = ["پزشک عمومی", "پزشک متخصص", "پزشک فوق تخصص", "همه موارد"];
|
||||
|
||||
function Content({ data, setData }) {
|
||||
const router = useRouter();
|
||||
const { parentList, childrenList } = filterList(data);
|
||||
|
||||
const changeUrl = (value, name, removeSpecialties) => {
|
||||
const changeUrl = (value) => {
|
||||
const current = new URLSearchParams(window.location.search);
|
||||
current.set(name, value.id || value);
|
||||
if (removeSpecialties) {
|
||||
current.delete("specialties");
|
||||
}
|
||||
current.set("specialties", value.id || value);
|
||||
const queryString = current.toString();
|
||||
router.push(`/doctors?${queryString}`);
|
||||
};
|
||||
|
||||
const changeData = (value, name, removeSpecialties) => {
|
||||
changeUrl(value, name, removeSpecialties);
|
||||
changeUrl(value);
|
||||
const newData = data;
|
||||
newData[name] = value;
|
||||
if (removeSpecialties) {
|
||||
@@ -34,20 +31,18 @@ function Content({ data, setData }) {
|
||||
<div className="mt-[50px] px-[0px] md:px-[19px] lg:px-[38px] mb-[32px]">
|
||||
<AutoCompleteSelect
|
||||
list={parentList}
|
||||
updateData={(value, name) => changeData(value, name, true)}
|
||||
updateData={(value) => changeData(value, "category", true)}
|
||||
sendAll={true}
|
||||
value={data.category.name}
|
||||
value={data.category?.name}
|
||||
label="دسته بندی"
|
||||
name="category"
|
||||
/>
|
||||
{!!childrenList.length && (
|
||||
<div className="mt-[24px]">
|
||||
<AutoCompleteSelect
|
||||
list={childrenList}
|
||||
updateData={changeData}
|
||||
updateData={(value) => changeData(value, "specialties")}
|
||||
sendAll={true}
|
||||
value={data.specialties}
|
||||
name="specialties"
|
||||
value={data.specialties?.name}
|
||||
label="تخصص"
|
||||
/>
|
||||
</div>
|
||||
@@ -57,7 +52,7 @@ function Content({ data, setData }) {
|
||||
changeData={changeData}
|
||||
value={data.gender}
|
||||
text="جنسیت پزشک"
|
||||
group={group1}
|
||||
group={gender}
|
||||
name="gender"
|
||||
/>
|
||||
<span className="block mt-[16px] mb-[24px] w-full h-px bg-[#EFEFEF]"></span>
|
||||
@@ -65,7 +60,7 @@ function Content({ data, setData }) {
|
||||
changeData={changeData}
|
||||
value={data.degree}
|
||||
text="درجه علمی"
|
||||
group={group2}
|
||||
group={degree}
|
||||
name="degree"
|
||||
/>
|
||||
<span className="block mt-[16px] mb-[24px] w-full h-px bg-[#EFEFEF]"></span>
|
||||
|
||||
Reference in New Issue
Block a user