File size: 964 Bytes
1e3df84 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { useState, useEffect } from 'react';
interface Props {
name: string;
}
export default function ProcessingStatus({ name }: Props) {
const [stage, setStage] = useState('');
useEffect(() => {
let active = true;
const poll = async () => {
try {
const res = await fetch(`/api/progress/${encodeURIComponent(name)}`);
if (res.ok && active) {
const data = await res.json();
if (data.stage) setStage(data.stage);
}
} catch { /* ignore */ }
};
const id = setInterval(poll, 800);
poll(); // immediate first check
return () => { active = false; clearInterval(id); };
}, [name]);
return (
<div className="processing-overlay">
<div className="spinner" />
<div className="processing-text">
Processing <strong>{name}</strong>
</div>
<div className="processing-stage">
{stage || 'Starting pipeline...'}
</div>
</div>
);
}
|