21 lines
594 B
JavaScript
21 lines
594 B
JavaScript
import specialties from "@/data/specialties.json";
|
|
|
|
export function buildSearchUrl(data = {}) {
|
|
const filters = {};
|
|
if (data.city && data.city !== "نوبت 724") filters.city = data.city;
|
|
if (data.province) filters.state = data.province;
|
|
if (data.search) {
|
|
const specialtyItem = specialties.find((item) =>
|
|
item.name.includes(data.search)
|
|
);
|
|
if (specialtyItem) {
|
|
filters.specialty = specialtyItem.name;
|
|
} else {
|
|
filters.name = data.search;
|
|
}
|
|
}
|
|
|
|
const queryParams = new URLSearchParams(filters).toString();
|
|
return `/doctors?${queryParams}`;
|
|
}
|