Share stored document retry flow across tender detail and vault
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { readableDocument, retryDocumentExtraction } from '../../services/storedDocument';
|
||||
import { documentProcessingLabel } from '../../services/documentProcessing';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useApp } from '../../context/AppContext';
|
||||
@@ -16,6 +17,7 @@ export const DocumentVault = () => {
|
||||
const [durum, setDurum] = useState(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [hata, setHata] = useState(null);
|
||||
const [islemeBilgi, setIslemeBilgi] = useState(null);
|
||||
const [kategori, setKategori] = useState(KATEGORILER[0]);
|
||||
const dosyaRef = useRef(null);
|
||||
|
||||
@@ -26,6 +28,19 @@ export const DocumentVault = () => {
|
||||
};
|
||||
useEffect(yukle, [authUser]);
|
||||
|
||||
const yenidenIsle = async (document) => {
|
||||
setBusy(true); setHata(null); setIslemeBilgi(null);
|
||||
try {
|
||||
const result = await retryDocumentExtraction(document);
|
||||
setIslemeBilgi(`${document.ad}: ${result.sayi || 0} kalem çıkarıldı.`);
|
||||
} catch (error) { setHata(error.message); }
|
||||
finally {
|
||||
try { setDurum(await listDocuments()); }
|
||||
catch { setHata(previous => [previous, 'Belge listesi yenilenemedi.'].filter(Boolean).join(' ')); }
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const dosyaSecildi = async (e) => {
|
||||
const f = e.target.files?.[0];
|
||||
if (!f) return;
|
||||
@@ -250,6 +265,7 @@ export const DocumentVault = () => {
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
{islemeBilgi && <p role="status" className="text-xs text-slate-700">{islemeBilgi}</p>}
|
||||
{durum.belgeler.map((d) => (
|
||||
<div key={d.id} className="bg-white rounded-xl border border-slate-200 p-4 shadow-xs flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
@@ -273,7 +289,14 @@ export const DocumentVault = () => {
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 shrink-0">
|
||||
<div className="flex flex-wrap items-center gap-1">
|
||||
{d.tur === 'ihale' && d.ikn && readableDocument(d.ad) && (
|
||||
<button onClick={() => yenidenIsle(d)} disabled={busy || !d.erisilebilir}
|
||||
aria-label={`${d.ad} için kalem çıkarımını yeniden dene`}
|
||||
className="text-[10px] text-blue-700 font-bold disabled:opacity-40">
|
||||
Kalemleri yeniden çıkar
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => downloadDocument(d.id, d.ad).catch((e) => setHata(e.message))}
|
||||
className="text-slate-400 hover:text-teal-600 p-1" title="İndir">
|
||||
<Download className="w-4 h-4" />
|
||||
|
||||
Reference in New Issue
Block a user