From eba231e5b6d01f1b23cc133b272b046dcb5174b4 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Mon, 23 Sep 2024 07:34:05 +0200 Subject: [PATCH] Handle deeplinking to report with policyID in URL --- .../linkingConfig/getAdaptedStateFromPath.ts | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index 000759306c07..3d1727f71fa9 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -133,7 +133,8 @@ function getAdaptedState(state: PartialState // }; // We need to check what is defined to know what we need to add. - const WorkspaceNavigator = state.routes.find((route) => route.name === NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR); + const workspaceNavigator = state.routes.find((route) => route.name === NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR); + const reportNavigator = state.routes.find((route) => route.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR); const rhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR); const lhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.LEFT_MODAL_NAVIGATOR); const onboardingModalNavigator = state.routes.find((route) => route.name === NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR); @@ -219,7 +220,7 @@ function getAdaptedState(state: PartialState adaptedState: getRoutesWithIndex(routes), }; } - if (WorkspaceNavigator) { + if (workspaceNavigator) { // Routes // - default bottom tab // - default central pane on desktop layout @@ -238,7 +239,7 @@ function getAdaptedState(state: PartialState ), ); - routes.push(WorkspaceNavigator); + routes.push(workspaceNavigator); return { adaptedState: getRoutesWithIndex(routes), @@ -271,6 +272,19 @@ function getAdaptedState(state: PartialState } // We need to make sure that this if only handles states where we deeplink to the bottom tab directly + + // If policyID is defined, it should be passed to the reportNavigator params. + if (reportNavigator && policyID) { + const routes = []; + const reportNavigatorWithPolicyID = {...reportNavigator}; + reportNavigatorWithPolicyID.params = {...reportNavigatorWithPolicyID.params, policyID}; + routes.push(reportNavigatorWithPolicyID); + + return { + adaptedState: getRoutesWithIndex(routes), + }; + } + return { adaptedState: state, };