Многоагентный аудит + имплементация: один воркер на файл, точечные правки. Верификация: py_compile (47/47 .py) + tsc --noEmit (0 ошибок). Unit-тесты не прогонялись (окружение не поднято: rollup native dep / нет pytest-venv). Полностью исправлено (169): #1336, #1337, #1339, #1340, #1341, #1342, #1343, #1345, #1346, #1348, #1349, #1350, #1351, #1354, #1356, #1358, #1359, #1360, #1362, #1364, #1365, #1366, #1367, #1368, #1369, #1370, #1371, #1372, #1373, #1374, #1375, #1376, #1377, #1378, #1379, #1380, #1381, #1382, #1384, #1385, #1386, #1387, #1388, #1389, #1390, #1391, #1392, #1394, #1395, #1396, #1397, #1399, #1400, #1401, #1402, #1403, #1404, #1408, #1409, #1410, #1411, #1412, #1413, #1414, #1415, #1416, #1417, #1418, #1420, #1423, #1425, #1426, #1427, #1428, #1429, #1430, #1431, #1432, #1433, #1434, #1435, #1437, #1438, #1439, #1440, #1441, #1442, #1443, #1444, #1445, #1446, #1447, #1448, #1449, #1450, #1451, #1452, #1453, #1454, #1455, #1456, #1457, #1458, #1459, #1460, #1461, #1462, #1463, #1464, #1465, #1466, #1467, #1468, #1469, #1471, #1472, #1473, #1474, #1476, #1478, #1479, #1481, #1482, #1483, #1484, #1485, #1487, #1488, #1489, #1490, #1491, #1492, #1493, #1494, #1495, #1496, #1497, #1499, #1500, #1501, #1502, #1504, #1505, #1506, #1507, #1510, #1514, #1515, #1516, #1517, #1518, #1519, #1521, #1522, #1523, #1524, #1525, #1526, #1527, #1528, #1529, #1531, #1532, #1533, #1534, #1535, #1536, #1537, #1538 Частично (9, in-file часть, остаток cross-file): #1361, #1419, #1422, #1424, #1470, #1475, #1477, #1480, #1498 Требуют cross-file (3, не тронуты): #1338, #1363, #1421 Пропущено (1): #1539 Не входило в партию: 22 needs-Leha issue (нужны решения владельца). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
266 lines
8.2 KiB
TypeScript
266 lines
8.2 KiB
TypeScript
"use client";
|
||
|
||
import React, { useEffect, useRef, useState } from "react";
|
||
import { ExternalLink } from "lucide-react";
|
||
|
||
// ── Types ─────────────────────────────────────────────────────────────────────
|
||
|
||
interface SubSection {
|
||
id: string;
|
||
label: string;
|
||
}
|
||
|
||
interface NavSection {
|
||
id: string;
|
||
label: string;
|
||
sub?: SubSection[];
|
||
}
|
||
|
||
// ── Config ────────────────────────────────────────────────────────────────────
|
||
|
||
const NAV_SECTIONS: NavSection[] = [
|
||
{ id: "section-1", label: "1. Объект" },
|
||
{ id: "section-2", label: "2. Земля и риски" },
|
||
{
|
||
id: "section-3",
|
||
label: "3. Рынок",
|
||
sub: [
|
||
{ id: "section-3-1", label: "3.1 Настройки выборки" },
|
||
{ id: "section-3-2", label: "3.2 Планировки" },
|
||
{ id: "section-3-3", label: "3.3 Остатки и скорость" },
|
||
],
|
||
},
|
||
{ id: "section-4", label: "4. Оценка" },
|
||
{ id: "section-5", label: "5. Атмосфера" },
|
||
{
|
||
id: "section-6",
|
||
label: "6. Прогноз",
|
||
sub: [
|
||
{ id: "section-6-1", label: "6.1 Прогноз по горизонтам" },
|
||
{ id: "section-6-2", label: "6.2 Сценарии" },
|
||
{ id: "section-6-3", label: "6.3 Уверенность" },
|
||
{ id: "section-6-4", label: "6.4 Рекомендация по продукту" },
|
||
{ id: "section-6-5", label: "6.5 Прозрачность скоринга" },
|
||
{ id: "section-6-6", label: "6.6 Будущее предложение и конкуренты" },
|
||
],
|
||
},
|
||
];
|
||
|
||
// All section IDs in scroll order (for IntersectionObserver)
|
||
const ALL_SECTION_IDS: string[] = NAV_SECTIONS.flatMap((s) =>
|
||
s.sub ? [s.id, ...s.sub.map((sub) => sub.id)] : [s.id],
|
||
);
|
||
|
||
// ── Component ─────────────────────────────────────────────────────────────────
|
||
|
||
export function AnalysisSidebar() {
|
||
const [activeId, setActiveId] = useState<string>(ALL_SECTION_IDS[0]);
|
||
const observerRef = useRef<IntersectionObserver | null>(null);
|
||
|
||
// Scrollspy via IntersectionObserver
|
||
useEffect(() => {
|
||
const candidates = ALL_SECTION_IDS.map((id) =>
|
||
document.getElementById(id),
|
||
).filter((el): el is HTMLElement => el !== null);
|
||
|
||
if (candidates.length === 0) return;
|
||
|
||
// Track which sections are visible; pick topmost visible one
|
||
const visible = new Set<string>();
|
||
|
||
observerRef.current = new IntersectionObserver(
|
||
(entries) => {
|
||
entries.forEach((entry) => {
|
||
if (entry.isIntersecting) {
|
||
visible.add(entry.target.id);
|
||
} else {
|
||
visible.delete(entry.target.id);
|
||
}
|
||
});
|
||
|
||
// Pick the topmost section that is currently visible
|
||
const next = ALL_SECTION_IDS.find((id) => visible.has(id));
|
||
if (next) setActiveId(next);
|
||
},
|
||
{
|
||
root: null,
|
||
// Trigger when section top enters top 60% of viewport
|
||
rootMargin: "-8px 0px -40% 0px",
|
||
threshold: 0,
|
||
},
|
||
);
|
||
|
||
candidates.forEach((el) => observerRef.current!.observe(el));
|
||
|
||
return () => {
|
||
observerRef.current?.disconnect();
|
||
};
|
||
}, []);
|
||
|
||
function handleAnchorClick(
|
||
e: React.MouseEvent<HTMLAnchorElement>,
|
||
targetId: string,
|
||
) {
|
||
e.preventDefault();
|
||
const el = document.getElementById(targetId);
|
||
if (el) {
|
||
el.scrollIntoView({ behavior: "smooth", block: "start" });
|
||
}
|
||
setActiveId(targetId);
|
||
}
|
||
|
||
return (
|
||
<aside
|
||
style={{
|
||
width: 240,
|
||
flexShrink: 0,
|
||
background: "var(--bg-card)",
|
||
borderRight: "1px solid var(--border-card)",
|
||
padding: "16px 12px",
|
||
display: "flex",
|
||
flexDirection: "column",
|
||
gap: 4,
|
||
position: "sticky",
|
||
top: 56,
|
||
height: "calc(100vh - 56px)",
|
||
overflowY: "auto",
|
||
}}
|
||
>
|
||
{/* Section label */}
|
||
<p
|
||
style={{
|
||
fontSize: 12,
|
||
fontWeight: 500,
|
||
textTransform: "uppercase",
|
||
letterSpacing: "0.04em",
|
||
color: "var(--fg-tertiary)",
|
||
margin: "0 0 8px",
|
||
padding: "0 4px",
|
||
}}
|
||
>
|
||
Навигация
|
||
</p>
|
||
|
||
{/* Nav items */}
|
||
{NAV_SECTIONS.map((section) => {
|
||
const isParentActive =
|
||
activeId === section.id ||
|
||
section.sub?.some((s) => s.id === activeId);
|
||
|
||
return (
|
||
<div key={section.id}>
|
||
<a
|
||
href={`#${section.id}`}
|
||
onClick={(e) => handleAnchorClick(e, section.id)}
|
||
style={{
|
||
display: "block",
|
||
padding: "7px 10px",
|
||
borderRadius: 8,
|
||
fontSize: 13,
|
||
fontWeight: isParentActive ? 600 : 400,
|
||
color: isParentActive ? "var(--accent)" : "var(--fg-secondary)",
|
||
background: isParentActive
|
||
? "var(--accent-soft)"
|
||
: "transparent",
|
||
textDecoration: "none",
|
||
transition: "background 100ms, color 100ms",
|
||
lineHeight: 1.4,
|
||
}}
|
||
>
|
||
{section.label}
|
||
</a>
|
||
|
||
{/* Sub-sections */}
|
||
{section.sub && (
|
||
<div
|
||
style={{
|
||
paddingLeft: 12,
|
||
marginTop: 2,
|
||
display: "flex",
|
||
flexDirection: "column",
|
||
gap: 2,
|
||
}}
|
||
>
|
||
{section.sub.map((sub) => {
|
||
const isSubActive = activeId === sub.id;
|
||
return (
|
||
<a
|
||
key={sub.id}
|
||
href={`#${sub.id}`}
|
||
onClick={(e) => handleAnchorClick(e, sub.id)}
|
||
style={{
|
||
display: "block",
|
||
padding: "5px 10px",
|
||
borderRadius: 6,
|
||
fontSize: 12,
|
||
fontWeight: isSubActive ? 600 : 400,
|
||
color: isSubActive
|
||
? "var(--accent)"
|
||
: "var(--fg-tertiary)",
|
||
background: isSubActive
|
||
? "var(--accent-soft)"
|
||
: "transparent",
|
||
textDecoration: "none",
|
||
transition: "background 100ms, color 100ms",
|
||
lineHeight: 1.4,
|
||
}}
|
||
>
|
||
{sub.label}
|
||
</a>
|
||
);
|
||
})}
|
||
</div>
|
||
)}
|
||
</div>
|
||
);
|
||
})}
|
||
|
||
{/* Sources footer */}
|
||
<div
|
||
style={{
|
||
marginTop: "auto",
|
||
paddingTop: 16,
|
||
borderTop: "1px solid var(--border-soft)",
|
||
}}
|
||
>
|
||
<p
|
||
style={{
|
||
fontSize: 11,
|
||
fontWeight: 500,
|
||
textTransform: "uppercase",
|
||
letterSpacing: "0.04em",
|
||
color: "var(--fg-tertiary)",
|
||
margin: "0 0 6px",
|
||
padding: "0 4px",
|
||
}}
|
||
>
|
||
Источники
|
||
</p>
|
||
{[
|
||
{ label: "Росреестр / ЕГРН", href: "https://rosreestr.gov.ru" },
|
||
{ label: "НСПД", href: "https://nspd.gov.ru" },
|
||
{ label: "2ГИС / OSM", href: "https://2gis.ru" },
|
||
].map(({ label, href }) => (
|
||
<a
|
||
key={label}
|
||
href={href}
|
||
target="_blank"
|
||
rel="noopener noreferrer"
|
||
style={{
|
||
display: "flex",
|
||
alignItems: "center",
|
||
gap: 4,
|
||
padding: "4px 4px",
|
||
fontSize: 11,
|
||
color: "var(--fg-tertiary)",
|
||
textDecoration: "none",
|
||
}}
|
||
>
|
||
<ExternalLink size={10} strokeWidth={1.5} />
|
||
{label}
|
||
</a>
|
||
))}
|
||
</div>
|
||
</aside>
|
||
);
|
||
}
|