fix(site-finder): «Скачать отчёт» без пустых скобок на fast-path из кэша #2289
3 changed files with 10 additions and 8 deletions
|
|
@ -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)"}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
: "Полный отчёт"}
|
||||
</span>
|
||||
<span className={styles.exportDesc}>
|
||||
|
|
|
|||
|
|
@ -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 "";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue