fix: align list expiry and date ordering with tender deadlines
This commit is contained in:
+16
-13
@@ -1,3 +1,4 @@
|
||||
import { deadlineInfo, tenderDateKey, istanbulDateKey } from './tenderCalendar.js';
|
||||
/**
|
||||
* İhale tarih yardımcıları — üst kartlar (SummaryCards) ile liste filtresi
|
||||
* (TenderList) aynı ölçütü kullansın diye tek yerde.
|
||||
@@ -11,9 +12,8 @@
|
||||
// "gg.aa.yyyy" → Date. Ayrıştırılamayanı GEÇMİŞ SAYMAYIZ: tarihi belirsiz bir
|
||||
// ihaleyi sessizce gizlemek, geçmiş bir ihaleyi göstermekten daha kötüdür.
|
||||
export const ihaleGunu = (v) => {
|
||||
const m = /^(\d{2})\.(\d{2})\.(\d{4})/.exec(String(v || '').trim());
|
||||
if (!m) return null;
|
||||
return new Date(Number(m[3]), Number(m[2]) - 1, Number(m[1]));
|
||||
const key = tenderDateKey({tarih:v});
|
||||
return key ? new Date(key+'T00:00:00+03:00') : null;
|
||||
};
|
||||
|
||||
// Her biçimi "yyyy-aa-gg" dizesine indirger (karşılaştırma için).
|
||||
@@ -26,12 +26,7 @@ export const ilanTarihiISO = (t) => {
|
||||
return '';
|
||||
};
|
||||
|
||||
const iso = (d) => {
|
||||
const y = d.getFullYear();
|
||||
const a = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const g = String(d.getDate()).padStart(2, '0');
|
||||
return `${y}-${a}-${g}`;
|
||||
};
|
||||
const iso = istanbulDateKey;
|
||||
|
||||
export const bugunISO = () => iso(new Date());
|
||||
|
||||
@@ -47,10 +42,18 @@ export const girisSonrasiEklendi = (t, oncekiGirisMs) => {
|
||||
};
|
||||
|
||||
// Süresi geçmemiş (veya tarihi okunamayan) ihale — listenin varsayılan görünümü.
|
||||
export const acikIhale = (t, bugun) => {
|
||||
const gun = ihaleGunu(t?.tarih);
|
||||
return !(gun && gun < bugun);
|
||||
};
|
||||
export const acikIhale = (t, now = new Date()) =>
|
||||
!['Sonuçlandı','Sözleşme İmzalandı','İptal'].includes(t?.durum) && !t?.kazananFirma && deadlineInfo(t,now).expired !== true;
|
||||
|
||||
export function compareTenderDeadlines(a,b,direction = 1) {
|
||||
const x=deadlineInfo(a),y=deadlineInfo(b);
|
||||
if (!x.dateKey || !y.dateKey) return x.dateKey ? -1 : y.dateKey ? 1 : 0;
|
||||
const day=x.dateKey.localeCompare(y.dateKey);
|
||||
if (day) return day * direction;
|
||||
// Unknown times follow known times on the same day in either direction.
|
||||
if (!x.deadline || !y.deadline) return x.deadline ? -1 : y.deadline ? 1 : 0;
|
||||
return (x.deadline-y.deadline)*direction;
|
||||
}
|
||||
|
||||
// Bu hızlı filtreler doğası gereği GEÇMİŞ ihaleleri hedefler; "sadece açık
|
||||
// ihaleler" kapısı bunlara uygulanmaz, yoksa hiç sonuç çıkmaz.
|
||||
|
||||
Reference in New Issue
Block a user