save state selected in modal filter, filter list with location selected, save data sort, filter list with sort point, real all url from .env file, change name of value category and specialties to persian and change functional find data with field

This commit is contained in:
Ehsan
2025-09-08 08:08:35 +03:30
parent ded164fcb9
commit 9f53daa398
19 changed files with 186 additions and 141 deletions
+13 -19
View File
@@ -15,24 +15,9 @@ function ButtonApply({
const router = useRouter();
const [loading, setLoading] = useState(false);
const sendReq = () => {
const sendReq = (requestData) => {
setLoading(true);
const params = new URLSearchParams(window.location.search);
const specialty = params.get("specialty");
const gender = params.get("gender");
const degree = params.get("degree");
const turn = params.get("turn");
const requestData = {
specialty: specialty === "null" ? null : specialty,
gender,
degree,
turn,
city: matchedCity?.id || null,
state: matchedState?.id || null,
};
request
.getDoctors(requestData)
.then((res) => {
@@ -50,13 +35,16 @@ function ButtonApply({
const mappings = [
{
key: "specialty",
key: "field",
getValue: () => {
if (data.category) {
const children = specialties.filter(
(item) => item.parent === data.category.id
);
return children.length > 0 ? children[0].id : data.category.id;
return children.length > 0
? children.find((item) => item.name === data.specialties.name)
?.name
: data.category.name;
}
return null;
},
@@ -66,14 +54,20 @@ function ButtonApply({
{ key: "turn", getValue: () => data.turn },
];
let requestData = {
city: matchedCity?.id || null,
state: matchedState?.id || null,
};
mappings.forEach(({ key, getValue }) => {
const value = getValue();
current.set(key, value);
requestData[key] = value;
});
const queryString = current.toString();
setConfirmedData(data);
sendReq();
sendReq(requestData);
router.push(`/doctors?${queryString}`);
};