import React, { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { apiFetch } from "../api/client"; import "./Dashboard.css"; const STATUS_LABEL = { planned: 'Запланирован', active: 'Активен', paused: 'Приостановлен', completed: 'Завершён', archived: 'В архиве', }; const STATUS_CLASS = { planned: 'st-planned', active: 'st-active', paused: 'st-paused', completed: 'st-completed', archived: 'st-archived', }; const Dashboard = () => { const navigate = useNavigate(); const [operations, setOperations] = useState([]); const [summary, setSummary] = useState({ active: 0, total: 0, completed_24h: 0 }); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [statusFilter, setStatusFilter] = useState('active'); const [creating, setCreating] = useState(false); const load = async () => { try { setLoading(true); setError(null); const qs = statusFilter ? `?status=${statusFilter}` : ''; const resp = await apiFetch(`/api/v1/operations${qs}`); if (!resp.ok) throw new Error('Не удалось загрузить поиски'); const data = await resp.json(); setOperations(data.items); const sumResp = await apiFetch('/api/v1/operations/summary'); if (sumResp.ok) setSummary(await sumResp.json()); } catch (e) { setError(e.message); } finally { setLoading(false); } }; useEffect(() => { load(); }, [statusFilter]); const openCase = (op) => { // Рабочее пространство операции: анализ по её карточке navigate(`/analysis/${op.case_id}`, { state: { operation: op } }); }; const startNewSearch = () => navigate('/desktop'); return (