fix filter gender, req and set new data when delete all filters, show date time with timestamp in doctors list, fix send data in home page list specialty, change data of params for request to doctors in doctors page
This commit is contained in:
+96
-3
@@ -1,8 +1,12 @@
|
||||
import { toast } from "react-toastify";
|
||||
import specialties from "@/data/specialties.json";
|
||||
import Cookies from "js-cookie";
|
||||
import moment from "moment-jalaali";
|
||||
|
||||
// Data
|
||||
import specialties from "@/data/specialties.json";
|
||||
import states from "@/data/state.json";
|
||||
import cities from "@/data/city.json";
|
||||
|
||||
export const numberToArStyle = (num) => num?.toLocaleString("ar-AE") || "";
|
||||
|
||||
export const isActiveURL = (link, name) => link === name;
|
||||
@@ -329,9 +333,25 @@ export const QueryForDoctorsReq = (newFilter) => {
|
||||
if (newFilter.state?.id) params.state = newFilter.state.id;
|
||||
|
||||
if (newFilter.degree && newFilter.degree !== "همه موارد")
|
||||
params.degree = newFilter.degree;
|
||||
switch (newFilter.degree) {
|
||||
case "کارشناس":
|
||||
params.degree = "expert";
|
||||
break;
|
||||
case "پزشک عمومی":
|
||||
params.degree = "general";
|
||||
break;
|
||||
case "پزشک متخصص":
|
||||
params.degree = "specialist";
|
||||
break;
|
||||
case "پزشک فوق تخصص":
|
||||
params.degree = "subspecialistplus";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (newFilter.gender && newFilter.gender !== "هر دو")
|
||||
params.gender = newFilter.gender;
|
||||
params.gender = newFilter.gender === "مرد" ? "man" : "woman";
|
||||
|
||||
if (newFilter.name) params.name = newFilter.name;
|
||||
|
||||
@@ -342,3 +362,76 @@ export const QueryForDoctorsReq = (newFilter) => {
|
||||
|
||||
return params;
|
||||
};
|
||||
|
||||
export const buildDoctorParams = (searchParams) => {
|
||||
const params = {};
|
||||
|
||||
// 🔹 active
|
||||
if (searchParams.active && Number(searchParams.active) === 1) {
|
||||
params.active = 1;
|
||||
}
|
||||
|
||||
// 🔹 specialty (find by name in specialties.json)
|
||||
if (searchParams.specialty) {
|
||||
const spec = specialties.find((s) => s.name === searchParams.specialty);
|
||||
if (spec) {
|
||||
params.specialty = spec.id;
|
||||
}
|
||||
}
|
||||
|
||||
// 🔹 city (find by name in city.json)
|
||||
if (searchParams.city) {
|
||||
const cityObj = cities.find((c) => c.name === searchParams.city);
|
||||
if (cityObj) {
|
||||
params.city = cityObj.id;
|
||||
}
|
||||
}
|
||||
|
||||
// 🔹 state (find by name in state.json)
|
||||
if (searchParams.state) {
|
||||
const stateObj = states.find((s) => s.name === searchParams.state);
|
||||
if (stateObj) {
|
||||
params.state = stateObj.id;
|
||||
}
|
||||
}
|
||||
|
||||
// 🔹 degree → convert fa → en
|
||||
if (searchParams.degree) {
|
||||
switch (searchParams.degree) {
|
||||
case "کارشناس":
|
||||
params.degree = "expert";
|
||||
break;
|
||||
case "پزشک عمومی":
|
||||
params.degree = "general";
|
||||
break;
|
||||
case "پزشک متخصص":
|
||||
params.degree = "specialist";
|
||||
break;
|
||||
case "پزشک فوق تخصص":
|
||||
params.degree = "subspecialistplus";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 🔹 gender
|
||||
if (searchParams.gender) {
|
||||
if (searchParams.gender === "مرد") params.gender = "man";
|
||||
if (searchParams.gender === "زن") params.gender = "woman";
|
||||
}
|
||||
|
||||
// 🔹 name
|
||||
if (searchParams.name) {
|
||||
params.name = searchParams.name;
|
||||
}
|
||||
|
||||
// 🔹 sort (3 = ASC, 4|5 = DESC)
|
||||
if (searchParams.sort) {
|
||||
const sortNum = Number(searchParams.sort);
|
||||
if (sortNum === 3) params.sort = "ASC";
|
||||
else if ([4, 5].includes(sortNum)) params.sort = "DESC";
|
||||
}
|
||||
|
||||
return params;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user