fix: normalize Turkish search and isolate query item matches
This commit is contained in:
@@ -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));
|
||||
}
|
||||
Reference in New Issue
Block a user