Persist document processing outcomes separately from upload success

This commit is contained in:
2026-09-06 09:34:52 +03:00
parent ece623d86c
commit 32ea749669
8 changed files with 72 additions and 10 deletions
+8 -2
View File
@@ -1,3 +1,4 @@
import { documentProcessingLabel } from '../../services/documentProcessing';
import React, { useState, useEffect, useRef } from 'react';
import { useApp } from '../../context/AppContext';
import { listDocuments, uploadDocument, deleteDocument, downloadDocument, formatBayt, updateDocumentMeta } from '../../services/account';
@@ -67,14 +68,17 @@ export const DocumentVault = () => {
const cevap = await uploadDocument(f, 'İhale Dokümanı', ikn, { otoIkn: true, documentType:'ihale' });
ikn = cevap?.ikn || ikn;
let kalem = cevap?.kalem?.sayi || null;
let kalemHata = cevap.processing?.status === 'error' ? cevap.processing.error : null;
if (ikn && !kalem && metin) {
try {
const { kalemCikar } = await import('../../services/kalem');
kalem = (await kalemCikar({ ikn, metin, dosya: f.name, documentId:cevap.id })).sayi || null;
} catch { /* kalem çıkmazsa yükleme yine başarılı */ }
} catch (error) { kalemHata = error.message; }
}
guncelle(i, { durum: 'tamam', ikn, kalem });
guncelle(i, { durum: 'tamam', ikn, kalem, kalemHata });
setDurum(cevap);
try { setDurum(await listDocuments()); }
catch { setHata('Dosya kayıtlı; güncel belge listesi alınamadı. Listeyi yeniden yükleyin.'); }
} catch (err) {
guncelle(i, { durum: 'hata', hata: err.message });
}
@@ -218,6 +222,7 @@ export const DocumentVault = () => {
{t.ikn
? <span className="font-mono font-bold text-amber-300">{t.ikn}</span>
: <span className="text-amber-200/80">İKN bulunamadı — ihaleye bağlanmadı</span>}
{t.kalemHata && <span role="alert" className="text-amber-200">Dosya kayıtlı; kalem aktarımı başarısız: {t.kalemHata}</span>}
{t.kalem ? <span className="text-emerald-300 font-bold flex items-center gap-1"><Package className="w-3 h-3" />{t.kalem} kalem</span> : null}
</span>
)}
@@ -254,6 +259,7 @@ export const DocumentVault = () => {
</p>
<p className="text-[10px] text-slate-400 mt-0.5">
{new Date(d.olusturma).toLocaleString('tr-TR')}
<span className="block">{documentProcessingLabel(d.isleme)}</span>
</p>
<label className="flex items-center gap-1.5 mt-1.5 text-[10px] text-slate-500">
<CalendarClock className={`w-3 h-3 ${kalanGun(d) != null && kalanGun(d) < 0 ? 'text-red-600' : kalanGun(d) != null && kalanGun(d) <= 30 ? 'text-amber-600' : 'text-slate-400'}`} />