From 94970bea6c47b8220dd976c05ead27e8e5fc2e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Thu, 16 Jul 2026 19:41:51 +0200 Subject: [PATCH] Inline the gate-redirect helper in the boundaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolveGateRedirect only supplied window.location.href to gateRedirectPath from two call sites; drop the extra indirection and call gateRedirectPath directly in the root and page error boundaries. Signed-off-by: Émile Ré --- .../components/errors/PageErrorBoundary.tsx | 5 ++-- .../components/errors/RootErrorBoundary.tsx | 5 ++-- .../components/errors/resolveGateRedirect.ts | 30 ------------------- 3 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 apps/compliance-portal/src/components/errors/resolveGateRedirect.ts diff --git a/apps/compliance-portal/src/components/errors/PageErrorBoundary.tsx b/apps/compliance-portal/src/components/errors/PageErrorBoundary.tsx index 41f581a97..ff0c3ee86 100644 --- a/apps/compliance-portal/src/components/errors/PageErrorBoundary.tsx +++ b/apps/compliance-portal/src/components/errors/PageErrorBoundary.tsx @@ -14,8 +14,9 @@ import { Navigate, useRouteError } from "react-router"; +import { gateRedirectPath } from "#/lib/auth/continueUrl"; + import { GlobalError } from "./GlobalError"; -import { resolveGateRedirect } from "./resolveGateRedirect"; // Child-route boundary: a page failure is contained to the layout's Outlet, so // the error renders inside the app chrome (TopBar + footer survive). @@ -24,7 +25,7 @@ export function PageErrorBoundary() { // Full-name / NDA gates are recoverable: send the user to the gate page and // return them here afterwards, instead of showing an error. - const gateRedirect = resolveGateRedirect(error); + const gateRedirect = gateRedirectPath(error, window.location.href); if (gateRedirect) { return ; } diff --git a/apps/compliance-portal/src/components/errors/RootErrorBoundary.tsx b/apps/compliance-portal/src/components/errors/RootErrorBoundary.tsx index 8a95f8a25..8cf783e14 100644 --- a/apps/compliance-portal/src/components/errors/RootErrorBoundary.tsx +++ b/apps/compliance-portal/src/components/errors/RootErrorBoundary.tsx @@ -14,8 +14,9 @@ import { Navigate, useRouteError } from "react-router"; +import { gateRedirectPath } from "#/lib/auth/continueUrl"; + import { GlobalError } from "./GlobalError"; -import { resolveGateRedirect } from "./resolveGateRedirect"; // Root route boundary: a failure in the layout (or anything above the page // boundaries) takes down the whole tree, so it renders a standalone full-page @@ -25,7 +26,7 @@ export function RootErrorBoundary() { // Full-name / NDA gates are recoverable: send the user to the gate page and // return them here afterwards, instead of showing an error. - const gateRedirect = resolveGateRedirect(error); + const gateRedirect = gateRedirectPath(error, window.location.href); if (gateRedirect) { return ; } diff --git a/apps/compliance-portal/src/components/errors/resolveGateRedirect.ts b/apps/compliance-portal/src/components/errors/resolveGateRedirect.ts deleted file mode 100644 index 10bb13d19..000000000 --- a/apps/compliance-portal/src/components/errors/resolveGateRedirect.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2026 Probo Inc . -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -import { gateRedirectPath } from "#/lib/auth/continueUrl"; - -// Maps a caught gate error to the route that resolves it, carrying the current -// URL as a `continue` target so the user returns here once the gate is cleared. -// Returns a router-relative path (basename applied by the router); the target -// page validates the continue URL via getSafeContinueUrl. Returns null for any -// other error so the boundary can fall through to its normal error UI. -export function resolveGateRedirect(error: unknown): string | null { - return gateRedirectPath(error, window.location.href); -}