fix: order calendar deadlines and surface undated tenders
This commit is contained in:
@@ -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};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user