Skip to content

Commit

Permalink
Prevent opening vbba modal if offline
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuoch committed Mar 27, 2024
1 parent 354a2f6 commit f597bea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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]}
/>
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit f597bea

Please sign in to comment.