diff --git a/apps/console/src/components/OrganizationErrorBoundary.tsx b/apps/console/src/components/OrganizationErrorBoundary.tsx
new file mode 100644
index 000000000..70f7bfe97
--- /dev/null
+++ b/apps/console/src/components/OrganizationErrorBoundary.tsx
@@ -0,0 +1,22 @@
+import { AssumptionRequiredError, UnAuthenticatedError } from "@probo/relay";
+import { Navigate, useLocation, useRouteError } from "react-router";
+
+import { useOrganizationId } from "#/hooks/useOrganizationId";
+
+import { PageError } from "./PageError";
+
+export function OrganizationErrorBoundary() {
+ const error = useRouteError();
+ const location = useLocation();
+ const organizationId = useOrganizationId();
+
+ if (error instanceof UnAuthenticatedError) {
+ return ;
+ }
+
+ if (error instanceof AssumptionRequiredError) {
+ return ;
+ }
+
+ return ;
+}
diff --git a/apps/console/src/components/RootErrorBoundary.tsx b/apps/console/src/components/RootErrorBoundary.tsx
new file mode 100644
index 000000000..a6f698230
--- /dev/null
+++ b/apps/console/src/components/RootErrorBoundary.tsx
@@ -0,0 +1,15 @@
+import { UnAuthenticatedError } from "@probo/relay";
+import { Navigate, useLocation, useRouteError } from "react-router";
+
+import { PageError } from "./PageError";
+
+export function RootErrorBoundary() {
+ const error = useRouteError();
+ const location = useLocation();
+
+ if (error instanceof UnAuthenticatedError) {
+ return ;
+ }
+
+ return ;
+}
diff --git a/apps/console/src/routes.tsx b/apps/console/src/routes.tsx
index cfcbdea6b..51589f5cb 100644
--- a/apps/console/src/routes.tsx
+++ b/apps/console/src/routes.tsx
@@ -1,9 +1,5 @@
import { Role } from "@probo/helpers";
import { lazy } from "@probo/react-lazy";
-import {
- AssumptionRequiredError,
- UnAuthenticatedError,
-} from "@probo/relay";
import { type AppRoute, routeFromAppRoute } from "@probo/routes";
import { CenteredLayout } from "@probo/ui";
import { use } from "react";
@@ -11,10 +7,11 @@ import {
createBrowserRouter,
Navigate,
redirect,
- useRouteError,
} from "react-router";
+import { OrganizationErrorBoundary } from "./components/OrganizationErrorBoundary";
import { PageError } from "./components/PageError";
+import { RootErrorBoundary } from "./components/RootErrorBoundary";
import { PageSkeleton } from "./components/skeletons/PageSkeleton";
import { ViewerLayoutLoading } from "./pages/iam/memberships/ViewerLayoutLoading";
import { compliancePageRoutes } from "./pages/organizations/compliance-page/routes";
@@ -38,24 +35,6 @@ import { statesOfApplicabilityRoutes } from "./routes/statesOfApplicabilityRoute
import { taskRoutes } from "./routes/taskRoutes";
import { vendorRoutes } from "./routes/vendorRoutes";
-/**
- * Top level error boundary
- */
-function ErrorBoundary() {
- const error = useRouteError();
-
- if (error instanceof UnAuthenticatedError) {
- return ;
- }
-
- if (error instanceof AssumptionRequiredError) {
- // TODO redirect to right URL
- return ;
- }
-
- return ;
-}
-
const routes = [
{
path: "/auth",
@@ -101,7 +80,7 @@ const routes = [
},
{
path: "/",
- ErrorBoundary: ErrorBoundary,
+ ErrorBoundary: RootErrorBoundary,
children: [
{
Component: lazy(() => import("./pages/iam/memberships/ViewerLayoutLoader")),
@@ -136,7 +115,7 @@ const routes = [
},
{
path: "documents/signing-requests",
- ErrorBoundary: ErrorBoundary,
+ ErrorBoundary: RootErrorBoundary,
Component: lazy(
() => import("./pages/DocumentSigningRequestsPage"),
),
@@ -146,7 +125,7 @@ const routes = [
Component: lazy(
() => import("./pages/organizations/employee/EmployeeLayoutLoader"),
),
- ErrorBoundary: ErrorBoundary,
+ ErrorBoundary: OrganizationErrorBoundary,
children: [
{
index: true,
@@ -157,7 +136,6 @@ const routes = [
},
{
path: ":documentId",
- ErrorBoundary: ErrorBoundary,
Component: lazy(
() =>
import("./pages/organizations/employee/EmployeeDocumentSignaturePageLoader"),
@@ -170,7 +148,7 @@ const routes = [
Component: lazy(
() => import("./pages/iam/organizations/ViewerMembershipLayoutLoader"),
),
- ErrorBoundary: ErrorBoundary,
+ ErrorBoundary: OrganizationErrorBoundary,
children: [
{
path: "",