fix: order calendar deadlines and surface undated tenders

This commit is contained in:
2026-09-06 14:05:24 +03:00
parent 2f34b42dc4
commit 6c33012ab8
4 changed files with 75 additions and 28 deletions
+21
View File
@@ -65,3 +65,24 @@ export function calendarMonthDays(month) {
label:new Date(`${month}-${day}T12:00:00Z`).toLocaleDateString('tr-TR',{weekday:'short',timeZone:'Europe/Istanbul'})};
});
}
/** Group once and order each date by known deadline; undated records remain visible. */
export function calendarAgenda(tenders, now=new Date()) {
const days=new Map(),undated=[];
for(const tender of tenders){
const entry={tender,info:deadlineInfo(tender,now)};
if(!entry.info.dateKey){undated.push(entry);continue;}
if(!days.has(entry.info.dateKey))days.set(entry.info.dateKey,[]);
days.get(entry.info.dateKey).push(entry);
}
const compare=(a,b)=>{
const aTime=a.info.deadline?.getTime(),bTime=b.info.deadline?.getTime();
if(aTime!==undefined&&bTime===undefined)return -1;
if(aTime===undefined&&bTime!==undefined)return 1;
if(aTime!==undefined&&aTime!==bTime)return aTime-bTime;
return String(a.tender.ikn || a.tender.id || '').localeCompare(String(b.tender.ikn || b.tender.id || ''),'tr');
};
for(const entries of days.values())entries.sort(compare);
undated.sort(compare);
return {days,undated};
}