From 08bbf44be234781e011da1d22fe2963af37c6110 Mon Sep 17 00:00:00 2001 From: bot-backend Date: Fri, 3 Jul 2026 16:28:51 +0500 Subject: [PATCH] =?UTF-8?q?fix(site-finder):=20=C2=AB=D0=A1=D0=BA=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=D1=82=D1=8C=20=D0=BE=D1=82=D1=87=D1=91=D1=82=C2=BB?= =?UTF-8?q?=20=D0=B1=D0=B5=D0=B7=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D1=85=20?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D0=B1=D0=BE=D0=BA=20=D0=BD=D0=B0=20fast-path?= =?UTF-8?q?=20=D0=B8=D0=B7=20=D0=BA=D1=8D=D1=88=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qa поймал: на мгновенном ready из POST-ответа (кэш) report_generated_at ещё null (дата приходит только из GET status) → кнопка рисовала «Скачать отчёт ()». Новый хелпер readyReportLabel опускает скобки без даты; оба компонента переведены на него. --- .../src/components/site-finder/analysis/ExportButtons.tsx | 6 ++---- .../components/site-finder/ptica/reports/PticaReports.tsx | 6 ++---- frontend/src/hooks/useFullReport.ts | 6 ++++++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/site-finder/analysis/ExportButtons.tsx b/frontend/src/components/site-finder/analysis/ExportButtons.tsx index a4e784aa..72821253 100644 --- a/frontend/src/components/site-finder/analysis/ExportButtons.tsx +++ b/frontend/src/components/site-finder/analysis/ExportButtons.tsx @@ -15,7 +15,7 @@ import { triggerDownload } from "@/lib/download"; import { useFullReport, formatElapsed, - formatReportDate, + readyReportLabel, } from "@/hooks/useFullReport"; import type { ParcelAnalyzeResponse, ParcelEgrn } from "@/lib/site-finder-api"; @@ -235,9 +235,7 @@ export function ExportButtons({ cad, analyzeData, egrn }: Props) { {reportBuilding ? `Готовится… ${formatElapsed(fullReport.elapsedMs)}` : reportReady - ? `Скачать отчёт (${formatReportDate( - fullReport.reportGeneratedAt, - )})` + ? readyReportLabel(fullReport.reportGeneratedAt) : "Полный отчёт (PDF)"} diff --git a/frontend/src/components/site-finder/ptica/reports/PticaReports.tsx b/frontend/src/components/site-finder/ptica/reports/PticaReports.tsx index 842de661..fd64fd41 100644 --- a/frontend/src/components/site-finder/ptica/reports/PticaReports.tsx +++ b/frontend/src/components/site-finder/ptica/reports/PticaReports.tsx @@ -33,7 +33,7 @@ import { useParcelForecastQuery } from "@/lib/site-finder-api"; import { useFullReport, formatElapsed, - formatReportDate, + readyReportLabel, } from "@/hooks/useFullReport"; import type { ParcelAnalysis } from "@/types/site-finder"; import { StatusRow } from "@/components/site-finder/ptica/drawers/DrawerPrimitives"; @@ -338,9 +338,7 @@ export function PticaReports({ cad, analysis }: Props) { {fullReport.uiState === "building" ? `Готовится… ${formatElapsed(fullReport.elapsedMs)}` : fullReport.uiState === "ready" - ? `Скачать отчёт (${formatReportDate( - fullReport.reportGeneratedAt, - )})` + ? readyReportLabel(fullReport.reportGeneratedAt) : "Полный отчёт"} diff --git a/frontend/src/hooks/useFullReport.ts b/frontend/src/hooks/useFullReport.ts index 5f8950d0..282a556c 100644 --- a/frontend/src/hooks/useFullReport.ts +++ b/frontend/src/hooks/useFullReport.ts @@ -219,6 +219,12 @@ export function formatElapsed(ms: number): string { return `${min}:${String(sec).padStart(2, "0")}`; } +/** «Скачать отчёт (дата)»; на fast-path из кэша даты ещё нет — без пустых скобок. */ +export function readyReportLabel(iso: string | null): string { + const d = formatReportDate(iso); + return d ? `Скачать отчёт (${d})` : "Скачать отчёт"; +} + /** ISO → «ru-RU» дата генерации отчёта (репо-конвенция, NaN-fallback). */ export function formatReportDate(iso: string | null): string { if (!iso) return "";