feat: normalize doctor name query to enhance search functionality and improve URL building
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import specialties from "@/data/specialties.json";
|
||||
import { normalizeDoctorNameQuery } from "@/helper";
|
||||
|
||||
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)
|
||||
);
|
||||
// عناوین احترامی («دکتر قلب» → «قلب») حذف میشوند تا تطبیق تخصص و نام درست کار کند
|
||||
const term = normalizeDoctorNameQuery(data.search);
|
||||
const specialtyItem = specialties.find((item) => item.name.includes(term));
|
||||
if (specialtyItem) {
|
||||
filters.specialty = specialtyItem.name;
|
||||
} else {
|
||||
filters.name = data.search;
|
||||
filters.name = term;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user