diff --git a/src/pages/EquipmentPage.tsx b/src/pages/EquipmentPage.tsx index 4fd1647..41f6d27 100644 --- a/src/pages/EquipmentPage.tsx +++ b/src/pages/EquipmentPage.tsx @@ -80,6 +80,7 @@ function PairCodeModal({ const [loading, setLoading] = useState(true) const [copied, setCopied] = useState(false) const [timeLeft, setTimeLeft] = useState(600) + const [paired, setPaired] = useState(false) const fetchCode = useCallback(() => { setLoading(true) @@ -91,6 +92,22 @@ function PairCodeModal({ }) }, [slug, workstation.id]) + // Poll workstation status — auto-close when agent connects + useEffect(() => { + const poll = setInterval(async () => { + try { + const list = await api.workstations.list(slug) + const ws = list.find((w: Workstation) => w.id === workstation.id) + if (ws?.agentId && ws?.isOnline) { + setPaired(true) + clearInterval(poll) + setTimeout(onClose, 1500) + } + } catch { /* ignore */ } + }, 3000) + return () => clearInterval(poll) + }, [slug, workstation.id, onClose]) + useEffect(() => { fetchCode() }, [fetchCode]) useEffect(() => { @@ -131,7 +148,15 @@ function PairCodeModal({ Рабочее место: {workstation.name}

- {loading ? ( + {paired ? ( +
+
+ +
+

Агент подключён!

+

Окно закроется автоматически...

+
+ ) : loading ? (
@@ -163,7 +188,7 @@ function PairCodeModal({ )} -