From f597beaa00a458f3093071f37845d9f2ef656376 Mon Sep 17 00:00:00 2001 From: Nathalie Kuoch Date: Wed, 27 Mar 2024 16:50:24 +0100 Subject: [PATCH] Prevent opening vbba modal if offline --- src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index f81dd908131a..ee47750663bc 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -75,7 +75,8 @@ function WorkspaceWorkflowsPage({policy, betas, route, session}: WorkspaceWorkfl navigateToBankAccountRoute(route.params.policyID, ROUTES.WORKSPACE_WORKFLOWS.getRoute(route.params.policyID)); }, [policy, route.params.policyID]); - useNetwork({onReconnect: fetchData}); + const {isOffline} = useNetwork({onReconnect: fetchData}); + const isPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); useEffect(() => { fetchData(); @@ -189,13 +190,16 @@ function WorkspaceWorkflowsPage({policy, betas, route, session}: WorkspaceWorkfl } description={bankDisplayName} onPress={() => { + if (isOffline || !isPolicyAdmin) { + return; + } if (!Policy.isCurrencySupportedForDirectReimbursement(policy?.outputCurrency ?? '')) { setIsCurrencyModalOpen(true); return; } navigateToBankAccountRoute(route.params.policyID, ROUTES.WORKSPACE_WORKFLOWS.getRoute(route.params.policyID)); }} - shouldShowRightIcon + shouldShowRightIcon={!isOffline && isPolicyAdmin} wrapperStyle={containerStyle} hoverAndPressStyle={[styles.mr0, styles.br2]} /> @@ -262,7 +266,6 @@ function WorkspaceWorkflowsPage({policy, betas, route, session}: WorkspaceWorkfl ); const isPaidGroupPolicy = PolicyUtils.isPaidGroupPolicy(policy); - const isPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); const isLoading = Boolean(policy?.isLoading && policy?.reimbursementChoice === undefined); return (