From 4a19ccf946556cbefcfc9bcaa9572f6dd0a0b1cd Mon Sep 17 00:00:00 2001 From: lekss361 Date: Mon, 18 May 2026 02:30:45 +0300 Subject: [PATCH] fix(sf-fe): decode cad URL param + hide entry sidebar when drawer open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two prod issues: 1. Analysis page B5 endpoint returned HTTP 400 'Неверный формат кадастрового номера' for any cad. Next.js dynamic route delivers `params.cad` URL-encoded (':' -> '%3A'). Hooks then ran encodeURIComponent on the already-encoded string, producing /api/v1/parcels/66%253A41%253A0204016%253A10/analyze; FastAPI decoded one layer to '66%3A41%3A0204016%3A10', which the regex rejected. Fix: decodeURIComponent the param once at the page boundary so downstream consumers (hooks + breadcrumb + Section1) work with the canonical '66:41:0204016:10' and encode exactly once when building URLs. Also resolves the breadcrumb double- encode noted in PR #346 QA. 2. Entry page right-sidebar (CadInput + RecentParcels + ParcelLegend) visually overlapped the ParcelDrawer slide-in: both were anchored to the right edge with the drawer rendered above as an overlay without an opaque backdrop on the sidebar area. Conditional render: sidebar only mounts when no parcel is selected, so opening a parcel gives the drawer a clean right column. --- .../app/site-finder/analysis/[cad]/page.tsx | 9 +++-- frontend/src/app/site-finder/page.tsx | 34 ++++++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/site-finder/analysis/[cad]/page.tsx b/frontend/src/app/site-finder/analysis/[cad]/page.tsx index e73f256d..4b804421 100644 --- a/frontend/src/app/site-finder/analysis/[cad]/page.tsx +++ b/frontend/src/app/site-finder/analysis/[cad]/page.tsx @@ -75,8 +75,13 @@ interface PageProps { } export default function AnalysisPage({ params }: PageProps) { - // React 19: use() unwraps Promise params (app router pattern) - const { cad } = use(params); + // React 19: use() unwraps Promise params (app router pattern). + // Next.js delivers `cad` URL-encoded (":" -> "%3A"); decode once here so + // downstream hooks/components see the canonical "66:41:0204016:10" and can + // re-encode exactly once when building API URLs / hrefs (prevents double- + // encode that made backend regex reject the cad with HTTP 400). + const { cad: cadRaw } = use(params); + const cad = decodeURIComponent(cadRaw); return (
- {/* Right sidebar */} -
- - - -
+ {/* Right sidebar — hidden when ParcelDrawer is open to avoid overlap */} + {selectedParcel == null && ( +
+ + + +
+ )} {/* Parcel drawer (slide-in from right) */}