import { useEffect, useState } from 'react'; import { Smartphone, Plus, Trash2, Info } from 'lucide-react'; import { PageHeader } from '@/components/PageHeader'; import { Card, CardHeader, Badge } from '@/components/ui/primitives'; import { apiGet, apiPost, apiDelete } from '@/api/client'; import { useAuth } from '@/core/store'; interface Device { imei: string; name: string; } export function DevicesModule() { const user = useAuth((s) => s.user); const [devices, setDevices] = useState([]); const [imei, setImei] = useState(''); const [name, setName] = useState(''); const [err, setErr] = useState(''); const [busy, setBusy] = useState(false); const refresh = () => apiGet('/devices').then(setDevices).catch(() => setDevices([])); useEffect(() => { refresh(); }, []); const bind = async () => { setErr(''); if (!/^\d{6,20}$/.test(imei.trim())) { setErr('IMEI — только цифры (6–20 знаков)'); return; } setBusy(true); try { await apiPost('/devices/bind', { imei: imei.trim(), name: name.trim() || undefined }); setImei(''); setName(''); await refresh(); } catch { setErr('Не удалось привязать устройство'); } finally { setBusy(false); } }; const remove = async (i: string) => { await apiDelete(`/devices/${i}`); refresh(); }; return (
кабинет: {user.clientId}} />
setImei(e.target.value)} placeholder="IMEI трекера" inputMode="numeric" className="tnum flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent" /> setName(e.target.value)} placeholder="Название (опционально)" className="flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent" />
{err &&

{err}

}
{devices.length === 0 ? (

Устройств пока нет. Привяжите трекер по IMEI — данные появятся после первого сеанса связи.

) : ( devices.map((d) => (
{d.name}
IMEI {d.imei}
)) )}

В конфигураторе Navtelecom укажите телематический сервер:

домен: gps.servaki.online
порт: 2000
протокол: FLEX

После привязки IMEI входящие данные попадут в ваш кабинет ({user.clientId}) и появятся в GPS-мониторинге — только вам.

); }