fix(site-finder): «Скачать отчёт» без пустых скобок на fast-path из кэша #2289

Merged
bot-backend merged 1 commit from fix/report-ready-label into main 2026-07-03 11:32:05 +00:00
3 changed files with 10 additions and 8 deletions

View file

@ -15,7 +15,7 @@ import { triggerDownload } from "@/lib/download";
import { import {
useFullReport, useFullReport,
formatElapsed, formatElapsed,
formatReportDate, readyReportLabel,
} from "@/hooks/useFullReport"; } from "@/hooks/useFullReport";
import type { ParcelAnalyzeResponse, ParcelEgrn } from "@/lib/site-finder-api"; import type { ParcelAnalyzeResponse, ParcelEgrn } from "@/lib/site-finder-api";
@ -235,9 +235,7 @@ export function ExportButtons({ cad, analyzeData, egrn }: Props) {
{reportBuilding {reportBuilding
? `Готовится… ${formatElapsed(fullReport.elapsedMs)}` ? `Готовится… ${formatElapsed(fullReport.elapsedMs)}`
: reportReady : reportReady
? `Скачать отчёт (${formatReportDate( ? readyReportLabel(fullReport.reportGeneratedAt)
fullReport.reportGeneratedAt,
)})`
: "Полный отчёт (PDF)"} : "Полный отчёт (PDF)"}
</button> </button>
</div> </div>

View file

@ -33,7 +33,7 @@ import { useParcelForecastQuery } from "@/lib/site-finder-api";
import { import {
useFullReport, useFullReport,
formatElapsed, formatElapsed,
formatReportDate, readyReportLabel,
} from "@/hooks/useFullReport"; } from "@/hooks/useFullReport";
import type { ParcelAnalysis } from "@/types/site-finder"; import type { ParcelAnalysis } from "@/types/site-finder";
import { StatusRow } from "@/components/site-finder/ptica/drawers/DrawerPrimitives"; import { StatusRow } from "@/components/site-finder/ptica/drawers/DrawerPrimitives";
@ -338,9 +338,7 @@ export function PticaReports({ cad, analysis }: Props) {
{fullReport.uiState === "building" {fullReport.uiState === "building"
? `Готовится… ${formatElapsed(fullReport.elapsedMs)}` ? `Готовится… ${formatElapsed(fullReport.elapsedMs)}`
: fullReport.uiState === "ready" : fullReport.uiState === "ready"
? `Скачать отчёт (${formatReportDate( ? readyReportLabel(fullReport.reportGeneratedAt)
fullReport.reportGeneratedAt,
)})`
: "Полный отчёт"} : "Полный отчёт"}
</span> </span>
<span className={styles.exportDesc}> <span className={styles.exportDesc}>

View file

@ -219,6 +219,12 @@ export function formatElapsed(ms: number): string {
return `${min}:${String(sec).padStart(2, "0")}`; 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). */ /** ISO → «ru-RU» дата генерации отчёта (репо-конвенция, NaN-fallback). */
export function formatReportDate(iso: string | null): string { export function formatReportDate(iso: string | null): string {
if (!iso) return ""; if (!iso) return "";