From 0b756923cc584047580a6a35590c4e29d5594a1e Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Sun, 24 Mar 2024 16:35:50 -0700 Subject: [PATCH 1/4] feat: add the new section for accounting connection on More Features page --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 2c8123670e0b..6f382102f703 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -100,6 +100,21 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro }, ]; + const integrateItems: Item[] = [ + { + icon: Illustrations.Accounting, + titleTranslationKey: 'workspace.moreFeatures.connections.title', + subtitleTranslationKey: 'workspace.moreFeatures.connections.subtitle', + //TODO: Look at the policy connection object? + isActive: false, + pendingAction: policy?.pendingFields?.tax, //TODO: which pending field? + action: (isEnabled: boolean) => { + //TODO: should be a function to enable the connection feature? + Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); + }, + }, + ]; + const sections: SectionObject[] = [ { titleTranslationKey: 'workspace.moreFeatures.spendSection.title', @@ -111,6 +126,11 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro subtitleTranslationKey: 'workspace.moreFeatures.organizeSection.subtitle', items: organizeItems, }, + { + titleTranslationKey: 'workspace.moreFeatures.integrateSection.title', + subtitleTranslationKey: 'workspace.moreFeatures.integrateSection.subtitle', + items: integrateItems, + }, ]; const renderItem = useCallback( From 2b705a9c8c000be22dd9541b21004c134882cdd8 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 28 Mar 2024 11:58:23 -0700 Subject: [PATCH 2/4] chore: read `areConnectionsEnabled` value & use `enablePolicyConnections` --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 6f382102f703..be3779d0b97b 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -105,12 +105,10 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro icon: Illustrations.Accounting, titleTranslationKey: 'workspace.moreFeatures.connections.title', subtitleTranslationKey: 'workspace.moreFeatures.connections.subtitle', - //TODO: Look at the policy connection object? - isActive: false, - pendingAction: policy?.pendingFields?.tax, //TODO: which pending field? + isActive: !!policy?.areConnectionsEnabled, + pendingAction: policy?.pendingFields?.connections, action: (isEnabled: boolean) => { - //TODO: should be a function to enable the connection feature? - Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); + Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); }, }, ]; From 42efe87c77a9f30e250f992107d27b732e95c8ce Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 28 Mar 2024 12:01:26 -0700 Subject: [PATCH 3/4] chore: check for the beta flag --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index be3779d0b97b..618758c31718 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -8,6 +8,7 @@ import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import type {WorkspacesCentralPaneNavigatorParamList} from '@libs/Navigation/types'; @@ -43,6 +44,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); + const {canUseAccountingIntegrations} = usePermissions(); const spendItems: Item[] = [ { @@ -124,12 +126,15 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro subtitleTranslationKey: 'workspace.moreFeatures.organizeSection.subtitle', items: organizeItems, }, - { + ]; + + if (canUseAccountingIntegrations) { + sections.push({ titleTranslationKey: 'workspace.moreFeatures.integrateSection.title', subtitleTranslationKey: 'workspace.moreFeatures.integrateSection.subtitle', items: integrateItems, - }, - ]; + }); + } const renderItem = useCallback( (item: Item) => ( From 4e25092af70ed3c6569ee1eda8f9b7635a81e4e2 Mon Sep 17 00:00:00 2001 From: Hayata Suenaga Date: Thu, 28 Mar 2024 14:21:13 -0700 Subject: [PATCH 4/4] fix: offline behavior --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 618758c31718..c717c4a2f14e 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -108,7 +108,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.connections.title', subtitleTranslationKey: 'workspace.moreFeatures.connections.subtitle', isActive: !!policy?.areConnectionsEnabled, - pendingAction: policy?.pendingFields?.connections, + pendingAction: policy?.pendingFields?.areConnectionsEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); },