/* ============================================================ ConstellationTab.tsx — обёртка вкладки «Группировка» с реальными данными. Грузит состав/геометрию/расписание из API (realData.ts) и монтирует прототипный ConstellationDashboard уже с готовыми env/domain/sched — поэтому его mount-once замыкания (RAF/canvas) видят стабильные данные с первого рендера. ============================================================ */ import { useEffect, useState, type ComponentType } from "react"; import ConstellationDashboardImpl from "./ConstellationDashboard.jsx"; import { loadConstellationEnv, type ConstellationConfig } from "./realData"; import "./dashboard.css"; // ConstellationDashboard — JS-модуль прототипа; типизируем точку монтирования. const ConstellationDashboard = ConstellationDashboardImpl as ComponentType; type LoadState = | { kind: "loading" } | { kind: "error"; message: string } | { kind: "ready"; cfg: ConstellationConfig }; export function ConstellationTab() { const [state, setState] = useState({ kind: "loading" }); useEffect(() => { let cancelled = false; setState({ kind: "loading" }); loadConstellationEnv() .then((cfg) => { if (!cancelled) setState({ kind: "ready", cfg }); }) .catch((error: unknown) => { if (!cancelled) { setState({ kind: "error", message: error instanceof Error ? error.message : "Не удалось загрузить данные группировки." }); } }); return () => { cancelled = true; }; }, []); if (state.kind === "loading") { return ; } if (state.kind === "error") { return ; } if (state.cfg.env.sats.length === 0) { return ; } return ; } function ConstellationNotice({ text, tone }: { text: string; tone?: "error" }) { return (
{text}
); } export default ConstellationTab;