validate delivery queue rows
This commit is contained in:
@@ -10,7 +10,13 @@ function Queue({weekly}){
|
|||||||
const endpoint=weekly?'/api/admin/brief/outbox':'/api/admin/notify/outbox';
|
const endpoint=weekly?'/api/admin/brief/outbox':'/api/admin/notify/outbox';
|
||||||
const [rows,setRows]=useState(null),[error,setError]=useState(null),[busy,setBusy]=useState(false);
|
const [rows,setRows]=useState(null),[error,setError]=useState(null),[busy,setBusy]=useState(false);
|
||||||
const alive=useRef(true),locked=useRef(false);
|
const alive=useRef(true),locked=useRef(false);
|
||||||
const load=async()=>{const data=await accountRequest(endpoint);const rows=requireArray(data,'deliveries');if(alive.current)setRows(rows);};
|
const load=async()=>{
|
||||||
|
const data=await accountRequest(endpoint);
|
||||||
|
const received=requireArray(data,'deliveries');
|
||||||
|
const rows=received.filter(row=>row && typeof row==='object' && typeof row.id==='string' && row.id.trim() && typeof row.state==='string');
|
||||||
|
if(rows.length!==received.length)throw new Error('Sunucu gönderim kayıtlarından birini geçersiz döndürdü. Liste yenilenemedi.');
|
||||||
|
if(alive.current)setRows(rows);
|
||||||
|
};
|
||||||
const act=async fn=>{if(locked.current)return;locked.current=true;setBusy(true);setError(null);try{await fn();}catch(e){if(alive.current)setError(e.message);}finally{locked.current=false;if(alive.current)setBusy(false);}};
|
const act=async fn=>{if(locked.current)return;locked.current=true;setBusy(true);setError(null);try{await fn();}catch(e){if(alive.current)setError(e.message);}finally{locked.current=false;if(alive.current)setBusy(false);}};
|
||||||
useEffect(()=>{alive.current=true;void act(load);return()=>{alive.current=false;};},[]);
|
useEffect(()=>{alive.current=true;void act(load);return()=>{alive.current=false;};},[]);
|
||||||
return <section role="region" aria-label={weekly?'Haftalık özet gönderim incelemesi':'E-posta gönderim incelemesi'} aria-busy={busy} className="bg-white border rounded-xl p-5 space-y-3">
|
return <section role="region" aria-label={weekly?'Haftalık özet gönderim incelemesi':'E-posta gönderim incelemesi'} aria-busy={busy} className="bg-white border rounded-xl p-5 space-y-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user