From d6fdc99cc86d4f34a8896a98f162017ca9160ae5 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 28 Feb 2024 18:17:22 +0100 Subject: [PATCH 01/44] add strings --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index cf8823f5b2be..62c9d5d09f78 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1732,6 +1732,7 @@ export default { workspaceType: 'Workspace type', workspaceAvatar: 'Workspace avatar', mustBeOnlineToViewMembers: 'You must be online in order to view members of this workspace.', + features: 'Features', }, type: { free: 'Free', diff --git a/src/languages/es.ts b/src/languages/es.ts index b3a8eef73d7c..96f4bbb710fd 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1756,6 +1756,7 @@ export default { workspaceType: 'Tipo de espacio de trabajo', workspaceAvatar: 'Espacio de trabajo avatar', mustBeOnlineToViewMembers: 'Debes estar en línea para poder ver los miembros de este espacio de trabajo.', + features: 'Características', }, type: { free: 'Gratis', From 042ddb9b5a180b7a2e4d759392f49068f7818fa6 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 28 Feb 2024 18:17:40 +0100 Subject: [PATCH 02/44] Implement draft page --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 src/pages/workspace/WorkspaceMoreFeaturesPage.tsx diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx new file mode 100644 index 000000000000..8cc6e7ef4670 --- /dev/null +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -0,0 +1,94 @@ +import type {StackScreenProps} from '@react-navigation/stack'; +import React, {useMemo} from 'react'; +import {FlatList, View} from 'react-native'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import * as Illustrations from '@components/Icon/Illustrations'; +import ScreenWrapper from '@components/ScreenWrapper'; +import Text from '@components/Text'; +import WorkspaceEmptyStateSection from '@components/WorkspaceEmptyStateSection'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; +import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; +import type SCREENS from '@src/SCREENS'; +import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; +import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; +import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; + +type WorkspaceMoreFeaturesPageProps = StackScreenProps; + +type FeatureForList = { + value: string; + text: string; + keyForList: string; + isSelected: boolean; +}; + +function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { + const styles = useThemeStyles(); + const {isSmallScreenWidth} = useWindowDimensions(); + const {translate} = useLocalize(); + + const featureList = useMemo( + () => + [].map((name, index) => ({ + // ['Feature 1', 'Feature 2', 'Feature 3'].map((name, index) => ({ + value: name, + text: name, + keyForList: name, + isSelected: index % 2 === 0, + })), + [], + ); + + return ( + + + + + + + Page subtitle... + + + {featureList.length ? ( + item.keyForList} + data={featureList} + renderItem={({item}) => ( + {}} + isActive={false} + /> + )} + /> + ) : ( + + )} + + + + ); +} + +WorkspaceMoreFeaturesPage.displayName = 'WorkspaceMoreFeaturesPage'; + +export default WorkspaceMoreFeaturesPage; From f0d0feafd8f0d18cb4a37bd48bac06aa45bf9ba3 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 28 Feb 2024 18:17:51 +0100 Subject: [PATCH 03/44] connect the page --- src/ROUTES.ts | 4 ++++ src/SCREENS.ts | 1 + src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx | 1 + .../CentralPaneNavigator/BaseCentralPaneNavigator.tsx | 1 + .../Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 3 +++ src/libs/Navigation/types.ts | 3 +++ src/pages/workspace/WorkspaceInitialPage.tsx | 6 ++++++ 8 files changed, 20 insertions(+) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 22ebffd52eec..6d0a5b48abe2 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -530,6 +530,10 @@ const ROUTES = { route: 'workspace/:policyID/categories/settings', getRoute: (policyID: string) => `workspace/${policyID}/categories/settings` as const, }, + WORKSPACE_MORE_FEATURES: { + route: 'workspace/:policyID/more-features', + getRoute: (policyID: string) => `workspace/${policyID}/more-features` as const, + }, // Referral program promotion REFERRAL_DETAILS_MODAL: { diff --git a/src/SCREENS.ts b/src/SCREENS.ts index ac75968e68b9..c12eede4e23a 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -220,6 +220,7 @@ const SCREENS = { SHARE: 'Workspace_Profile_Share', NAME: 'Workspace_Profile_Name', CATEGORIES_SETTINGS: 'Categories_Settings', + MORE_FEATURES: 'More_Features', }, EDIT_REQUEST: { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 3d0144d8cf77..b022f7d886e2 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -249,6 +249,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/WorkspaceProfileSharePage').default as React.ComponentType, [SCREENS.WORKSPACE.CURRENCY]: () => require('../../../pages/workspace/WorkspaceProfileCurrencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORIES_SETTINGS]: () => require('../../../pages/workspace/categories/WorkspaceCategoriesSettingsPage').default as React.ComponentType, + [SCREENS.WORKSPACE.MORE_FEATURES]: () => require('../../../pages/workspace/WorkspaceMoreFeaturesPage').default as React.ComponentType, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../pages/ReimbursementAccount/ReimbursementAccountPage').default as React.ComponentType, [SCREENS.GET_ASSISTANCE]: () => require('../../../pages/GetAssistancePage').default as React.ComponentType, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default as React.ComponentType, diff --git a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx index 1e5d3639a32f..4dbb049bf9bb 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx @@ -24,6 +24,7 @@ const workspaceSettingsScreens = { [SCREENS.WORKSPACE.TRAVEL]: () => require('../../../../../pages/workspace/travel/WorkspaceTravelPage').default as React.ComponentType, [SCREENS.WORKSPACE.MEMBERS]: () => require('../../../../../pages/workspace/WorkspaceMembersPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORIES]: () => require('../../../../../pages/workspace/categories/WorkspaceCategoriesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.MORE_FEATURES]: () => require('../../../../../pages/workspace/WorkspaceMoreFeaturesPage').default as React.ComponentType, } satisfies Screens; function BaseCentralPaneNavigator() { diff --git a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts index f4316009b70b..68fe6aa9b227 100755 --- a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts @@ -14,6 +14,7 @@ const TAB_TO_CENTRAL_PANE_MAPPING: Record = { SCREENS.WORKSPACE.TRAVEL, SCREENS.WORKSPACE.MEMBERS, SCREENS.WORKSPACE.CATEGORIES, + SCREENS.WORKSPACE.MORE_FEATURES, ], }; diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 7a6211ebd283..fa685f780017 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -67,6 +67,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.CATEGORIES]: { path: ROUTES.WORKSPACE_CATEGORIES.route, }, + [SCREENS.WORKSPACE.MORE_FEATURES]: { + path: ROUTES.WORKSPACE_MORE_FEATURES.route, + }, }, }, [SCREENS.NOT_FOUND]: '*', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index a997e783deb0..2f38e61c23f3 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -81,6 +81,9 @@ type CentralPaneNavigatorParamList = { [SCREENS.WORKSPACE.CATEGORIES]: { policyID: string; }; + [SCREENS.WORKSPACE.MORE_FEATURES]: { + policyID: string; + }; }; type WorkspaceSwitcherNavigatorParamList = { diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 571e4cafce74..3b7b770d124b 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -169,6 +169,12 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.CATEGORIES, }, + { + translationKey: 'workspace.common.features', + icon: Expensicons.Checkmark, + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)))), + routeName: SCREENS.WORKSPACE.MORE_FEATURES, + }, ]; const menuItems: WorkspaceMenuItem[] = [ From f46fa4fcef884088fb99602b850423ee74196e2e Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 29 Feb 2024 10:47:03 +0100 Subject: [PATCH 04/44] update strings --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- src/pages/workspace/WorkspaceInitialPage.tsx | 2 +- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 2a279b1cf376..a1019c70c22b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1732,7 +1732,7 @@ export default { workspaceType: 'Workspace type', workspaceAvatar: 'Workspace avatar', mustBeOnlineToViewMembers: 'You must be online in order to view members of this workspace.', - features: 'Features', + moreFeatures: 'More features', }, type: { free: 'Free', diff --git a/src/languages/es.ts b/src/languages/es.ts index 8a16b740e1ae..6749c0690de9 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1756,7 +1756,7 @@ export default { workspaceType: 'Tipo de espacio de trabajo', workspaceAvatar: 'Espacio de trabajo avatar', mustBeOnlineToViewMembers: 'Debes estar en línea para poder ver los miembros de este espacio de trabajo.', - features: 'Características', + moreFeatures: 'Más características', }, type: { free: 'Gratis', diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 3b7b770d124b..4ad8d1936aee 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -170,7 +170,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r routeName: SCREENS.WORKSPACE.CATEGORIES, }, { - translationKey: 'workspace.common.features', + translationKey: 'workspace.common.moreFeatures', icon: Expensicons.Checkmark, action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.MORE_FEATURES, diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 8cc6e7ef4670..f036ec60f077 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -52,7 +52,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { > From a00866aacf877a04a23dfd522e00d811032f39e0 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 29 Feb 2024 16:44:08 +0100 Subject: [PATCH 05/44] add icons --- .../simple-illustration__accounting.svg | 32 +++++++++++++++++++ .../simple-illustration__car.svg | 25 +++++++++++++++ .../simple-illustration__coins.svg | 26 +++++++++++++++ .../simple-illustration__pencil.svg | 20 ++++++++++++ .../simple-illustration__tag.svg | 15 +++++++++ src/components/Icon/Illustrations.ts | 10 ++++++ 6 files changed, 128 insertions(+) create mode 100644 assets/images/simple-illustrations/simple-illustration__accounting.svg create mode 100644 assets/images/simple-illustrations/simple-illustration__car.svg create mode 100644 assets/images/simple-illustrations/simple-illustration__coins.svg create mode 100644 assets/images/simple-illustrations/simple-illustration__pencil.svg create mode 100644 assets/images/simple-illustrations/simple-illustration__tag.svg diff --git a/assets/images/simple-illustrations/simple-illustration__accounting.svg b/assets/images/simple-illustrations/simple-illustration__accounting.svg new file mode 100644 index 000000000000..f7634141e966 --- /dev/null +++ b/assets/images/simple-illustrations/simple-illustration__accounting.svg @@ -0,0 +1,32 @@ + diff --git a/assets/images/simple-illustrations/simple-illustration__car.svg b/assets/images/simple-illustrations/simple-illustration__car.svg new file mode 100644 index 000000000000..2d420be6c3a9 --- /dev/null +++ b/assets/images/simple-illustrations/simple-illustration__car.svg @@ -0,0 +1,25 @@ + diff --git a/assets/images/simple-illustrations/simple-illustration__coins.svg b/assets/images/simple-illustrations/simple-illustration__coins.svg new file mode 100644 index 000000000000..5350886402c6 --- /dev/null +++ b/assets/images/simple-illustrations/simple-illustration__coins.svg @@ -0,0 +1,26 @@ + diff --git a/assets/images/simple-illustrations/simple-illustration__pencil.svg b/assets/images/simple-illustrations/simple-illustration__pencil.svg new file mode 100644 index 000000000000..8d9f06991612 --- /dev/null +++ b/assets/images/simple-illustrations/simple-illustration__pencil.svg @@ -0,0 +1,20 @@ + diff --git a/assets/images/simple-illustrations/simple-illustration__tag.svg b/assets/images/simple-illustrations/simple-illustration__tag.svg new file mode 100644 index 000000000000..c8e431c89abb --- /dev/null +++ b/assets/images/simple-illustrations/simple-illustration__tag.svg @@ -0,0 +1,15 @@ + diff --git a/src/components/Icon/Illustrations.ts b/src/components/Icon/Illustrations.ts index e03b393dc81f..0d6c7ff3b451 100644 --- a/src/components/Icon/Illustrations.ts +++ b/src/components/Icon/Illustrations.ts @@ -28,12 +28,15 @@ import TadaBlue from '@assets/images/product-illustrations/tada--blue.svg'; import TadaYellow from '@assets/images/product-illustrations/tada--yellow.svg'; import TeleScope from '@assets/images/product-illustrations/telescope.svg'; import ToddBehindCloud from '@assets/images/product-illustrations/todd-behind-cloud.svg'; +import Accounting from '@assets/images/simple-illustrations/simple-illustration__accounting.svg'; import Approval from '@assets/images/simple-illustrations/simple-illustration__approval.svg'; import BankArrow from '@assets/images/simple-illustrations/simple-illustration__bank-arrow.svg'; import BigRocket from '@assets/images/simple-illustrations/simple-illustration__bigrocket.svg'; import PinkBill from '@assets/images/simple-illustrations/simple-illustration__bill.svg'; +import Car from '@assets/images/simple-illustrations/simple-illustration__car.svg'; import ChatBubbles from '@assets/images/simple-illustrations/simple-illustration__chatbubbles.svg'; import CoffeeMug from '@assets/images/simple-illustrations/simple-illustration__coffeemug.svg'; +import Coins from '@assets/images/simple-illustrations/simple-illustration__coins.svg'; import CommentBubbles from '@assets/images/simple-illustrations/simple-illustration__commentbubbles.svg'; import ConciergeBubble from '@assets/images/simple-illustrations/simple-illustration__concierge-bubble.svg'; import ConciergeNew from '@assets/images/simple-illustrations/simple-illustration__concierge.svg'; @@ -57,6 +60,7 @@ import MoneyIntoWallet from '@assets/images/simple-illustrations/simple-illustra import MoneyWings from '@assets/images/simple-illustrations/simple-illustration__moneywings.svg'; import OpenSafe from '@assets/images/simple-illustrations/simple-illustration__opensafe.svg'; import PalmTree from '@assets/images/simple-illustrations/simple-illustration__palmtree.svg'; +import Pencil from '@assets/images/simple-illustrations/simple-illustration__pencil.svg'; import Profile from '@assets/images/simple-illustrations/simple-illustration__profile.svg'; import QRCode from '@assets/images/simple-illustrations/simple-illustration__qr-code.svg'; import ReceiptEnvelope from '@assets/images/simple-illustrations/simple-illustration__receipt-envelope.svg'; @@ -64,6 +68,7 @@ import ReceiptWrangler from '@assets/images/simple-illustrations/simple-illustra import SanFrancisco from '@assets/images/simple-illustrations/simple-illustration__sanfrancisco.svg'; import ShieldYellow from '@assets/images/simple-illustrations/simple-illustration__shield.svg'; import SmallRocket from '@assets/images/simple-illustrations/simple-illustration__smallrocket.svg'; +import Tag from '@assets/images/simple-illustrations/simple-illustration__tag.svg'; import ThumbsUpStars from '@assets/images/simple-illustrations/simple-illustration__thumbsupstars.svg'; import TrackShoe from '@assets/images/simple-illustrations/simple-illustration__track-shoe.svg'; import TrashCan from '@assets/images/simple-illustrations/simple-illustration__trashcan.svg'; @@ -144,4 +149,9 @@ export { WalletAlt, Workflows, House, + Accounting, + Car, + Coins, + Pencil, + Tag, }; From a80209335dc2ab5366dcd80fc2e18b7acbcd352c Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 29 Feb 2024 16:44:26 +0100 Subject: [PATCH 06/44] use correct icons --- src/pages/workspace/WorkspaceInitialPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 4ad8d1936aee..94a1622c6e2f 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -171,7 +171,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r }, { translationKey: 'workspace.common.moreFeatures', - icon: Expensicons.Checkmark, + icon: Expensicons.Gear, action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.MORE_FEATURES, }, From a144cbe383e193bf22f1d06e4886d63ea09e6bc3 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 29 Feb 2024 16:44:51 +0100 Subject: [PATCH 07/44] build draft sections --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 190 +++++++++++++----- 1 file changed, 144 insertions(+), 46 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index f036ec60f077..b33c236f2915 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -1,11 +1,11 @@ +/* eslint-disable no-console */ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useMemo} from 'react'; -import {FlatList, View} from 'react-native'; +import {ScrollView, View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Illustrations from '@components/Icon/Illustrations'; import ScreenWrapper from '@components/ScreenWrapper'; -import Text from '@components/Text'; -import WorkspaceEmptyStateSection from '@components/WorkspaceEmptyStateSection'; +import Section from '@components/Section'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -13,34 +13,134 @@ import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import type SCREENS from '@src/SCREENS'; import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; +import type {ToggleSettingOptionRowProps} from './workflows/ToggleSettingsOptionRow'; import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; -type WorkspaceMoreFeaturesPageProps = StackScreenProps; +/** +areCategoriesEnabled +areTagsEnabled +areDistanceRatesEnabled +areWorkflowsEnabled +areReportFieldsEnabled +areConnectionsEnabled +tax.trackingEnabled (see above) +*/ -type FeatureForList = { - value: string; - text: string; - keyForList: string; - isSelected: boolean; -}; +type WorkspaceMoreFeaturesPageProps = StackScreenProps; function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); - const featureList = useMemo( - () => - [].map((name, index) => ({ - // ['Feature 1', 'Feature 2', 'Feature 3'].map((name, index) => ({ - value: name, - text: name, - keyForList: name, - isSelected: index % 2 === 0, - })), + const spendItems: ToggleSettingOptionRowProps[] = useMemo( + () => [ + { + icon: Illustrations.Car, + title: 'Distance rates', + subtitle: 'Add, update and enforce rates', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + { + icon: Illustrations.HandCard, + title: 'Expensify card', + subtitle: 'Gain insights and control over spend', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + { + icon: Illustrations.Workflows, + title: 'Workflows', + subtitle: 'Configure how spend is approved and paid', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + ], [], ); + const organizeItems: ToggleSettingOptionRowProps[] = useMemo( + () => [ + { + icon: Illustrations.FolderOpen, + title: 'Categories', + subtitle: 'Track and organize spend', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + { + icon: Illustrations.Tag, + title: 'Tags', + subtitle: 'Add additional ways to classify spend', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + { + icon: Illustrations.Coins, + title: 'Taxes', + subtitle: 'Document and reclaim eligible taxes.', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + { + icon: Illustrations.Pencil, + title: 'Report fields', + subtitle: 'Subtitle...', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + { + icon: Illustrations.Accounting, + title: 'Connections', + subtitle: 'Subtitle...', + onToggle: (isEnabled: boolean) => { + console.log('isEnabled', isEnabled); + }, + isActive: false, + pendingAction: undefined, + }, + ], + [], + ); + + const renderItem = (item: ToggleSettingOptionRowProps) => ( + + + + ); + return ( @@ -51,38 +151,36 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { shouldShowOfflineIndicatorInWideScreen > - - Page subtitle... - + + +
+ {spendItems.map(renderItem)} +
+
- {featureList.length ? ( - item.keyForList} - data={featureList} - renderItem={({item}) => ( - {}} - isActive={false} - /> - )} - /> - ) : ( - - )} + +
+ {organizeItems.map(renderItem)} +
+
+
From 719972cc03216e24e8b484400597d2bbccad360e Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 29 Feb 2024 16:59:11 +0100 Subject: [PATCH 08/44] add strings --- src/languages/en.ts | 42 ++++++++++++++++++ src/languages/es.ts | 42 ++++++++++++++++++ .../workspace/WorkspaceMoreFeaturesPage.tsx | 44 +++++++++---------- 3 files changed, 106 insertions(+), 22 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index a1019c70c22b..24cd17343b10 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1748,6 +1748,48 @@ export default { subtitle: 'Add a category to organize your spend.', }, }, + moreFeatures: { + spendSection: { + title: 'Spend', + subtitle: 'Enable optional functionality that helps you scale your team.', + }, + organizeSection: { + title: 'Organize', + subtitle: 'Group and analyze spend, record every tax paid.', + }, + distanceRates: { + title: 'Distance rates', + subtitle: 'Add, update and enforce rates.', + }, + expensifyCard: { + title: 'Expensify card', + subtitle: 'Gain insights and control over spend.', + }, + workflows: { + title: 'Workflows', + subtitle: 'Configure how spend is approved and paid.', + }, + categories: { + title: 'Categories', + subtitle: 'Track and organize spend.', + }, + tags: { + title: 'Tags', + subtitle: 'Add additional ways to classify spend.', + }, + taxes: { + title: 'Taxes', + subtitle: 'Document and reclaim eligible taxes.', + }, + reportFields: { + title: 'Report fields', + subtitle: 'Subtitle...', + }, + connections: { + title: 'Connections', + subtitle: 'Subtitle...', + }, + }, emptyWorkspace: { title: 'Create a workspace', subtitle: 'Workspaces are where you’ll chat with your team, reimburse expenses, issue cards, send invoices, pay bills, and more - all in one place.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 6749c0690de9..97d50d7ca214 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1772,6 +1772,48 @@ export default { subtitle: 'Añade una categoría para organizar tu gasto.', }, }, + moreFeatures: { + spendSection: { + title: 'Gastar', + subtitle: 'Habilitar una funcionalidad opcional que lo ayude a escalar su equipo.', + }, + organizeSection: { + title: 'Organizar', + subtitle: 'Agrupar y analizar el gasto, registrar cada impuesto pagado.', + }, + distanceRates: { + title: 'Tasas de distancia', + subtitle: 'Agregar, actualizar y hacer cumplir las tarifas.', + }, + expensifyCard: { + title: 'Tarjeta de expensas', + subtitle: 'Obtener ideas y control sobre el gasto.', + }, + workflows: { + title: 'Flujos de trabajo', + subtitle: 'Configure cómo se aprueba y paga el gasto.', + }, + categories: { + title: 'Categorías', + subtitle: 'Rastrear y organizar el gasto.', + }, + tags: { + title: 'Etiquetas', + subtitle: 'Agregue formas adicionales de clasificar el gasto.', + }, + taxes: { + title: 'Impuestos', + subtitle: 'Documentar y reclamar impuestos elegibles.', + }, + reportFields: { + title: 'Campos de informes', + subtitle: 'Subtitle...', + }, + connections: { + title: 'Conexión', + subtitle: 'Subtitle...', + }, + }, emptyWorkspace: { title: 'Crea un espacio de trabajo', subtitle: 'En los espacios de trabajo podrás chatear con tu equipo, reembolsar gastos, emitir tarjetas, enviar y pagar facturas, y mucho más - todo en un mismo lugar.', diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index b33c236f2915..47dd45d51670 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -37,8 +37,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { () => [ { icon: Illustrations.Car, - title: 'Distance rates', - subtitle: 'Add, update and enforce rates', + title: translate('workspace.moreFeatures.distanceRates.title'), + subtitle: translate('workspace.moreFeatures.distanceRates.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -47,8 +47,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { }, { icon: Illustrations.HandCard, - title: 'Expensify card', - subtitle: 'Gain insights and control over spend', + title: translate('workspace.moreFeatures.expensifyCard.title'), + subtitle: translate('workspace.moreFeatures.expensifyCard.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -57,8 +57,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { }, { icon: Illustrations.Workflows, - title: 'Workflows', - subtitle: 'Configure how spend is approved and paid', + title: translate('workspace.moreFeatures.workflows.title'), + subtitle: translate('workspace.moreFeatures.workflows.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -66,15 +66,15 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { pendingAction: undefined, }, ], - [], + [translate], ); const organizeItems: ToggleSettingOptionRowProps[] = useMemo( () => [ { icon: Illustrations.FolderOpen, - title: 'Categories', - subtitle: 'Track and organize spend', + title: translate('workspace.moreFeatures.categories.title'), + subtitle: translate('workspace.moreFeatures.categories.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -83,8 +83,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { }, { icon: Illustrations.Tag, - title: 'Tags', - subtitle: 'Add additional ways to classify spend', + title: translate('workspace.moreFeatures.tags.title'), + subtitle: translate('workspace.moreFeatures.tags.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -93,8 +93,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { }, { icon: Illustrations.Coins, - title: 'Taxes', - subtitle: 'Document and reclaim eligible taxes.', + title: translate('workspace.moreFeatures.taxes.title'), + subtitle: translate('workspace.moreFeatures.taxes.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -103,8 +103,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { }, { icon: Illustrations.Pencil, - title: 'Report fields', - subtitle: 'Subtitle...', + title: translate('workspace.moreFeatures.reportFields.title'), + subtitle: translate('workspace.moreFeatures.reportFields.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -113,8 +113,8 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { }, { icon: Illustrations.Accounting, - title: 'Connections', - subtitle: 'Subtitle...', + title: translate('workspace.moreFeatures.connections.title'), + subtitle: translate('workspace.moreFeatures.connections.subtitle'), onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, @@ -122,7 +122,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { pendingAction: undefined, }, ], - [], + [translate], ); const renderItem = (item: ToggleSettingOptionRowProps) => ( @@ -160,9 +160,9 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) {
{spendItems.map(renderItem)} @@ -172,9 +172,9 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) {
{organizeItems.map(renderItem)} From 7849b7fb1b9bc78be099b990fb713550aedabb38 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 1 Mar 2024 17:03:48 +0100 Subject: [PATCH 09/44] add strings --- src/languages/en.ts | 8 ++++++-- src/languages/es.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 71768935e174..467061b59bfb 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1760,6 +1760,10 @@ export default { title: 'Organize', subtitle: 'Group and analyze spend, record every tax paid.', }, + integrateSection: { + title: 'Integrate', + subtitle: 'Connect Expensify to popular financial products.', + }, distanceRates: { title: 'Distance rates', subtitle: 'Add, update and enforce rates.', @@ -1786,11 +1790,11 @@ export default { }, reportFields: { title: 'Report fields', - subtitle: 'Subtitle...', + subtitle: 'Set up custom fields for spend.', }, connections: { title: 'Connections', - subtitle: 'Subtitle...', + subtitle: 'Sync your chart of accounts and more.', }, }, emptyWorkspace: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 2764d0596125..6c594cd849ca 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1784,6 +1784,10 @@ export default { title: 'Organizar', subtitle: 'Agrupar y analizar el gasto, registrar cada impuesto pagado.', }, + integrateSection: { + title: 'Integrar', + subtitle: 'Conectar gastos de expensización a productos financieros populares.', + }, distanceRates: { title: 'Tasas de distancia', subtitle: 'Agregar, actualizar y hacer cumplir las tarifas.', @@ -1810,11 +1814,11 @@ export default { }, reportFields: { title: 'Campos de informes', - subtitle: 'Subtitle...', + subtitle: 'Configurar campos personalizados para gastar.', }, connections: { title: 'Conexión', - subtitle: 'Subtitle...', + subtitle: 'Sincronice su gráfico de cuentas y más.', }, }, emptyWorkspace: { From 08e89a4037820ba4cd97577f078b1b0b9c39f424 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 1 Mar 2024 17:04:10 +0100 Subject: [PATCH 10/44] implement integrate section --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 47dd45d51670..3b227b410f39 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -111,6 +111,12 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { isActive: false, pendingAction: undefined, }, + ], + [translate], + ); + + const integrateItems: ToggleSettingOptionRowProps[] = useMemo( + () => [ { icon: Illustrations.Accounting, title: translate('workspace.moreFeatures.connections.title'), @@ -180,6 +186,18 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { {organizeItems.map(renderItem)}
+ + +
+ {integrateItems.map(renderItem)} +
+
From 82a78036aef1258a4e7724be23e6ce2e51fdf848 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 1 Mar 2024 17:09:15 +0100 Subject: [PATCH 11/44] integrate section renderer --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 3b227b410f39..7f319ddf877f 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -131,6 +131,27 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { [translate], ); + const sections = useMemo( + () => [ + { + title: translate('workspace.moreFeatures.spendSection.title'), + subtitle: translate('workspace.moreFeatures.spendSection.subtitle'), + items: spendItems, + }, + { + title: translate('workspace.moreFeatures.organizeSection.title'), + subtitle: translate('workspace.moreFeatures.organizeSection.subtitle'), + items: organizeItems, + }, + { + title: translate('workspace.moreFeatures.integrateSection.title'), + subtitle: translate('workspace.moreFeatures.integrateSection.subtitle'), + items: integrateItems, + }, + ], + [integrateItems, organizeItems, spendItems, translate], + ); + const renderItem = (item: ToggleSettingOptionRowProps) => ( ); + const renderSection = (section: (typeof sections)[0]) => ( + +
+ {section.items.map(renderItem)} +
+
+ ); + return ( @@ -162,43 +200,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { shouldShowBackButton={isSmallScreenWidth} /> - - -
- {spendItems.map(renderItem)} -
-
- - -
- {organizeItems.map(renderItem)} -
-
- - -
- {integrateItems.map(renderItem)} -
-
-
+ {sections.map(renderSection)}
From c64d1a555a19aa227da11e1c909f96a1aa4ebc3d Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 1 Mar 2024 17:18:34 +0100 Subject: [PATCH 12/44] connect active values --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 7f319ddf877f..146cb6dab311 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -13,22 +13,14 @@ import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import type SCREENS from '@src/SCREENS'; import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; +import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; +import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; import type {ToggleSettingOptionRowProps} from './workflows/ToggleSettingsOptionRow'; import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; -/** -areCategoriesEnabled -areTagsEnabled -areDistanceRatesEnabled -areWorkflowsEnabled -areReportFieldsEnabled -areConnectionsEnabled -tax.trackingEnabled (see above) -*/ +type WorkspaceMoreFeaturesPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; -type WorkspaceMoreFeaturesPageProps = StackScreenProps; - -function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { +function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPageProps) { const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); @@ -42,7 +34,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.areDistanceRatesEnabled ?? false, pendingAction: undefined, }, { @@ -62,11 +54,11 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.areWorkflowsEnabled ?? false, pendingAction: undefined, }, ], - [translate], + [policy?.areDistanceRatesEnabled, policy?.areWorkflowsEnabled, translate], ); const organizeItems: ToggleSettingOptionRowProps[] = useMemo( @@ -78,7 +70,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.areCategoriesEnabled ?? false, pendingAction: undefined, }, { @@ -88,7 +80,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.areTagsEnabled ?? false, pendingAction: undefined, }, { @@ -98,7 +90,7 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.tax?.trackingEnabled ?? false, pendingAction: undefined, }, { @@ -108,11 +100,11 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.areReportFieldsEnabled ?? false, pendingAction: undefined, }, ], - [translate], + [policy?.areCategoriesEnabled, policy?.areReportFieldsEnabled, policy?.areTagsEnabled, policy?.tax?.trackingEnabled, translate], ); const integrateItems: ToggleSettingOptionRowProps[] = useMemo( @@ -124,11 +116,11 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { onToggle: (isEnabled: boolean) => { console.log('isEnabled', isEnabled); }, - isActive: false, + isActive: policy?.areConnectionsEnabled ?? false, pendingAction: undefined, }, ], - [translate], + [policy?.areConnectionsEnabled, translate], ); const sections = useMemo( @@ -209,4 +201,4 @@ function WorkspaceMoreFeaturesPage({route}: WorkspaceMoreFeaturesPageProps) { WorkspaceMoreFeaturesPage.displayName = 'WorkspaceMoreFeaturesPage'; -export default WorkspaceMoreFeaturesPage; +export default withPolicyAndFullscreenLoading(WorkspaceMoreFeaturesPage); From 7653ea8210dae78ac0a6c9398fc14d8985247df3 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Mon, 4 Mar 2024 13:30:13 +0100 Subject: [PATCH 13/44] remove expensify card option --- src/languages/en.ts | 4 ---- src/languages/es.ts | 4 ---- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 10 ---------- 3 files changed, 18 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index e782d486b1ff..1ec2108bbb72 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1786,10 +1786,6 @@ export default { title: 'Distance rates', subtitle: 'Add, update and enforce rates.', }, - expensifyCard: { - title: 'Expensify card', - subtitle: 'Gain insights and control over spend.', - }, workflows: { title: 'Workflows', subtitle: 'Configure how spend is approved and paid.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 12e2672ef67e..83f5eaa1e4f1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1810,10 +1810,6 @@ export default { title: 'Tasas de distancia', subtitle: 'Agregar, actualizar y hacer cumplir las tarifas.', }, - expensifyCard: { - title: 'Tarjeta de expensas', - subtitle: 'Obtener ideas y control sobre el gasto.', - }, workflows: { title: 'Flujos de trabajo', subtitle: 'Configure cómo se aprueba y paga el gasto.', diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 146cb6dab311..6207579272f1 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -37,16 +37,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro isActive: policy?.areDistanceRatesEnabled ?? false, pendingAction: undefined, }, - { - icon: Illustrations.HandCard, - title: translate('workspace.moreFeatures.expensifyCard.title'), - subtitle: translate('workspace.moreFeatures.expensifyCard.subtitle'), - onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); - }, - isActive: false, - pendingAction: undefined, - }, { icon: Illustrations.Workflows, title: translate('workspace.moreFeatures.workflows.title'), From 9a824a62bd7f30569caa36503d2abb2380999183 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Mon, 4 Mar 2024 15:18:36 +0100 Subject: [PATCH 14/44] integrate API commands --- .../EnablePolicyCategoriesParams.ts | 6 + .../EnablePolicyConnectionsParams.ts | 6 + .../EnablePolicyDistanceRatesParams.ts | 6 + .../EnablePolicyReportFieldsParams.ts | 6 + .../API/parameters/EnablePolicyTagsParams.ts | 6 + .../API/parameters/EnablePolicyTaxesParams.ts | 6 + .../parameters/EnablePolicyWorkflowsParams.ts | 6 + src/libs/API/parameters/index.ts | 7 + src/libs/API/types.ts | 14 + src/libs/actions/Policy.ts | 361 ++++++++++++++++++ .../workspace/WorkspaceMoreFeaturesPage.tsx | 71 ++-- 11 files changed, 470 insertions(+), 25 deletions(-) create mode 100644 src/libs/API/parameters/EnablePolicyCategoriesParams.ts create mode 100644 src/libs/API/parameters/EnablePolicyConnectionsParams.ts create mode 100644 src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts create mode 100644 src/libs/API/parameters/EnablePolicyReportFieldsParams.ts create mode 100644 src/libs/API/parameters/EnablePolicyTagsParams.ts create mode 100644 src/libs/API/parameters/EnablePolicyTaxesParams.ts create mode 100644 src/libs/API/parameters/EnablePolicyWorkflowsParams.ts diff --git a/src/libs/API/parameters/EnablePolicyCategoriesParams.ts b/src/libs/API/parameters/EnablePolicyCategoriesParams.ts new file mode 100644 index 000000000000..6d994f9dca37 --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyCategoriesParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyCategoriesParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyCategoriesParams; diff --git a/src/libs/API/parameters/EnablePolicyConnectionsParams.ts b/src/libs/API/parameters/EnablePolicyConnectionsParams.ts new file mode 100644 index 000000000000..312c93c42b30 --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyConnectionsParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyConnectionsParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyConnectionsParams; diff --git a/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts b/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts new file mode 100644 index 000000000000..18718670af25 --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyDistanceRatesParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyDistanceRatesParams; diff --git a/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts b/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts new file mode 100644 index 000000000000..341716563f53 --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyReportFieldsParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyReportFieldsParams; diff --git a/src/libs/API/parameters/EnablePolicyTagsParams.ts b/src/libs/API/parameters/EnablePolicyTagsParams.ts new file mode 100644 index 000000000000..f85fabd30f1f --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyTagsParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyTagsParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyTagsParams; diff --git a/src/libs/API/parameters/EnablePolicyTaxesParams.ts b/src/libs/API/parameters/EnablePolicyTaxesParams.ts new file mode 100644 index 000000000000..c180bab572b0 --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyTaxesParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyTaxesParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyTaxesParams; diff --git a/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts b/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts new file mode 100644 index 000000000000..ab472197f7b7 --- /dev/null +++ b/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts @@ -0,0 +1,6 @@ +type EnablePolicyWorkflowsParams = { + policyID: string; + isEnabled: boolean; +}; + +export default EnablePolicyWorkflowsParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 4fbc597b8186..eedfc6406f05 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -153,3 +153,10 @@ export type {default as SetWorkspaceAutoReportingFrequencyParams} from './SetWor export type {default as SetWorkspaceAutoReportingMonthlyOffsetParams} from './SetWorkspaceAutoReportingMonthlyOffsetParams'; export type {default as SetWorkspaceApprovalModeParams} from './SetWorkspaceApprovalModeParams'; export type {default as SwitchToOldDotParams} from './SwitchToOldDotParams'; +export type {default as EnablePolicyCategoriesParams} from './EnablePolicyCategoriesParams'; +export type {default as EnablePolicyConnectionsParams} from './EnablePolicyConnectionsParams'; +export type {default as EnablePolicyDistanceRatesParams} from './EnablePolicyDistanceRatesParams'; +export type {default as EnablePolicyTagsParams} from './EnablePolicyTagsParams'; +export type {default as EnablePolicyTaxesParams} from './EnablePolicyTaxesParams'; +export type {default as EnablePolicyWorkflowsParams} from './EnablePolicyWorkflowsParams'; +export type {default as EnablePolicyReportFieldsParams} from './EnablePolicyReportFieldsParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index ba49bc5fa27b..9a937a8cc2ff 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -156,6 +156,13 @@ const WRITE_COMMANDS = { CANCEL_PAYMENT: 'CancelPayment', ACCEPT_ACH_CONTRACT_FOR_BANK_ACCOUNT: 'AcceptACHContractForBankAccount', SWITCH_TO_OLD_DOT: 'SwitchToOldDot', + ENABLE_POLICY_CATEGORIES: 'EnablePolicyCategories', + ENABLE_POLICY_CONNECTIONS: 'EnablePolicyConnections', + ENABLE_POLICY_DISTANCE_RATES: 'EnablePolicyDistanceRates', + ENABLE_POLICY_TAGS: 'EnablePolicyTags', + ENABLE_POLICY_TAXES: 'EnablePolicyTaxes', + ENABLE_POLICY_WORKFLOWS: 'EnablePolicyWorkflows', + ENABLE_POLICY_REPORT_FIELDS: 'EnablePolicyReportFields', } as const; type WriteCommand = ValueOf; @@ -310,6 +317,13 @@ type WriteCommandParameters = { [WRITE_COMMANDS.SET_WORKSPACE_AUTO_REPORTING_MONTHLY_OFFSET]: Parameters.SetWorkspaceAutoReportingMonthlyOffsetParams; [WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE]: Parameters.SetWorkspaceApprovalModeParams; [WRITE_COMMANDS.SWITCH_TO_OLD_DOT]: Parameters.SwitchToOldDotParams; + [WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES]: Parameters.EnablePolicyCategoriesParams; + [WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS]: Parameters.EnablePolicyConnectionsParams; + [WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES]: Parameters.EnablePolicyDistanceRatesParams; + [WRITE_COMMANDS.ENABLE_POLICY_TAGS]: Parameters.EnablePolicyTagsParams; + [WRITE_COMMANDS.ENABLE_POLICY_TAXES]: Parameters.EnablePolicyTaxesParams; + [WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS]: Parameters.EnablePolicyWorkflowsParams; + [WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS]: Parameters.EnablePolicyReportFieldsParams; }; const READ_COMMANDS = { diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 313c4deb9934..99c47d80bf67 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -15,6 +15,13 @@ import type { DeleteMembersFromWorkspaceParams, DeleteWorkspaceAvatarParams, DeleteWorkspaceParams, + EnablePolicyCategoriesParams, + EnablePolicyConnectionsParams, + EnablePolicyDistanceRatesParams, + EnablePolicyReportFieldsParams, + EnablePolicyTagsParams, + EnablePolicyTaxesParams, + EnablePolicyWorkflowsParams, OpenDraftWorkspaceRequestParams, OpenWorkspaceInvitePageParams, OpenWorkspaceMembersPageParams, @@ -2487,6 +2494,353 @@ function clearCategoryErrors(policyID: string, categoryName: string) { }); } +function enablePolicyCategories(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areCategoriesEnabled: isEnabled, + pendingFields: { + areCategoriesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areCategoriesEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areCategoriesEnabled: !isEnabled, + pendingFields: { + areCategoriesEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyCategoriesParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES, parameters, { + optimisticData, + successData, + failureData, + }); +} + +function enablePolicyConnections(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areConnectionsEnabled: isEnabled, + pendingFields: { + areConnectionsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areConnectionsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areConnectionsEnabled: !isEnabled, + pendingFields: { + areConnectionsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyConnectionsParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS, parameters, { + optimisticData, + successData, + failureData, + }); +} + +function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areDistanceRatesEnabled: isEnabled, + pendingFields: { + areDistanceRatesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areDistanceRatesEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areDistanceRatesEnabled: !isEnabled, + pendingFields: { + areDistanceRatesEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyDistanceRatesParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES, parameters, { + optimisticData, + successData, + failureData, + }); +} + +function enablePolicyReportFields(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areReportFieldsEnabled: isEnabled, + pendingFields: { + areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areReportFieldsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areReportFieldsEnabled: !isEnabled, + pendingFields: { + areReportFieldsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyReportFieldsParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS, parameters, { + optimisticData, + successData, + failureData, + }); +} + +function enablePolicyTags(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areTagsEnabled: isEnabled, + pendingFields: { + areTagsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areTagsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areTagsEnabled: !isEnabled, + pendingFields: { + areTagsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyTagsParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_TAGS, parameters, { + optimisticData, + successData, + failureData, + }); +} + +function enablePolicyTaxes(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + tax: { + trackingEnabled: isEnabled, + }, + pendingFields: { + isTaxTrackingEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + isTaxTrackingEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + tax: { + trackingEnabled: !isEnabled, + }, + pendingFields: { + isTaxTrackingEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyTaxesParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_TAXES, parameters, { + optimisticData, + successData, + failureData, + }); +} + +function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areWorkflowsEnabled: isEnabled, + pendingFields: { + areWorkflowsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + ]; + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areWorkflowsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areWorkflowsEnabled: !isEnabled, + pendingFields: { + areWorkflowsEnabled: null, + }, + pendingAction: null, + }, + }, + ]; + + const parameters: EnablePolicyWorkflowsParams = {policyID, isEnabled}; + + API.write(WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS, parameters, { + optimisticData, + successData, + failureData, + }); +} + export { removeMembers, updateWorkspaceMembersRole, @@ -2536,4 +2890,11 @@ export { setWorkspaceCategoryEnabled, setWorkspaceRequiresCategory, clearCategoryErrors, + enablePolicyCategories, + enablePolicyConnections, + enablePolicyDistanceRates, + enablePolicyReportFields, + enablePolicyTags, + enablePolicyTaxes, + enablePolicyWorkflows, }; diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 6207579272f1..f09b74281b6c 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -10,6 +10,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; +import * as Policy from '@userActions/Policy'; import type SCREENS from '@src/SCREENS'; import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; @@ -31,24 +32,32 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro icon: Illustrations.Car, title: translate('workspace.moreFeatures.distanceRates.title'), subtitle: translate('workspace.moreFeatures.distanceRates.subtitle'), + isActive: policy?.areDistanceRatesEnabled ?? false, + pendingAction: policy?.pendingFields?.areDistanceRatesEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyDistanceRates(policy?.id ?? '', isEnabled); }, - isActive: policy?.areDistanceRatesEnabled ?? false, - pendingAction: undefined, }, { icon: Illustrations.Workflows, title: translate('workspace.moreFeatures.workflows.title'), subtitle: translate('workspace.moreFeatures.workflows.subtitle'), + isActive: policy?.areWorkflowsEnabled ?? false, + pendingAction: policy?.pendingFields?.areWorkflowsEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyWorkflows(policy?.id ?? '', isEnabled); }, - isActive: policy?.areWorkflowsEnabled ?? false, - pendingAction: undefined, }, ], - [policy?.areDistanceRatesEnabled, policy?.areWorkflowsEnabled, translate], + [ + policy?.areDistanceRatesEnabled, + policy?.areWorkflowsEnabled, + policy?.id, + policy?.pendingAction, + policy?.pendingFields?.areDistanceRatesEnabled, + policy?.pendingFields?.areWorkflowsEnabled, + translate, + ], ); const organizeItems: ToggleSettingOptionRowProps[] = useMemo( @@ -57,44 +66,56 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro icon: Illustrations.FolderOpen, title: translate('workspace.moreFeatures.categories.title'), subtitle: translate('workspace.moreFeatures.categories.subtitle'), + isActive: policy?.areCategoriesEnabled ?? false, + pendingAction: policy?.pendingFields?.areCategoriesEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyCategories(policy?.id ?? '', isEnabled); }, - isActive: policy?.areCategoriesEnabled ?? false, - pendingAction: undefined, }, { icon: Illustrations.Tag, title: translate('workspace.moreFeatures.tags.title'), subtitle: translate('workspace.moreFeatures.tags.subtitle'), + isActive: policy?.areTagsEnabled ?? false, + pendingAction: policy?.pendingFields?.areTagsEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyTags(policy?.id ?? '', isEnabled); }, - isActive: policy?.areTagsEnabled ?? false, - pendingAction: undefined, }, { icon: Illustrations.Coins, title: translate('workspace.moreFeatures.taxes.title'), subtitle: translate('workspace.moreFeatures.taxes.subtitle'), + isActive: policy?.tax?.trackingEnabled ?? false, + pendingAction: policy?.pendingFields?.isTaxTrackingEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); }, - isActive: policy?.tax?.trackingEnabled ?? false, - pendingAction: undefined, }, { icon: Illustrations.Pencil, title: translate('workspace.moreFeatures.reportFields.title'), subtitle: translate('workspace.moreFeatures.reportFields.subtitle'), + isActive: policy?.areReportFieldsEnabled ?? false, + pendingAction: policy?.pendingFields?.areReportFieldsEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyReportFields(policy?.id ?? '', isEnabled); }, - isActive: policy?.areReportFieldsEnabled ?? false, - pendingAction: undefined, }, ], - [policy?.areCategoriesEnabled, policy?.areReportFieldsEnabled, policy?.areTagsEnabled, policy?.tax?.trackingEnabled, translate], + [ + policy?.areCategoriesEnabled, + policy?.areReportFieldsEnabled, + policy?.areTagsEnabled, + policy?.id, + policy?.pendingAction, + policy?.pendingFields?.areCategoriesEnabled, + policy?.pendingFields?.areReportFieldsEnabled, + policy?.pendingFields?.areTagsEnabled, + policy?.pendingFields?.isTaxTrackingEnabled, + policy?.tax?.trackingEnabled, + translate, + ], ); const integrateItems: ToggleSettingOptionRowProps[] = useMemo( @@ -103,14 +124,14 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro icon: Illustrations.Accounting, title: translate('workspace.moreFeatures.connections.title'), subtitle: translate('workspace.moreFeatures.connections.subtitle'), + isActive: policy?.areConnectionsEnabled ?? false, + pendingAction: policy?.pendingFields?.areConnectionsEnabled && policy.pendingAction, onToggle: (isEnabled: boolean) => { - console.log('isEnabled', isEnabled); + Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); }, - isActive: policy?.areConnectionsEnabled ?? false, - pendingAction: undefined, }, ], - [policy?.areConnectionsEnabled, translate], + [policy?.areConnectionsEnabled, policy?.id, policy?.pendingAction, policy?.pendingFields?.areConnectionsEnabled, translate], ); const sections = useMemo( @@ -143,9 +164,9 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro icon={item.icon} title={item.title} subtitle={item.subtitle} - onToggle={item.onToggle} isActive={item.isActive} pendingAction={item.pendingAction} + onToggle={item.onToggle} />
); From 3d988c8502cba7c79fcd07a8998112ebb7717c6e Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 5 Mar 2024 13:11:14 +0100 Subject: [PATCH 15/44] integrate navigation on a screen once enable a feature --- src/libs/actions/Policy.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 99c47d80bf67..6dd1ecd5f1af 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -41,6 +41,7 @@ import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import Log from '@libs/Log'; +import Navigation from '@libs/Navigation/Navigation'; import * as NumberUtils from '@libs/NumberUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PhoneNumber from '@libs/PhoneNumber'; @@ -49,6 +50,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type { InvitedEmailsToAccountIDs, PersonalDetailsList, @@ -2541,6 +2543,10 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { successData, failureData, }); + + if (isEnabled) { + Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); + } } function enablePolicyConnections(policyID: string, isEnabled: boolean) { @@ -2590,6 +2596,11 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { successData, failureData, }); + + // TODO: Integrate navigation to a screen, once it appears + // if (isEnabled) { + // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // } } function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { @@ -2639,6 +2650,11 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { successData, failureData, }); + + // TODO: Integrate navigation to a screen, once it appears + // if (isEnabled) { + // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // } } function enablePolicyReportFields(policyID: string, isEnabled: boolean) { @@ -2688,6 +2704,11 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { successData, failureData, }); + + // TODO: Integrate navigation to a screen, once it appears + // if (isEnabled) { + // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // } } function enablePolicyTags(policyID: string, isEnabled: boolean) { @@ -2737,6 +2758,10 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { successData, failureData, }); + + if (isEnabled) { + Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); + } } function enablePolicyTaxes(policyID: string, isEnabled: boolean) { @@ -2790,6 +2815,11 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { successData, failureData, }); + + // TODO: Integrate navigation to a screen, once it appears + // if (isEnabled) { + // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // } } function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { @@ -2839,6 +2869,10 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { successData, failureData, }); + + if (isEnabled) { + Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); + } } export { From b57beee0d3e1a8bc337049d2493f83b706b9e5d4 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 5 Mar 2024 13:35:09 +0100 Subject: [PATCH 16/44] use IconAsset type for icon of ToggleSettingOptionRow --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 62f32992601a..51b8b5091218 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,16 +1,16 @@ import React, {useState} from 'react'; import {View} from 'react-native'; -import type {SvgProps} from 'react-native-svg'; import Icon from '@components/Icon'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import Switch from '@components/Switch'; import Text from '@components/Text'; import useThemeStyles from '@hooks/useThemeStyles'; import type {PendingAction} from '@src/types/onyx/OnyxCommon'; +import type IconAsset from '@src/types/utils/IconAsset'; type ToggleSettingOptionRowProps = { /** Icon to be shown for the option */ - icon: React.FC; + icon: IconAsset; /** Title of the option */ title: string; /** Subtitle of the option */ From 745523198797d784c0eeed828597e9e1c65ef80e Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 5 Mar 2024 13:35:19 +0100 Subject: [PATCH 17/44] improve perf. of WorkspaceMoreFeaturesPage --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 242 ++++++++---------- 1 file changed, 113 insertions(+), 129 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index f09b74281b6c..ef37e58348a7 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -1,6 +1,5 @@ -/* eslint-disable no-console */ import type {StackScreenProps} from '@react-navigation/stack'; -import React, {useMemo} from 'react'; +import React from 'react'; import {ScrollView, View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Illustrations from '@components/Icon/Illustrations'; @@ -11,176 +10,161 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import * as Policy from '@userActions/Policy'; +import type {TranslationPaths} from '@src/languages/types'; import type SCREENS from '@src/SCREENS'; +import type {PendingAction} from '@src/types/onyx/OnyxCommon'; +import type IconAsset from '@src/types/utils/IconAsset'; import AdminPolicyAccessOrNotFoundWrapper from './AdminPolicyAccessOrNotFoundWrapper'; import PaidPolicyAccessOrNotFoundWrapper from './PaidPolicyAccessOrNotFoundWrapper'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; -import type {ToggleSettingOptionRowProps} from './workflows/ToggleSettingsOptionRow'; import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; type WorkspaceMoreFeaturesPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; +type Item = { + icon: IconAsset; + titleTranslationKey: TranslationPaths; + subtitleTranslationKey: TranslationPaths; + isActive: boolean; + action: (isEnabled: boolean) => void; + pendingAction: PendingAction | undefined; +}; + +type SectionObject = { + titleTranslationKey: TranslationPaths; + subtitleTranslationKey: TranslationPaths; + items: Item[]; +}; + function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPageProps) { const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); - const spendItems: ToggleSettingOptionRowProps[] = useMemo( - () => [ - { - icon: Illustrations.Car, - title: translate('workspace.moreFeatures.distanceRates.title'), - subtitle: translate('workspace.moreFeatures.distanceRates.subtitle'), - isActive: policy?.areDistanceRatesEnabled ?? false, - pendingAction: policy?.pendingFields?.areDistanceRatesEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyDistanceRates(policy?.id ?? '', isEnabled); - }, + const spendItems: Item[] = [ + { + icon: Illustrations.Car, + titleTranslationKey: 'workspace.moreFeatures.distanceRates.title', + subtitleTranslationKey: 'workspace.moreFeatures.distanceRates.subtitle', + isActive: policy?.areDistanceRatesEnabled ?? false, + pendingAction: policy?.pendingFields?.areDistanceRatesEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyDistanceRates(policy?.id ?? '', isEnabled); }, - { - icon: Illustrations.Workflows, - title: translate('workspace.moreFeatures.workflows.title'), - subtitle: translate('workspace.moreFeatures.workflows.subtitle'), - isActive: policy?.areWorkflowsEnabled ?? false, - pendingAction: policy?.pendingFields?.areWorkflowsEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyWorkflows(policy?.id ?? '', isEnabled); - }, + }, + { + icon: Illustrations.Workflows, + titleTranslationKey: 'workspace.moreFeatures.workflows.title', + subtitleTranslationKey: 'workspace.moreFeatures.workflows.subtitle', + isActive: policy?.areWorkflowsEnabled ?? false, + pendingAction: policy?.pendingFields?.areWorkflowsEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyWorkflows(policy?.id ?? '', isEnabled); }, - ], - [ - policy?.areDistanceRatesEnabled, - policy?.areWorkflowsEnabled, - policy?.id, - policy?.pendingAction, - policy?.pendingFields?.areDistanceRatesEnabled, - policy?.pendingFields?.areWorkflowsEnabled, - translate, - ], - ); + }, + ]; - const organizeItems: ToggleSettingOptionRowProps[] = useMemo( - () => [ - { - icon: Illustrations.FolderOpen, - title: translate('workspace.moreFeatures.categories.title'), - subtitle: translate('workspace.moreFeatures.categories.subtitle'), - isActive: policy?.areCategoriesEnabled ?? false, - pendingAction: policy?.pendingFields?.areCategoriesEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyCategories(policy?.id ?? '', isEnabled); - }, + const organizeItems: Item[] = [ + { + icon: Illustrations.FolderOpen, + titleTranslationKey: 'workspace.moreFeatures.categories.title', + subtitleTranslationKey: 'workspace.moreFeatures.categories.subtitle', + isActive: policy?.areCategoriesEnabled ?? false, + pendingAction: policy?.pendingFields?.areCategoriesEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyCategories(policy?.id ?? '', isEnabled); }, - { - icon: Illustrations.Tag, - title: translate('workspace.moreFeatures.tags.title'), - subtitle: translate('workspace.moreFeatures.tags.subtitle'), - isActive: policy?.areTagsEnabled ?? false, - pendingAction: policy?.pendingFields?.areTagsEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyTags(policy?.id ?? '', isEnabled); - }, + }, + { + icon: Illustrations.Tag, + titleTranslationKey: 'workspace.moreFeatures.tags.title', + subtitleTranslationKey: 'workspace.moreFeatures.tags.subtitle', + isActive: policy?.areTagsEnabled ?? false, + pendingAction: policy?.pendingFields?.areTagsEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyTags(policy?.id ?? '', isEnabled); }, - { - icon: Illustrations.Coins, - title: translate('workspace.moreFeatures.taxes.title'), - subtitle: translate('workspace.moreFeatures.taxes.subtitle'), - isActive: policy?.tax?.trackingEnabled ?? false, - pendingAction: policy?.pendingFields?.isTaxTrackingEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); - }, + }, + { + icon: Illustrations.Coins, + titleTranslationKey: 'workspace.moreFeatures.taxes.title', + subtitleTranslationKey: 'workspace.moreFeatures.taxes.subtitle', + isActive: policy?.tax?.trackingEnabled ?? false, + pendingAction: policy?.pendingFields?.isTaxTrackingEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); }, - { - icon: Illustrations.Pencil, - title: translate('workspace.moreFeatures.reportFields.title'), - subtitle: translate('workspace.moreFeatures.reportFields.subtitle'), - isActive: policy?.areReportFieldsEnabled ?? false, - pendingAction: policy?.pendingFields?.areReportFieldsEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyReportFields(policy?.id ?? '', isEnabled); - }, + }, + { + icon: Illustrations.Pencil, + titleTranslationKey: 'workspace.moreFeatures.reportFields.title', + subtitleTranslationKey: 'workspace.moreFeatures.reportFields.subtitle', + isActive: policy?.areReportFieldsEnabled ?? false, + pendingAction: policy?.pendingFields?.areReportFieldsEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyReportFields(policy?.id ?? '', isEnabled); }, - ], - [ - policy?.areCategoriesEnabled, - policy?.areReportFieldsEnabled, - policy?.areTagsEnabled, - policy?.id, - policy?.pendingAction, - policy?.pendingFields?.areCategoriesEnabled, - policy?.pendingFields?.areReportFieldsEnabled, - policy?.pendingFields?.areTagsEnabled, - policy?.pendingFields?.isTaxTrackingEnabled, - policy?.tax?.trackingEnabled, - translate, - ], - ); + }, + ]; - const integrateItems: ToggleSettingOptionRowProps[] = useMemo( - () => [ - { - icon: Illustrations.Accounting, - title: translate('workspace.moreFeatures.connections.title'), - subtitle: translate('workspace.moreFeatures.connections.subtitle'), - isActive: policy?.areConnectionsEnabled ?? false, - pendingAction: policy?.pendingFields?.areConnectionsEnabled && policy.pendingAction, - onToggle: (isEnabled: boolean) => { - Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); - }, + const integrateItems: Item[] = [ + { + icon: Illustrations.Accounting, + titleTranslationKey: 'workspace.moreFeatures.connections.title', + subtitleTranslationKey: 'workspace.moreFeatures.connections.subtitle', + isActive: policy?.areConnectionsEnabled ?? false, + pendingAction: policy?.pendingFields?.areConnectionsEnabled && policy.pendingAction, + action: (isEnabled: boolean) => { + Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); }, - ], - [policy?.areConnectionsEnabled, policy?.id, policy?.pendingAction, policy?.pendingFields?.areConnectionsEnabled, translate], - ); + }, + ]; - const sections = useMemo( - () => [ - { - title: translate('workspace.moreFeatures.spendSection.title'), - subtitle: translate('workspace.moreFeatures.spendSection.subtitle'), - items: spendItems, - }, - { - title: translate('workspace.moreFeatures.organizeSection.title'), - subtitle: translate('workspace.moreFeatures.organizeSection.subtitle'), - items: organizeItems, - }, - { - title: translate('workspace.moreFeatures.integrateSection.title'), - subtitle: translate('workspace.moreFeatures.integrateSection.subtitle'), - items: integrateItems, - }, - ], - [integrateItems, organizeItems, spendItems, translate], - ); + const sections: SectionObject[] = [ + { + titleTranslationKey: 'workspace.moreFeatures.spendSection.title', + subtitleTranslationKey: 'workspace.moreFeatures.spendSection.subtitle', + items: spendItems, + }, + { + titleTranslationKey: 'workspace.moreFeatures.organizeSection.title', + subtitleTranslationKey: 'workspace.moreFeatures.organizeSection.subtitle', + items: organizeItems, + }, + { + titleTranslationKey: 'workspace.moreFeatures.integrateSection.title', + subtitleTranslationKey: 'workspace.moreFeatures.integrateSection.subtitle', + items: integrateItems, + }, + ]; - const renderItem = (item: ToggleSettingOptionRowProps) => ( + const renderItem = (item: Item) => ( ); const renderSection = (section: (typeof sections)[0]) => (
{section.items.map(renderItem)} From ddc0e5caa99f09ac146bf8773c6835eaf9ed8d67 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 5 Mar 2024 13:48:33 +0100 Subject: [PATCH 18/44] use another tax key --- src/libs/actions/Policy.ts | 6 +++--- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 6dd1ecd5f1af..021f972697c3 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2774,7 +2774,7 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { trackingEnabled: isEnabled, }, pendingFields: { - isTaxTrackingEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + tax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2786,7 +2786,7 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { pendingFields: { - isTaxTrackingEnabled: null, + tax: null, }, pendingAction: null, }, @@ -2801,7 +2801,7 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { trackingEnabled: !isEnabled, }, pendingFields: { - isTaxTrackingEnabled: null, + tax: null, }, pendingAction: null, }, diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index ef37e58348a7..343093ddb577 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -91,7 +91,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.taxes.title', subtitleTranslationKey: 'workspace.moreFeatures.taxes.subtitle', isActive: policy?.tax?.trackingEnabled ?? false, - pendingAction: policy?.pendingFields?.isTaxTrackingEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.tax && policy.pendingAction, action: (isEnabled: boolean) => { Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); }, From bdb03c09e10882112e5736336813713d3e938998 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 5 Mar 2024 14:04:19 +0100 Subject: [PATCH 19/44] show only enabled policy features --- src/pages/workspace/WorkspaceInitialPage.tsx | 52 ++++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 45f8365e82bb..c7f71e43a485 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -149,39 +149,49 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r }, ]; - const protectedCollectPolicyMenuItems: WorkspaceMenuItem[] = [ - { + const protectedCollectPolicyMenuItems: WorkspaceMenuItem[] = []; + + if (policy?.areWorkflowsEnabled) { + protectedCollectPolicyMenuItems.push({ translationKey: 'workspace.common.workflows', icon: Expensicons.Workflows, action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.WORKFLOWS, - }, - { - translationKey: 'workspace.common.members', - icon: Expensicons.Users, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))), - brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, - routeName: SCREENS.WORKSPACE.MEMBERS, - }, - { + }); + } + + protectedCollectPolicyMenuItems.push({ + translationKey: 'workspace.common.members', + icon: Expensicons.Users, + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID)))), + brickRoadIndicator: hasMembersError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, + routeName: SCREENS.WORKSPACE.MEMBERS, + }); + + if (policy?.areCategoriesEnabled) { + protectedCollectPolicyMenuItems.push({ translationKey: 'workspace.common.categories', icon: Expensicons.Folder, action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.CATEGORIES, - }, - { + }); + } + + if (policy?.areTagsEnabled) { + protectedCollectPolicyMenuItems.push({ translationKey: 'workspace.common.tags', icon: Expensicons.Tag, action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)))), routeName: SCREENS.WORKSPACE.TAGS, - }, - { - translationKey: 'workspace.common.moreFeatures', - icon: Expensicons.Gear, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)))), - routeName: SCREENS.WORKSPACE.MORE_FEATURES, - }, - ]; + }); + } + + protectedCollectPolicyMenuItems.push({ + translationKey: 'workspace.common.moreFeatures', + icon: Expensicons.Gear, + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)))), + routeName: SCREENS.WORKSPACE.MORE_FEATURES, + }); const menuItems: WorkspaceMenuItem[] = [ { From 9350c1a61cbebe15211f33877629d4d0c518bc87 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 6 Mar 2024 17:02:35 +0100 Subject: [PATCH 20/44] improve ToggleSettingOptionRow state updates --- .../workflows/ToggleSettingsOptionRow.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 51b8b5091218..b63f6aa93a87 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import Icon from '@components/Icon'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -29,11 +29,19 @@ const ICON_SIZE = 48; function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, isActive, pendingAction}: ToggleSettingOptionRowProps) { const [isEnabled, setIsEnabled] = useState(isActive); const styles = useThemeStyles(); + const toggleSwitch = () => { - setIsEnabled(!isEnabled); - onToggle(!isEnabled); + setIsEnabled((prev) => { + onToggle(!prev); + + return !prev; + }); }; + useEffect(() => { + setIsEnabled(isActive); + }, [isActive]); + return ( From e9594bc0e31fbe5a96f37e0ffc3cde09ca0032f2 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 6 Mar 2024 18:46:01 +0100 Subject: [PATCH 21/44] simplify states of ToggleSettingOptionRow --- .../workflows/ToggleSettingsOptionRow.tsx | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index b63f6aa93a87..673e9f59a2f6 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import React from 'react'; import {View} from 'react-native'; import Icon from '@components/Icon'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -27,21 +27,12 @@ type ToggleSettingOptionRowProps = { const ICON_SIZE = 48; function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, isActive, pendingAction}: ToggleSettingOptionRowProps) { - const [isEnabled, setIsEnabled] = useState(isActive); const styles = useThemeStyles(); const toggleSwitch = () => { - setIsEnabled((prev) => { - onToggle(!prev); - - return !prev; - }); + onToggle(!isActive); }; - useEffect(() => { - setIsEnabled(isActive); - }, [isActive]); - return ( @@ -80,10 +71,10 @@ function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, - {isEnabled && subMenuItems} + {isActive && subMenuItems} ); From b328f492ab68bdb1de4de993a40a252527143521 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 6 Mar 2024 19:21:52 +0100 Subject: [PATCH 22/44] fix translations --- src/languages/es.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 5b0da518f5e8..294841385cb0 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1798,44 +1798,44 @@ export default { }, moreFeatures: { spendSection: { - title: 'Gastar', - subtitle: 'Habilitar una funcionalidad opcional que lo ayude a escalar su equipo.', + title: 'Gasto', + subtitle: 'Habilita otras funcionalidades que ayudan a aumentar tu equipo.', }, organizeSection: { title: 'Organizar', - subtitle: 'Agrupar y analizar el gasto, registrar cada impuesto pagado.', + subtitle: 'Agrupa y analiza el gasto, registra cada impuesto pagado.', }, integrateSection: { title: 'Integrar', - subtitle: 'Conectar gastos de expensización a productos financieros populares.', + subtitle: 'Conecta Expensify a otros productos financieros populares.', }, distanceRates: { title: 'Tasas de distancia', - subtitle: 'Agregar, actualizar y hacer cumplir las tarifas.', + subtitle: 'Añade, actualiza y haz cumplir las tasas.', }, workflows: { title: 'Flujos de trabajo', - subtitle: 'Configure cómo se aprueba y paga el gasto.', + subtitle: 'Configura cómo se aprueba y paga los gastos.', }, categories: { title: 'Categorías', - subtitle: 'Rastrear y organizar el gasto.', + subtitle: 'Monitoriza y organiza los gastos.', }, tags: { title: 'Etiquetas', - subtitle: 'Agregue formas adicionales de clasificar el gasto.', + subtitle: 'Añade formas adicionales de clasificar los gastos.', }, taxes: { title: 'Impuestos', - subtitle: 'Documentar y reclamar impuestos elegibles.', + subtitle: 'Documenta y reclama los impuestos aplicables.', }, reportFields: { title: 'Campos de informes', - subtitle: 'Configurar campos personalizados para gastar.', + subtitle: 'Configura campos personalizados para los gastos.', }, connections: { title: 'Conexión', - subtitle: 'Sincronice su gráfico de cuentas y más.', + subtitle: 'Sincroniza tu plan de cuentas y otras opciones.', }, }, tags: { From 20bf80204756b40e295f10d50cfbb603468097ea Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 7 Mar 2024 15:38:34 +0100 Subject: [PATCH 23/44] align icon of ToggleSettingOptionRow --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 673e9f59a2f6..6616310b1001 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -44,7 +44,6 @@ function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, width={ICON_SIZE} additionalStyles={{ ...styles.mr3, - ...styles.pb4, }} /> From a14dbdc3f56573e2089749da6613d1b0bd0bc3e1 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 7 Mar 2024 16:02:21 +0100 Subject: [PATCH 24/44] navigate to initial settings for narrow devices --- src/libs/actions/Policy.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index aaabf9322000..07113b00ddd1 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -41,6 +41,7 @@ import type { import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; +import getIsNarrowLayout from '@libs/getIsNarrowLayout'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; import * as NumberUtils from '@libs/NumberUtils'; @@ -2611,7 +2612,9 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { }); if (isEnabled) { - Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); + const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); + + navigationAction(); } } @@ -2665,7 +2668,9 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { // TODO: Integrate navigation to a screen, once it appears // if (isEnabled) { - // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + + // navigationAction(); // } } @@ -2719,7 +2724,9 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { // TODO: Integrate navigation to a screen, once it appears // if (isEnabled) { - // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + + // navigationAction(); // } } @@ -2773,7 +2780,9 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { // TODO: Integrate navigation to a screen, once it appears // if (isEnabled) { - // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + + // navigationAction(); // } } @@ -2826,7 +2835,9 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { }); if (isEnabled) { - Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); + const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); + + navigationAction(); } } @@ -2884,7 +2895,9 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { // TODO: Integrate navigation to a screen, once it appears // if (isEnabled) { - // Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); + + // navigationAction(); // } } @@ -2937,7 +2950,9 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { }); if (isEnabled) { - Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); + const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); + + navigationAction(); } } From 32905202beeffadb633bc53ee630b707b8538d7e Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 7 Mar 2024 16:09:24 +0100 Subject: [PATCH 25/44] use own ScrollView --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 343093ddb577..9ba50a86c274 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -1,9 +1,10 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React from 'react'; -import {ScrollView, View} from 'react-native'; +import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Illustrations from '@components/Icon/Illustrations'; import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; From 5b634a978576841b17f12a49545afc5f350ce5c1 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 7 Mar 2024 16:33:06 +0100 Subject: [PATCH 26/44] update workflows icon --- .../simple-illustration__workflows.svg | 154 +++++++++++++++++- 1 file changed, 153 insertions(+), 1 deletion(-) diff --git a/assets/images/simple-illustrations/simple-illustration__workflows.svg b/assets/images/simple-illustrations/simple-illustration__workflows.svg index 47d30d54310f..b684c58126f7 100644 --- a/assets/images/simple-illustrations/simple-illustration__workflows.svg +++ b/assets/images/simple-illustrations/simple-illustration__workflows.svg @@ -1 +1,153 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4a9895d56f6ba08eda5a9f43a140253d333582ff Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Thu, 7 Mar 2024 17:51:37 +0100 Subject: [PATCH 27/44] use bigger line height --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 6616310b1001..9ef35b0f7e07 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -51,6 +51,7 @@ function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, style={{ ...styles.textMicroBold, ...styles.textNormal, + ...styles.lh20, }} > {title} From 6e0735145e2f80484cdfaaa3201ec3fe2108801f Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 12:37:41 +0100 Subject: [PATCH 28/44] add empty lines --- src/libs/actions/Policy.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index bfe3c49af4d9..ec90a5d727e7 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -3040,6 +3040,7 @@ function acceptJoinRequest(reportID: string, reportAction: OnyxEntry Date: Fri, 8 Mar 2024 14:36:44 +0100 Subject: [PATCH 29/44] remove the page from the modal stack --- src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx index 763acc1c0ead..978e338796ea 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx @@ -251,7 +251,6 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../pages/workspace/WorkspaceProfileCurrencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORY_SETTINGS]: () => require('../../../pages/workspace/categories/CategorySettingsPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORIES_SETTINGS]: () => require('../../../pages/workspace/categories/WorkspaceCategoriesSettingsPage').default as React.ComponentType, - [SCREENS.WORKSPACE.MORE_FEATURES]: () => require('../../../pages/workspace/WorkspaceMoreFeaturesPage').default as React.ComponentType, [SCREENS.WORKSPACE.MEMBER_DETAILS]: () => require('../../../pages/workspace/members/WorkspaceMemberDetailsPage').default as React.ComponentType, [SCREENS.WORKSPACE.MEMBER_DETAILS_ROLE_SELECTION]: () => require('../../../pages/workspace/members/WorkspaceMemberDetailsRoleSelectionPage').default as React.ComponentType, [SCREENS.WORKSPACE.CATEGORY_CREATE]: () => require('../../../pages/workspace/categories/CreateCategoryPage').default as React.ComponentType, From 46dcb4c335bf61640d78d1a98829a067ae0fe817 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 14:37:54 +0100 Subject: [PATCH 30/44] tweak Switch handler --- src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx index 9ef35b0f7e07..c5c4465937b9 100644 --- a/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx +++ b/src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx @@ -29,10 +29,6 @@ const ICON_SIZE = 48; function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, isActive, pendingAction}: ToggleSettingOptionRowProps) { const styles = useThemeStyles(); - const toggleSwitch = () => { - onToggle(!isActive); - }; - return ( @@ -70,7 +66,7 @@ function ToggleSettingOptionRow({icon, title, subtitle, onToggle, subMenuItems, From 1567a46ac6cd50a952fedc787ac00938fa0717fa Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 14:39:29 +0100 Subject: [PATCH 31/44] clarify types of WorkspaceMoreFeaturesPage --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 9ba50a86c274..7b541df3df1d 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -21,7 +21,7 @@ import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscree import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; import ToggleSettingOptionRow from './workflows/ToggleSettingsOptionRow'; -type WorkspaceMoreFeaturesPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; +type WorkspaceMoreFeaturesPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps; type Item = { icon: IconAsset; @@ -156,7 +156,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro ); - const renderSection = (section: (typeof sections)[0]) => ( + const renderSection = (section: SectionObject) => ( Date: Fri, 8 Mar 2024 14:41:54 +0100 Subject: [PATCH 32/44] memorize render functions --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 7b541df3df1d..ca380c4bec5c 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -1,5 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import React from 'react'; +import React, {useCallback} from 'react'; import {View} from 'react-native'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Illustrations from '@components/Icon/Illustrations'; @@ -140,37 +140,43 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro }, ]; - const renderItem = (item: Item) => ( - - - + const renderItem = useCallback( + (item: Item) => ( + + + + ), + [styles.mt7, translate], ); - const renderSection = (section: SectionObject) => ( - -
( + - {section.items.map(renderItem)} -
-
+
+ {section.items.map(renderItem)} +
+
+ ), + [isSmallScreenWidth, renderItem, styles.mt3, styles.p5, styles.p8, styles.textStrong, styles.workspaceSection, styles.workspaceSectionMobile, translate], ); return ( From 83e22a6bb9ecfe16b0f4e4a07d09ad38a8a16328 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 14:42:33 +0100 Subject: [PATCH 33/44] remove todo comments --- src/libs/actions/Policy.ts | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index ec90a5d727e7..23345415eb54 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2702,13 +2702,6 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { successData, failureData, }); - - // TODO: Integrate navigation to a screen, once it appears - // if (isEnabled) { - // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); - - // navigationAction(); - // } } function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { @@ -2758,13 +2751,6 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { successData, failureData, }); - - // TODO: Integrate navigation to a screen, once it appears - // if (isEnabled) { - // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); - - // navigationAction(); - // } } function enablePolicyReportFields(policyID: string, isEnabled: boolean) { @@ -2814,13 +2800,6 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { successData, failureData, }); - - // TODO: Integrate navigation to a screen, once it appears - // if (isEnabled) { - // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); - - // navigationAction(); - // } } function enablePolicyTags(policyID: string, isEnabled: boolean) { @@ -2929,13 +2908,6 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { successData, failureData, }); - - // TODO: Integrate navigation to a screen, once it appears - // if (isEnabled) { - // const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_.getRoute(policyID)); - - // navigationAction(); - // } } function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { From 42eeb3ed3bc3ea17b518557dc39228a813a60dd2 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 14:53:16 +0100 Subject: [PATCH 34/44] remove pendingAction --- src/libs/actions/Policy.ts | 21 ------------------- .../workspace/WorkspaceMoreFeaturesPage.tsx | 14 ++++++------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 23345415eb54..31f1dae8ebf5 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2610,7 +2610,6 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { pendingFields: { areCategoriesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2622,7 +2621,6 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { pendingFields: { areCategoriesEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2635,7 +2633,6 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { pendingFields: { areCategoriesEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2665,7 +2662,6 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { pendingFields: { areConnectionsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2677,7 +2673,6 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { pendingFields: { areConnectionsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2690,7 +2685,6 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { pendingFields: { areConnectionsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2714,7 +2708,6 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { pendingFields: { areDistanceRatesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2726,7 +2719,6 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { pendingFields: { areDistanceRatesEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2739,7 +2731,6 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { pendingFields: { areDistanceRatesEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2763,7 +2754,6 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { pendingFields: { areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2775,7 +2765,6 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { pendingFields: { areReportFieldsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2788,7 +2777,6 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { pendingFields: { areReportFieldsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2812,7 +2800,6 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { pendingFields: { areTagsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2824,7 +2811,6 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { pendingFields: { areTagsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2837,7 +2823,6 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { pendingFields: { areTagsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2869,7 +2854,6 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { pendingFields: { tax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2881,7 +2865,6 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { pendingFields: { tax: null, }, - pendingAction: null, }, }, ]; @@ -2896,7 +2879,6 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { pendingFields: { tax: null, }, - pendingAction: null, }, }, ]; @@ -2920,7 +2902,6 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { pendingFields: { areWorkflowsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, ]; @@ -2932,7 +2913,6 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { pendingFields: { areWorkflowsEnabled: null, }, - pendingAction: null, }, }, ]; @@ -2945,7 +2925,6 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { pendingFields: { areWorkflowsEnabled: null, }, - pendingAction: null, }, }, ]; diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index ca380c4bec5c..6c268d977dfc 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -49,7 +49,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.distanceRates.title', subtitleTranslationKey: 'workspace.moreFeatures.distanceRates.subtitle', isActive: policy?.areDistanceRatesEnabled ?? false, - pendingAction: policy?.pendingFields?.areDistanceRatesEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.areDistanceRatesEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyDistanceRates(policy?.id ?? '', isEnabled); }, @@ -59,7 +59,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.workflows.title', subtitleTranslationKey: 'workspace.moreFeatures.workflows.subtitle', isActive: policy?.areWorkflowsEnabled ?? false, - pendingAction: policy?.pendingFields?.areWorkflowsEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.areWorkflowsEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyWorkflows(policy?.id ?? '', isEnabled); }, @@ -72,7 +72,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.categories.title', subtitleTranslationKey: 'workspace.moreFeatures.categories.subtitle', isActive: policy?.areCategoriesEnabled ?? false, - pendingAction: policy?.pendingFields?.areCategoriesEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.areCategoriesEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyCategories(policy?.id ?? '', isEnabled); }, @@ -82,7 +82,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.tags.title', subtitleTranslationKey: 'workspace.moreFeatures.tags.subtitle', isActive: policy?.areTagsEnabled ?? false, - pendingAction: policy?.pendingFields?.areTagsEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.areTagsEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyTags(policy?.id ?? '', isEnabled); }, @@ -92,7 +92,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.taxes.title', subtitleTranslationKey: 'workspace.moreFeatures.taxes.subtitle', isActive: policy?.tax?.trackingEnabled ?? false, - pendingAction: policy?.pendingFields?.tax && policy.pendingAction, + pendingAction: policy?.pendingFields?.tax, action: (isEnabled: boolean) => { Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); }, @@ -102,7 +102,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.reportFields.title', subtitleTranslationKey: 'workspace.moreFeatures.reportFields.subtitle', isActive: policy?.areReportFieldsEnabled ?? false, - pendingAction: policy?.pendingFields?.areReportFieldsEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.areReportFieldsEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyReportFields(policy?.id ?? '', isEnabled); }, @@ -115,7 +115,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro titleTranslationKey: 'workspace.moreFeatures.connections.title', subtitleTranslationKey: 'workspace.moreFeatures.connections.subtitle', isActive: policy?.areConnectionsEnabled ?? false, - pendingAction: policy?.pendingFields?.areConnectionsEnabled && policy.pendingAction, + pendingAction: policy?.pendingFields?.areConnectionsEnabled, action: (isEnabled: boolean) => { Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); }, From 6bed5e1dd3643c5aedf553cf54ab06c032cb95d3 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 15:01:13 +0100 Subject: [PATCH 35/44] use onyxData arrays --- src/libs/actions/Policy.ts | 470 ++++++++++++++++++------------------- 1 file changed, 228 insertions(+), 242 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 31f1dae8ebf5..dbe84ab61f97 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2601,49 +2601,47 @@ function clearCategoryErrors(policyID: string, categoryName: string) { } function enablePolicyCategories(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areCategoriesEnabled: isEnabled, - pendingFields: { - areCategoriesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areCategoriesEnabled: isEnabled, + pendingFields: { + areCategoriesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - areCategoriesEnabled: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areCategoriesEnabled: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areCategoriesEnabled: !isEnabled, - pendingFields: { - areCategoriesEnabled: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areCategoriesEnabled: !isEnabled, + pendingFields: { + areCategoriesEnabled: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyCategoriesParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES, parameters, onyxData); if (isEnabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); @@ -2653,187 +2651,179 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { } function enablePolicyConnections(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areConnectionsEnabled: isEnabled, - pendingFields: { - areConnectionsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areConnectionsEnabled: isEnabled, + pendingFields: { + areConnectionsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - areConnectionsEnabled: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areConnectionsEnabled: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areConnectionsEnabled: !isEnabled, - pendingFields: { - areConnectionsEnabled: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areConnectionsEnabled: !isEnabled, + pendingFields: { + areConnectionsEnabled: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyConnectionsParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS, parameters, onyxData); } function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areDistanceRatesEnabled: isEnabled, - pendingFields: { - areDistanceRatesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areDistanceRatesEnabled: isEnabled, + pendingFields: { + areDistanceRatesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - areDistanceRatesEnabled: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areDistanceRatesEnabled: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areDistanceRatesEnabled: !isEnabled, - pendingFields: { - areDistanceRatesEnabled: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areDistanceRatesEnabled: !isEnabled, + pendingFields: { + areDistanceRatesEnabled: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyDistanceRatesParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES, parameters, onyxData); } function enablePolicyReportFields(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areReportFieldsEnabled: isEnabled, - pendingFields: { - areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areReportFieldsEnabled: isEnabled, + pendingFields: { + areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - areReportFieldsEnabled: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areReportFieldsEnabled: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areReportFieldsEnabled: !isEnabled, - pendingFields: { - areReportFieldsEnabled: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areReportFieldsEnabled: !isEnabled, + pendingFields: { + areReportFieldsEnabled: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyReportFieldsParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS, parameters, onyxData); } function enablePolicyTags(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areTagsEnabled: isEnabled, - pendingFields: { - areTagsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areTagsEnabled: isEnabled, + pendingFields: { + areTagsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - areTagsEnabled: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areTagsEnabled: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areTagsEnabled: !isEnabled, - pendingFields: { - areTagsEnabled: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areTagsEnabled: !isEnabled, + pendingFields: { + areTagsEnabled: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyTagsParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_TAGS, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_TAGS, parameters, onyxData); if (isEnabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); @@ -2843,99 +2833,95 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { } function enablePolicyTaxes(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - tax: { - trackingEnabled: isEnabled, - }, - pendingFields: { - tax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + tax: { + trackingEnabled: isEnabled, + }, + pendingFields: { + tax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - tax: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + tax: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - tax: { - trackingEnabled: !isEnabled, - }, - pendingFields: { - tax: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + tax: { + trackingEnabled: !isEnabled, + }, + pendingFields: { + tax: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyTaxesParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_TAXES, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_TAXES, parameters, onyxData); } function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areWorkflowsEnabled: isEnabled, - pendingFields: { - areWorkflowsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areWorkflowsEnabled: isEnabled, + pendingFields: { + areWorkflowsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, }, - }, - ]; - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - pendingFields: { - areWorkflowsEnabled: null, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + pendingFields: { + areWorkflowsEnabled: null, + }, }, }, - }, - ]; - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, - value: { - areWorkflowsEnabled: !isEnabled, - pendingFields: { - areWorkflowsEnabled: null, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + areWorkflowsEnabled: !isEnabled, + pendingFields: { + areWorkflowsEnabled: null, + }, }, }, - }, - ]; + ], + }; const parameters: EnablePolicyWorkflowsParams = {policyID, isEnabled}; - API.write(WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS, parameters, { - optimisticData, - successData, - failureData, - }); + API.write(WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS, parameters, onyxData); if (isEnabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); From 129bac585490db92e79075ad4690cddbd4302407 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 15:01:58 +0100 Subject: [PATCH 36/44] clarify screen name --- src/SCREENS.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 699f1b4b3a00..ba378b28b4be 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -227,7 +227,7 @@ const SCREENS = { CATEGORY_CREATE: 'Category_Create', CATEGORY_SETTINGS: 'Category_Settings', CATEGORIES_SETTINGS: 'Categories_Settings', - MORE_FEATURES: 'More_Features', + MORE_FEATURES: 'Workspace_More_Features', MEMBER_DETAILS: 'Workspace_Member_Details', MEMBER_DETAILS_ROLE_SELECTION: 'Workspace_Member_Details_Role_Selection', }, From ad9b75bbb03ec97db1ec1733f5019bc093ac0043 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Fri, 8 Mar 2024 16:55:54 +0100 Subject: [PATCH 37/44] simplify deps. arrays --- src/pages/workspace/WorkspaceMoreFeaturesPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 6c268d977dfc..8b539ad58f9d 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -156,7 +156,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro /> ), - [styles.mt7, translate], + [styles, translate], ); const renderSection = useCallback( @@ -176,7 +176,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
), - [isSmallScreenWidth, renderItem, styles.mt3, styles.p5, styles.p8, styles.textStrong, styles.workspaceSection, styles.workspaceSectionMobile, translate], + [isSmallScreenWidth, styles, renderItem, translate], ); return ( From 54bed631cf894298e88ffe6caf9b3d83c3e8e633 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Sat, 9 Mar 2024 10:30:22 +0100 Subject: [PATCH 38/44] add bottom padding --- 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 8b539ad58f9d..e2539c60d234 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -194,7 +194,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro shouldShowBackButton={isSmallScreenWidth} /> - {sections.map(renderSection)} + {sections.map(renderSection)} From 4b816cf500a88e653277222c409776bda1da8150 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Sat, 9 Mar 2024 10:33:00 +0100 Subject: [PATCH 39/44] rename to enabled --- .../EnablePolicyCategoriesParams.ts | 2 +- .../EnablePolicyConnectionsParams.ts | 2 +- .../EnablePolicyDistanceRatesParams.ts | 2 +- .../EnablePolicyReportFieldsParams.ts | 2 +- .../API/parameters/EnablePolicyTagsParams.ts | 2 +- .../API/parameters/EnablePolicyTaxesParams.ts | 2 +- .../parameters/EnablePolicyWorkflowsParams.ts | 2 +- src/libs/actions/Policy.ts | 62 +++++++++---------- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/libs/API/parameters/EnablePolicyCategoriesParams.ts b/src/libs/API/parameters/EnablePolicyCategoriesParams.ts index 6d994f9dca37..61aa600b8ea0 100644 --- a/src/libs/API/parameters/EnablePolicyCategoriesParams.ts +++ b/src/libs/API/parameters/EnablePolicyCategoriesParams.ts @@ -1,6 +1,6 @@ type EnablePolicyCategoriesParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyCategoriesParams; diff --git a/src/libs/API/parameters/EnablePolicyConnectionsParams.ts b/src/libs/API/parameters/EnablePolicyConnectionsParams.ts index 312c93c42b30..cd2ac828b359 100644 --- a/src/libs/API/parameters/EnablePolicyConnectionsParams.ts +++ b/src/libs/API/parameters/EnablePolicyConnectionsParams.ts @@ -1,6 +1,6 @@ type EnablePolicyConnectionsParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyConnectionsParams; diff --git a/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts b/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts index 18718670af25..d66f898e6e10 100644 --- a/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts +++ b/src/libs/API/parameters/EnablePolicyDistanceRatesParams.ts @@ -1,6 +1,6 @@ type EnablePolicyDistanceRatesParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyDistanceRatesParams; diff --git a/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts b/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts index 341716563f53..7a5670e200c8 100644 --- a/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts +++ b/src/libs/API/parameters/EnablePolicyReportFieldsParams.ts @@ -1,6 +1,6 @@ type EnablePolicyReportFieldsParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyReportFieldsParams; diff --git a/src/libs/API/parameters/EnablePolicyTagsParams.ts b/src/libs/API/parameters/EnablePolicyTagsParams.ts index f85fabd30f1f..8a8e21dd3371 100644 --- a/src/libs/API/parameters/EnablePolicyTagsParams.ts +++ b/src/libs/API/parameters/EnablePolicyTagsParams.ts @@ -1,6 +1,6 @@ type EnablePolicyTagsParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyTagsParams; diff --git a/src/libs/API/parameters/EnablePolicyTaxesParams.ts b/src/libs/API/parameters/EnablePolicyTaxesParams.ts index c180bab572b0..4a235d5d6a1f 100644 --- a/src/libs/API/parameters/EnablePolicyTaxesParams.ts +++ b/src/libs/API/parameters/EnablePolicyTaxesParams.ts @@ -1,6 +1,6 @@ type EnablePolicyTaxesParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyTaxesParams; diff --git a/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts b/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts index ab472197f7b7..1958ec8df581 100644 --- a/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts +++ b/src/libs/API/parameters/EnablePolicyWorkflowsParams.ts @@ -1,6 +1,6 @@ type EnablePolicyWorkflowsParams = { policyID: string; - isEnabled: boolean; + enabled: boolean; }; export default EnablePolicyWorkflowsParams; diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index d8aacd872b91..d12789091f2f 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2652,14 +2652,14 @@ function clearCategoryErrors(policyID: string, categoryName: string) { }); } -function enablePolicyCategories(policyID: string, isEnabled: boolean) { +function enablePolicyCategories(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areCategoriesEnabled: isEnabled, + areCategoriesEnabled: enabled, pendingFields: { areCategoriesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2682,7 +2682,7 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areCategoriesEnabled: !isEnabled, + areCategoriesEnabled: !enabled, pendingFields: { areCategoriesEnabled: null, }, @@ -2691,25 +2691,25 @@ function enablePolicyCategories(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyCategoriesParams = {policyID, isEnabled}; + const parameters: EnablePolicyCategoriesParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES, parameters, onyxData); - if (isEnabled) { + if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); navigationAction(); } } -function enablePolicyConnections(policyID: string, isEnabled: boolean) { +function enablePolicyConnections(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areConnectionsEnabled: isEnabled, + areConnectionsEnabled: enabled, pendingFields: { areConnectionsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2732,7 +2732,7 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areConnectionsEnabled: !isEnabled, + areConnectionsEnabled: !enabled, pendingFields: { areConnectionsEnabled: null, }, @@ -2741,19 +2741,19 @@ function enablePolicyConnections(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyConnectionsParams = {policyID, isEnabled}; + const parameters: EnablePolicyConnectionsParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_CONNECTIONS, parameters, onyxData); } -function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { +function enablePolicyDistanceRates(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areDistanceRatesEnabled: isEnabled, + areDistanceRatesEnabled: enabled, pendingFields: { areDistanceRatesEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2776,7 +2776,7 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areDistanceRatesEnabled: !isEnabled, + areDistanceRatesEnabled: !enabled, pendingFields: { areDistanceRatesEnabled: null, }, @@ -2785,19 +2785,19 @@ function enablePolicyDistanceRates(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyDistanceRatesParams = {policyID, isEnabled}; + const parameters: EnablePolicyDistanceRatesParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES, parameters, onyxData); } -function enablePolicyReportFields(policyID: string, isEnabled: boolean) { +function enablePolicyReportFields(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areReportFieldsEnabled: isEnabled, + areReportFieldsEnabled: enabled, pendingFields: { areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2820,7 +2820,7 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areReportFieldsEnabled: !isEnabled, + areReportFieldsEnabled: !enabled, pendingFields: { areReportFieldsEnabled: null, }, @@ -2829,19 +2829,19 @@ function enablePolicyReportFields(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyReportFieldsParams = {policyID, isEnabled}; + const parameters: EnablePolicyReportFieldsParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_REPORT_FIELDS, parameters, onyxData); } -function enablePolicyTags(policyID: string, isEnabled: boolean) { +function enablePolicyTags(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areTagsEnabled: isEnabled, + areTagsEnabled: enabled, pendingFields: { areTagsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2864,7 +2864,7 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areTagsEnabled: !isEnabled, + areTagsEnabled: !enabled, pendingFields: { areTagsEnabled: null, }, @@ -2873,18 +2873,18 @@ function enablePolicyTags(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyTagsParams = {policyID, isEnabled}; + const parameters: EnablePolicyTagsParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_TAGS, parameters, onyxData); - if (isEnabled) { + if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); navigationAction(); } } -function enablePolicyTaxes(policyID: string, isEnabled: boolean) { +function enablePolicyTaxes(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { @@ -2892,7 +2892,7 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { tax: { - trackingEnabled: isEnabled, + trackingEnabled: enabled, }, pendingFields: { tax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, @@ -2917,7 +2917,7 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { tax: { - trackingEnabled: !isEnabled, + trackingEnabled: !enabled, }, pendingFields: { tax: null, @@ -2927,19 +2927,19 @@ function enablePolicyTaxes(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyTaxesParams = {policyID, isEnabled}; + const parameters: EnablePolicyTaxesParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_TAXES, parameters, onyxData); } -function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { +function enablePolicyWorkflows(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areWorkflowsEnabled: isEnabled, + areWorkflowsEnabled: enabled, pendingFields: { areWorkflowsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, @@ -2962,7 +2962,7 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - areWorkflowsEnabled: !isEnabled, + areWorkflowsEnabled: !enabled, pendingFields: { areWorkflowsEnabled: null, }, @@ -2971,11 +2971,11 @@ function enablePolicyWorkflows(policyID: string, isEnabled: boolean) { ], }; - const parameters: EnablePolicyWorkflowsParams = {policyID, isEnabled}; + const parameters: EnablePolicyWorkflowsParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS, parameters, onyxData); - if (isEnabled) { + if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); navigationAction(); From d3c611cea604288ab13614a0b8ddfa1d225db947 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Sat, 9 Mar 2024 10:37:30 +0100 Subject: [PATCH 40/44] remove unimplemented features from the list --- .../workspace/WorkspaceMoreFeaturesPage.tsx | 38 ------------------- 1 file changed, 38 deletions(-) diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index e2539c60d234..45a950e0fafb 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -87,39 +87,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro Policy.enablePolicyTags(policy?.id ?? '', isEnabled); }, }, - { - icon: Illustrations.Coins, - titleTranslationKey: 'workspace.moreFeatures.taxes.title', - subtitleTranslationKey: 'workspace.moreFeatures.taxes.subtitle', - isActive: policy?.tax?.trackingEnabled ?? false, - pendingAction: policy?.pendingFields?.tax, - action: (isEnabled: boolean) => { - Policy.enablePolicyTaxes(policy?.id ?? '', isEnabled); - }, - }, - { - icon: Illustrations.Pencil, - titleTranslationKey: 'workspace.moreFeatures.reportFields.title', - subtitleTranslationKey: 'workspace.moreFeatures.reportFields.subtitle', - isActive: policy?.areReportFieldsEnabled ?? false, - pendingAction: policy?.pendingFields?.areReportFieldsEnabled, - action: (isEnabled: boolean) => { - Policy.enablePolicyReportFields(policy?.id ?? '', isEnabled); - }, - }, - ]; - - const integrateItems: Item[] = [ - { - icon: Illustrations.Accounting, - titleTranslationKey: 'workspace.moreFeatures.connections.title', - subtitleTranslationKey: 'workspace.moreFeatures.connections.subtitle', - isActive: policy?.areConnectionsEnabled ?? false, - pendingAction: policy?.pendingFields?.areConnectionsEnabled, - action: (isEnabled: boolean) => { - Policy.enablePolicyConnections(policy?.id ?? '', isEnabled); - }, - }, ]; const sections: SectionObject[] = [ @@ -133,11 +100,6 @@ 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 5efcc2d676a3407c4f3b52af68c4df2bb9e21ecf Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Sat, 9 Mar 2024 10:38:07 +0100 Subject: [PATCH 41/44] add navigate to distance rates --- src/libs/actions/Policy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index d12789091f2f..978f400320f7 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2788,6 +2788,12 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean) { const parameters: EnablePolicyDistanceRatesParams = {policyID, enabled}; API.write(WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES, parameters, onyxData); + + if (enabled) { + const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)); + + navigationAction(); + } } function enablePolicyReportFields(policyID: string, enabled: boolean) { From 4c1c1f9e0f827c0569588e3b347c5fef0afe1368 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Sat, 9 Mar 2024 10:39:56 +0100 Subject: [PATCH 42/44] remove extra empty lines --- src/libs/actions/Policy.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 978f400320f7..d0e3332ab918 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -2697,7 +2697,6 @@ function enablePolicyCategories(policyID: string, enabled: boolean) { if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); - navigationAction(); } } @@ -2791,7 +2790,6 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean) { if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)); - navigationAction(); } } @@ -2885,7 +2883,6 @@ function enablePolicyTags(policyID: string, enabled: boolean) { if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); - navigationAction(); } } @@ -2983,7 +2980,6 @@ function enablePolicyWorkflows(policyID: string, enabled: boolean) { if (enabled) { const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); - navigationAction(); } } From 1ec02955d45c494b662687ddd58af9d9eec54c3b Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Mon, 11 Mar 2024 10:55:09 +0100 Subject: [PATCH 43/44] improve nav flow --- src/libs/actions/Policy.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index d0e3332ab918..8bfa2a4a11fd 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -53,6 +53,7 @@ import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import type {Route} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type { InvitedEmailsToAccountIDs, @@ -2652,6 +2653,18 @@ function clearCategoryErrors(policyID: string, categoryName: string) { }); } +function navigateWhenEnableFeature(policyID: string, featureRoute: Route) { + const isNarrowLayout = getIsNarrowLayout(); + + if (isNarrowLayout) { + Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID), CONST.NAVIGATION.TYPE.FORCED_UP); + + return; + } + + Navigation.navigate(featureRoute); +} + function enablePolicyCategories(policyID: string, enabled: boolean) { const onyxData: OnyxData = { optimisticData: [ @@ -2696,8 +2709,7 @@ function enablePolicyCategories(policyID: string, enabled: boolean) { API.write(WRITE_COMMANDS.ENABLE_POLICY_CATEGORIES, parameters, onyxData); if (enabled) { - const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); - navigationAction(); + navigateWhenEnableFeature(policyID, ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID)); } } @@ -2789,8 +2801,7 @@ function enablePolicyDistanceRates(policyID: string, enabled: boolean) { API.write(WRITE_COMMANDS.ENABLE_POLICY_DISTANCE_RATES, parameters, onyxData); if (enabled) { - const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)); - navigationAction(); + navigateWhenEnableFeature(policyID, ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)); } } @@ -2882,8 +2893,7 @@ function enablePolicyTags(policyID: string, enabled: boolean) { API.write(WRITE_COMMANDS.ENABLE_POLICY_TAGS, parameters, onyxData); if (enabled) { - const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID)); - navigationAction(); + navigateWhenEnableFeature(policyID, ROUTES.WORKSPACE_TAGS.getRoute(policyID)); } } @@ -2979,8 +2989,7 @@ function enablePolicyWorkflows(policyID: string, enabled: boolean) { API.write(WRITE_COMMANDS.ENABLE_POLICY_WORKFLOWS, parameters, onyxData); if (enabled) { - const navigationAction = getIsNarrowLayout() ? Navigation.goBack : () => Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); - navigationAction(); + navigateWhenEnableFeature(policyID, ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)); } } From c8282eafccffe53df9c25394967a202df2267629 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Mon, 11 Mar 2024 10:56:00 +0100 Subject: [PATCH 44/44] move distance rates up --- src/pages/workspace/WorkspaceInitialPage.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.tsx b/src/pages/workspace/WorkspaceInitialPage.tsx index 7b2f7631cea4..240a148110f7 100644 --- a/src/pages/workspace/WorkspaceInitialPage.tsx +++ b/src/pages/workspace/WorkspaceInitialPage.tsx @@ -145,6 +145,15 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r const protectedCollectPolicyMenuItems: WorkspaceMenuItem[] = []; + if (policy?.areDistanceRatesEnabled) { + protectedCollectPolicyMenuItems.push({ + translationKey: 'workspace.common.distanceRates', + icon: Expensicons.Car, + action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)))), + routeName: SCREENS.WORKSPACE.DISTANCE_RATES, + }); + } + if (policy?.areWorkflowsEnabled) { protectedCollectPolicyMenuItems.push({ translationKey: 'workspace.common.workflows', @@ -172,15 +181,6 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, policyMembers, r }); } - if (policy?.areDistanceRatesEnabled) { - protectedCollectPolicyMenuItems.push({ - translationKey: 'workspace.common.distanceRates', - icon: Expensicons.Car, - action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID)))), - routeName: SCREENS.WORKSPACE.DISTANCE_RATES, - }); - } - protectedCollectPolicyMenuItems.push({ translationKey: 'workspace.common.moreFeatures', icon: Expensicons.Gear,