Distinguish shared item inventory from tender rows and load errors
This commit is contained in:
+15
-5
@@ -8,11 +8,21 @@
|
||||
import { getToken } from './auth.js';
|
||||
|
||||
/** Bir ihalenin tüm kalemleri. */
|
||||
export async function kalemleriGetir(ikn) {
|
||||
const r = await fetch(`/api/kalem?ikn=${encodeURIComponent(ikn)}`);
|
||||
const d = await r.json().catch(() => ({}));
|
||||
if (!d.success) throw new Error(d.error || 'kalemler alınamadı');
|
||||
return d;
|
||||
export async function kalemleriGetir(ikn, {signal, timeoutMs = 30000} = {}) {
|
||||
const controller = new AbortController();
|
||||
const cancel = () => controller.abort();
|
||||
if (signal?.aborted) cancel(); else signal?.addEventListener('abort',cancel,{once:true});
|
||||
let timedOut = false;
|
||||
const timer = setTimeout(() => {timedOut=true;controller.abort();},timeoutMs);
|
||||
try {
|
||||
const r = await fetch(`/api/kalem?ikn=${encodeURIComponent(ikn)}`,{signal:controller.signal});
|
||||
const d = await r.json().catch(() => null);
|
||||
if (!r.ok || d?.success !== true || !Array.isArray(d.kalemler)) throw new Error('Kalem listesi alınamadı. Yeniden deneyin.');
|
||||
return d;
|
||||
} catch (error) {
|
||||
if (timedOut) throw new Error('Kalem listesi yüklenirken zaman aşımı oluştu.');
|
||||
throw error;
|
||||
} finally {clearTimeout(timer);signal?.removeEventListener('abort',cancel);}
|
||||
}
|
||||
|
||||
/** Kalem metninde arama — eşleşen İKN'ler. */
|
||||
|
||||
Reference in New Issue
Block a user