"use client"; /** * PticaPageContent — client root of the ПТИЦА cockpit (INCREMENT 1). * * Wires the SAME /analyze data as the existing light analysis page via * useParcelAnalyzeQuery, narrows the response to ParcelAnalysis (the sanctioned * `as unknown as` pattern — see AnalysisPageContent.tsx:111), and composes the * dark operator-terminal shell. Only the 'analysis' tab renders content in PR#1; * Scenarios / Reports / Compare show an honest "В разработке" panel. * * The root carries BOTH `.pticaRoot` and `data-theme="dark"` so the scoped dark * tokens apply here and never leak to the light pages. */ import { useState } from "react"; import Link from "next/link"; import styles from "./ptica.module.css"; import { useParcelAnalyzeQuery, useParcelForecastQuery, } from "@/lib/site-finder-api"; import type { ParcelAnalysis } from "@/types/site-finder"; import { PticaShell } from "@/components/site-finder/ptica/PticaShell"; import type { PticaTab } from "@/components/site-finder/ptica/PticaShell"; import { PticaHero } from "@/components/site-finder/ptica/PticaHero"; import { DevelopmentScan } from "@/components/site-finder/ptica/DevelopmentScan"; import { PticaScenarios } from "@/components/site-finder/ptica/scenarios/PticaScenarios"; import { PticaReports } from "@/components/site-finder/ptica/reports/PticaReports"; import { PticaCompare } from "@/components/site-finder/ptica/compare/PticaCompare"; interface Props { cad: string; } export function PticaPageContent({ cad }: Props) { const [horizon, setHorizon] = useState(12); const [tab, setTab] = useState("analysis"); const { data, isLoading, error } = useParcelAnalyzeQuery(cad, horizon); // §22 forecast is keyed/cached by cad — call unconditionally; it polls the // async report (enqueued by /analyze) and feeds both the hero invest-score and // the Scenarios tab. Pending state is handled inside each consumer. const { data: forecastData } = useParcelForecastQuery(cad); const forecastReport = forecastData?.status === "ready" ? forecastData.report : undefined; // ── Loading ──────────────────────────────────────────────────────────────── if (isLoading) { return (
Анализируем участок {cad}…
); } // ── Error ────────────────────────────────────────────────────────────────── if (error || !data) { const msg = error instanceof Error ? error.message : "Ошибка загрузки анализа"; return (
{msg}
← Вернуться к Site Finder
); } // Narrow to ParcelAnalysis (superset of ParcelAnalyzeResponse) — both describe // the same /analyze endpoint. Sanctioned pattern (AnalysisPageContent.tsx:111). const analysis = data as unknown as ParcelAnalysis; return (
{tab === "analysis" && ( <> )} {tab === "scenarios" && ( )} {tab === "reports" && } {tab === "compare" && }
); }