From ad01bc7f4d3165dc400f8909775d02c58458cd6f Mon Sep 17 00:00:00 2001
From: HotelSync
Date: Sat, 28 Mar 2026 17:07:50 +0300
Subject: [PATCH] feat: auto-close pair modal on agent connect, center close
button
Co-Authored-By: Claude Sonnet 4.6
---
src/pages/EquipmentPage.tsx | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
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({
>
)}
-