fix: normalize Turkish search and isolate query item matches

This commit is contained in:
2026-09-06 09:22:05 +03:00
parent efec6e434d
commit a34b758430
5 changed files with 48 additions and 15 deletions
+15
View File
@@ -0,0 +1,15 @@
export const normalizeTenderSearch = value => String(value ?? '').normalize('NFKD')
.toLocaleLowerCase('tr-TR').replace(/ı/g,'i').replace(/[\u0300-\u036f]/g,'').replace(/\s+/g,' ').trim();
export function matchingItemResults(result, query) {
return result?.query === normalizeTenderSearch(query) ? result.matches : null;
}
export function matchesTenderSearch(tender, query, itemMatches) {
const q=normalizeTenderSearch(query);
if (!q) return true;
const values=[tender.baslik,tender.kurum,tender.ikn,
...(tender.items || []).map(item=>item.ad),
...(tender.kalemler || []).map(item=>typeof item === 'string' ? item : item.ad)];
return values.some(v=>normalizeTenderSearch(v).includes(q)) || Boolean(itemMatches?.has(tender.ikn));
}