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 "";