use Istanbul dates for document alerts

This commit is contained in:
2026-09-06 19:12:39 +03:00
parent 9b9df43a00
commit 3fbaa1ca26
2 changed files with 14 additions and 2 deletions
+8 -2
View File
@@ -14,6 +14,7 @@ import { getUserDataSnapshot, setUserData, getPlan, bildirimleriGetir, bildirimO
import { applyTenderStates, tenderStateKey, tenderSnapshot, publicTender, tenderSourceChanges } from '../services/tenderState';
import { getTenderStates, saveTenderState } from '../services/account';
import { SECTORS_LIST, INSTITUTION_TYPES_LIST } from '../data/constants';
import { istanbulDateKey } from '../services/tenderCalendar';
const AppContext = createContext();
@@ -710,7 +711,7 @@ export const AppProvider = ({ children }) => {
if (!veriSenkron) return;
const session = getToken();
const uyariAnahtari = hesapAnahtari('ihaleist_belge_uyari_gunu', authUser?.email);
const bugun = new Date().toISOString().slice(0, 10);
const bugun = istanbulDateKey();
try { if (localStorage.getItem(uyariAnahtari) === bugun) return; } catch { /* yoksay */ }
listDocuments().then((d) => {
if(getToken() !== session) return;
@@ -718,7 +719,12 @@ export const AppProvider = ({ children }) => {
const dolan = [], yakin = [];
for (const b of d?.belgeler || []) {
if (!b.son_kullanma) continue;
const kalan = Math.ceil((new Date(b.son_kullanma).getTime() - simdi) / 86400000);
const rawDate = String(b.son_kullanma).trim();
const sonKullanmaMs = /^\d{4}-\d{2}-\d{2}$/.test(rawDate)
? Date.parse(`${rawDate}T00:00:00+03:00`)
: Date.parse(rawDate);
if (!Number.isFinite(sonKullanmaMs)) continue;
const kalan = Math.ceil((sonKullanmaMs - simdi) / 86400000);
if (kalan < 0) dolan.push(b.ad); else if (kalan <= 30) yakin.push(`${b.ad} (${kalan} gün)`);
}
if (dolan.length) notify(`${dolan.length} belgenin süresi dolmuş`, dolan.slice(0, 4).join(', '));