fix(site-finder): «Скачать отчёт» без пустых скобок на fast-path из кэша
All checks were successful
CI Trade-In / changes (pull_request) Successful in 7s
CI / changes (pull_request) Successful in 7s
CI Trade-In / backend-tests (pull_request) Has been skipped
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Successful in 57s
CI / openapi-codegen-check (pull_request) Successful in 1m53s
All checks were successful
CI Trade-In / changes (pull_request) Successful in 7s
CI / changes (pull_request) Successful in 7s
CI Trade-In / backend-tests (pull_request) Has been skipped
CI Trade-In / frontend-checks (pull_request) Has been skipped
CI / backend-tests (pull_request) Has been skipped
CI / frontend-tests (pull_request) Successful in 57s
CI / openapi-codegen-check (pull_request) Successful in 1m53s
qa поймал: на мгновенном ready из POST-ответа (кэш) report_generated_at ещё null (дата приходит только из GET status) → кнопка рисовала «Скачать отчёт ()». Новый хелпер readyReportLabel опускает скобки без даты; оба компонента переведены на него.
This commit is contained in:
parent
2f127c4316
commit
08bbf44be2
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