From 31d24ffbdb04e7cb64be45a091a5cd858432c35c Mon Sep 17 00:00:00 2001 From: bot-frontend Date: Sat, 30 May 2026 19:49:47 +0000 Subject: [PATCH] =?UTF-8?q?fix(tradein):=20error/not-found/loading=20UI=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20restore=20=D0=BF=D0=BE=20=3Fid=3D=20(#822)?= =?UTF-8?q?=20(#825)=20Co-authored-by:=20bot-frontend=20=20Co-committed-by:=20bot-frontend=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tradein-mvp/frontend/src/app/page.tsx | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tradein-mvp/frontend/src/app/page.tsx b/tradein-mvp/frontend/src/app/page.tsx index df6e7058..04c7b531 100644 --- a/tradein-mvp/frontend/src/app/page.tsx +++ b/tradein-mvp/frontend/src/app/page.tsx @@ -12,6 +12,7 @@ import { useQueryClient } from "@tanstack/react-query"; import "@/components/trade-in/trade-in.css"; import type { AggregatedEstimate, TradeInEstimateInput, HouseType, RepairState } from "@/types/trade-in"; import { useEstimateMutation, useEstimate } from "@/lib/trade-in-api"; +import { HTTPError } from "@/lib/api"; import { EstimateForm } from "@/components/trade-in/EstimateForm"; import { Topbar } from "@/components/trade-in/Topbar"; import { SourcesProgress } from "@/components/trade-in/SourcesProgress"; @@ -127,6 +128,16 @@ export default function TradeInPage() { } : null); + // #822: restore по ?id= — отражаем загрузку/ошибку вместо молчаливого + // empty-state. Backend отдаёт 404 на missing/owner-mismatch/expired. + const restoreActive = urlEstimateId !== null && freshResult === null; + const restoreError = restoreActive && restoredEstimate.isError; + const restoreLoading = restoreActive && restoredEstimate.isPending; + const restoreNotFound = + restoreError && + restoredEstimate.error instanceof HTTPError && + restoredEstimate.error.status === 404; + // Надёжный input для «Что-если»: предпочитаем поля самой оценки (есть и при // restore по ?id=, где resultData.input — stub с нулями), откатываемся на input. // address/rooms обязательны для payload — берём из estimate, иначе из input. @@ -275,6 +286,36 @@ export default function TradeInPage() { + ) : restoreError ? ( +
+
+

+ {restoreNotFound + ? "Отчёт не найден или недоступен" + : "Не удалось загрузить отчёт"} +

+

+ {restoreNotFound + ? "Ссылка устарела, отчёт удалён или у вас нет к нему доступа." + : "Произошла ошибка при загрузке отчёта. Попробуйте ещё раз."} +

+ +
+
+ ) : restoreLoading ? ( +
+
+

+ Загрузка отчёта… +

+
+
) : (