send filter degree, gender and speciality with en name, handle set url in doctors page with searchbar home for key field or search, set value of province in url with id, change filter stars with ASC and DESC, bg-color of field in spcialties
This commit is contained in:
@@ -3,6 +3,7 @@ import specialties from "@/data/specialties.json";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { request } from "@/services/response";
|
||||
import { degreeVal } from "@/helper";
|
||||
|
||||
function ButtonApply({
|
||||
data,
|
||||
@@ -36,21 +37,32 @@ function ButtonApply({
|
||||
const mappings = [
|
||||
{
|
||||
key: "field",
|
||||
getValue: () => {
|
||||
getValue: (name) => {
|
||||
if (data.category) {
|
||||
const children = specialties.filter(
|
||||
(item) => item.parent === data.category.id
|
||||
);
|
||||
return children.length > 0
|
||||
? children.find((item) => item.name === data.specialties.name)
|
||||
?.name
|
||||
: data.category.name;
|
||||
? children.find((item) => item.name === data.specialties.name)[
|
||||
name || "id"
|
||||
]
|
||||
: data.category[name || "id"];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
{ key: "gender", getValue: () => data.gender || null },
|
||||
{ key: "degree", getValue: () => data.degree || null },
|
||||
{
|
||||
key: "gender",
|
||||
getValue: () => (data.gender === "زن" ? "woman" : "man" || null),
|
||||
},
|
||||
{
|
||||
key: "degree",
|
||||
getValue: (name) => {
|
||||
const item = degreeVal.find((item) => item.name === data.degree);
|
||||
|
||||
return (item && item[name || "val"]) || null;
|
||||
},
|
||||
},
|
||||
{ key: "turn", getValue: () => data.turn },
|
||||
];
|
||||
|
||||
@@ -60,9 +72,20 @@ function ButtonApply({
|
||||
};
|
||||
|
||||
mappings.forEach(({ key, getValue }) => {
|
||||
const value = getValue();
|
||||
let value;
|
||||
if (key === "field") {
|
||||
value = getValue("name");
|
||||
} else if (key === "gender") {
|
||||
value = data.gender;
|
||||
} else if ("degree") {
|
||||
value = getValue("name");
|
||||
}
|
||||
current.set(key, value);
|
||||
requestData[key] = value;
|
||||
});
|
||||
|
||||
mappings.forEach(({ key, getValue }) => {
|
||||
let value = getValue();
|
||||
requestData[key === "field" ? "specialty" : key] = value;
|
||||
});
|
||||
|
||||
const queryString = current.toString();
|
||||
|
||||
Reference in New Issue
Block a user