From 5f7c983756f532c2bd35ca325224fc07aed81c12 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Mon, 9 Dec 2024 12:50:12 -0700 Subject: [PATCH] Revert "feat: Provide education/confirmation before creating workspaces in New Workspace flows" --- src/ONYXKEYS.ts | 3 - src/ROUTES.ts | 2 +- src/SCREENS.ts | 3 - src/components/CurrencyPicker.tsx | 87 -------- src/languages/en.ts | 3 +- src/languages/es.ts | 1 - .../API/parameters/CreateWorkspaceParams.ts | 2 - src/libs/CurrencyUtils.ts | 7 - .../ModalStackNavigators/index.tsx | 6 - .../Navigators/RightModalNavigator.tsx | 4 - src/libs/Navigation/linkingConfig/config.ts | 5 - src/libs/Navigation/types.ts | 6 - src/libs/actions/App.ts | 23 +-- src/libs/actions/Policy/Policy.ts | 39 +--- .../WorkspaceCardCreateAWorkspace.tsx | 5 +- .../FloatingActionButtonAndPopover.tsx | 3 +- .../workspace/WorkspaceConfirmationPage.tsx | 191 ------------------ src/pages/workspace/WorkspaceNamePage.tsx | 2 +- src/pages/workspace/WorkspacesListPage.tsx | 5 +- src/types/form/WorkspaceConfirmationForm.ts | 20 -- src/types/form/index.ts | 1 - 21 files changed, 25 insertions(+), 393 deletions(-) delete mode 100644 src/components/CurrencyPicker.tsx delete mode 100644 src/pages/workspace/WorkspaceConfirmationPage.tsx delete mode 100644 src/types/form/WorkspaceConfirmationForm.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index dc0af7334cda..45d636c0b1df 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -554,8 +554,6 @@ const ONYXKEYS = { ADD_PAYMENT_CARD_FORM_DRAFT: 'addPaymentCardFormDraft', WORKSPACE_SETTINGS_FORM: 'workspaceSettingsForm', WORKSPACE_CATEGORY_FORM: 'workspaceCategoryForm', - WORKSPACE_CONFIRMATION_FORM: 'workspaceConfirmationForm', - WORKSPACE_CONFIRMATION_FORM_DRAFT: 'workspaceConfirmationFormDraft', WORKSPACE_CATEGORY_FORM_DRAFT: 'workspaceCategoryFormDraft', WORKSPACE_CATEGORY_DESCRIPTION_HINT_FORM: 'workspaceCategoryDescriptionHintForm', WORKSPACE_CATEGORY_DESCRIPTION_HINT_FORM_DRAFT: 'workspaceCategoryDescriptionHintFormDraft', @@ -735,7 +733,6 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM]: FormTypes.AddPaymentCardForm; [ONYXKEYS.FORMS.WORKSPACE_SETTINGS_FORM]: FormTypes.WorkspaceSettingsForm; [ONYXKEYS.FORMS.WORKSPACE_CATEGORY_FORM]: FormTypes.WorkspaceCategoryForm; - [ONYXKEYS.FORMS.WORKSPACE_CONFIRMATION_FORM]: FormTypes.WorkspaceConfirmationForm; [ONYXKEYS.FORMS.WORKSPACE_TAG_FORM]: FormTypes.WorkspaceTagForm; [ONYXKEYS.FORMS.WORKSPACE_TAX_CUSTOM_NAME]: FormTypes.WorkspaceTaxCustomName; [ONYXKEYS.FORMS.WORKSPACE_COMPANY_CARD_FEED_NAME]: FormTypes.WorkspaceCompanyCardFeedName; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 171d9218e2f0..4abd5c6d3d49 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1387,8 +1387,8 @@ const ROUTES = { }, WELCOME_VIDEO_ROOT: 'onboarding/welcome-video', EXPLANATION_MODAL_ROOT: 'onboarding/explanation', - WORKSPACE_CONFIRMATION: 'workspace/confirmation', MIGRATED_USER_WELCOME_MODAL: 'onboarding/migrated-user-welcome', + TRANSACTION_RECEIPT: { route: 'r/:reportID/transaction/:transactionID/receipt', getRoute: (reportID: string, transactionID: string, readonly = false, isFromReviewDuplicates = false) => diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 7fc11413ca95..47090bd7075b 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -156,7 +156,6 @@ const SCREENS = { DETAILS: 'Details', PROFILE: 'Profile', REPORT_DETAILS: 'Report_Details', - WORKSPACE_CONFIRMATION: 'Workspace_Confirmation', REPORT_SETTINGS: 'Report_Settings', REPORT_DESCRIPTION: 'Report_Description', PARTICIPANTS: 'Participants', @@ -318,8 +317,6 @@ const SCREENS = { EXPORT: 'Report_Details_Export', }, - WORKSPACE_CONFIRMATION: {ROOT: 'Workspace_Confirmation_Root'}, - WORKSPACE: { ACCOUNTING: { ROOT: 'Policy_Accounting', diff --git a/src/components/CurrencyPicker.tsx b/src/components/CurrencyPicker.tsx deleted file mode 100644 index 7f60eb94fc34..000000000000 --- a/src/components/CurrencyPicker.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import React, {forwardRef, useState} from 'react'; -import type {ForwardedRef} from 'react'; -import {View} from 'react-native'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useThemeStyles from '@hooks/useThemeStyles'; -import variables from '@styles/variables'; -import CONST from '@src/CONST'; -import CurrencySelectionListWithOnyx from './CurrencySelectionList'; -import HeaderWithBackButton from './HeaderWithBackButton'; -import MenuItemWithTopDescription from './MenuItemWithTopDescription'; -import Modal from './Modal'; -import ScreenWrapper from './ScreenWrapper'; -import type {ValuePickerItem, ValuePickerProps} from './ValuePicker/types'; - -type CurrencyPickerProps = { - selectedCurrency?: string; -}; -function CurrencyPicker({selectedCurrency, label, errorText = '', value, onInputChange, furtherDetails}: ValuePickerProps & CurrencyPickerProps, forwardedRef: ForwardedRef) { - const StyleUtils = useStyleUtils(); - const styles = useThemeStyles(); - const [isPickerVisible, setIsPickerVisible] = useState(false); - - const showPickerModal = () => { - setIsPickerVisible(true); - }; - - const hidePickerModal = () => { - setIsPickerVisible(false); - }; - - const updateInput = (item: ValuePickerItem) => { - if (item.value !== selectedCurrency) { - onInputChange?.(item.value); - } - hidePickerModal(); - }; - - const descStyle = !selectedCurrency || selectedCurrency.length === 0 ? StyleUtils.getFontSizeStyle(variables.fontSizeLabel) : null; - - return ( - - - - hidePickerModal} - onModalHide={hidePickerModal} - hideModalContentWhileAnimating - useNativeDriver - onBackdropPress={hidePickerModal} - > - - - updateInput({value: item.currencyCode})} - searchInputLabel="Currency" - initiallySelectedCurrencyCode={selectedCurrency} - /> - - - - ); -} - -CurrencyPicker.displayName = 'CurrencyPicker'; - -export default forwardRef(CurrencyPicker); diff --git a/src/languages/en.ts b/src/languages/en.ts index 26f7875e53ee..5c2cb34dc251 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3716,7 +3716,7 @@ const translations = { }, emptyWorkspace: { title: 'Create a workspace', - subtitle: 'Create a workspace to track receipts, reimburse expenses, send invoices, and more — all at the speed of chat.', + subtitle: 'Create a workspace to track receipts, reimburse expenses, send invoices, and more -- all at the speed of chat.', createAWorkspaceCTA: 'Get Started', features: { trackAndCollect: 'Track and collect receipts', @@ -3734,7 +3734,6 @@ const translations = { new: { newWorkspace: 'New workspace', getTheExpensifyCardAndMore: 'Get the Expensify Card and more', - confirmWorkspace: 'Confirm Workspace', }, people: { genericFailureMessage: 'An error occurred removing a member from the workspace, please try again.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 66940ef87c6f..2370fd0a1a9d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3779,7 +3779,6 @@ const translations = { new: { newWorkspace: 'Nuevo espacio de trabajo', getTheExpensifyCardAndMore: 'Consigue la Tarjeta Expensify y más', - confirmWorkspace: 'Confirmar espacio de trabajo', }, people: { genericFailureMessage: 'Se ha producido un error al intentar eliminar a un miembro del espacio de trabajo. Por favor, inténtalo más tarde.', diff --git a/src/libs/API/parameters/CreateWorkspaceParams.ts b/src/libs/API/parameters/CreateWorkspaceParams.ts index 313ef1bd6268..91c1039169aa 100644 --- a/src/libs/API/parameters/CreateWorkspaceParams.ts +++ b/src/libs/API/parameters/CreateWorkspaceParams.ts @@ -11,8 +11,6 @@ type CreateWorkspaceParams = { customUnitID: string; customUnitRateID: string; engagementChoice?: string; - currency: string; - file?: File; }; export default CreateWorkspaceParams; diff --git a/src/libs/CurrencyUtils.ts b/src/libs/CurrencyUtils.ts index 32fc1c11984c..26a5d209b0ff 100644 --- a/src/libs/CurrencyUtils.ts +++ b/src/libs/CurrencyUtils.ts @@ -2,7 +2,6 @@ import Onyx from 'react-native-onyx'; import CONST from '@src/CONST'; import type {OnyxValues} from '@src/ONYXKEYS'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Currency} from '@src/types/onyx'; import BaseLocaleListener from './Localize/LocaleListener/BaseLocaleListener'; import * as NumberFormatUtils from './NumberFormatUtils'; @@ -31,11 +30,6 @@ function getCurrencyDecimals(currency: string = CONST.CURRENCY.USD): number { return decimals ?? 2; } -function getCurrency(currency: string = CONST.CURRENCY.USD): Currency | null { - const currencyItem = currencyList?.[currency]; - return currencyItem; -} - /** * Returns the currency's minor unit quantity * e.g. Cent in USD @@ -222,6 +216,5 @@ export { convertToDisplayStringWithoutCurrency, isValidCurrencyCode, convertToShortDisplayString, - getCurrency, sanitizeCurrencyCode, }; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 3f78b39c596c..edc32bb705b6 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -31,7 +31,6 @@ import type { TransactionDuplicateNavigatorParamList, TravelNavigatorParamList, WalletStatementNavigatorParamList, - WorkspaceConfirmationNavigatorParamList, } from '@navigation/types'; import type {Screen} from '@src/SCREENS'; import SCREENS from '@src/SCREENS'; @@ -130,10 +129,6 @@ const ReportSettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/Report/VisibilityPage').default, }); -const WorkspaceConfirmationModalStackNavigator = createModalStackNavigator({ - [SCREENS.WORKSPACE_CONFIRMATION.ROOT]: () => require('../../../../pages/workspace/WorkspaceConfirmationPage').default, -}); - const TaskModalStackNavigator = createModalStackNavigator({ [SCREENS.TASK.TITLE]: () => require('../../../../pages/tasks/TaskTitlePage').default, [SCREENS.TASK.ASSIGNEE]: () => require('../../../../pages/tasks/TaskAssigneeSelectorModal').default, @@ -720,5 +715,4 @@ export { SearchSavedSearchModalStackNavigator, MissingPersonalDetailsModalStackNavigator, DebugModalStackNavigator, - WorkspaceConfirmationModalStackNavigator, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index 535232de4d17..c996f380e98c 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -134,10 +134,6 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { name={SCREENS.RIGHT_MODAL.MONEY_REQUEST} component={ModalStackNavigators.MoneyRequestModalStackNavigator} /> - ['config'] = { }, }, }, - [SCREENS.RIGHT_MODAL.WORKSPACE_CONFIRMATION]: { - screens: { - [SCREENS.WORKSPACE_CONFIRMATION.ROOT]: ROUTES.WORKSPACE_CONFIRMATION, - }, - }, [SCREENS.RIGHT_MODAL.NEW_TASK]: { screens: { [SCREENS.NEW_TASK.ROOT]: ROUTES.NEW_TASK.route, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index ecc2b6d157f8..86948ea7f099 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -1206,10 +1206,6 @@ type MoneyRequestNavigatorParamList = { }; }; -type WorkspaceConfirmationNavigatorParamList = { - [SCREENS.WORKSPACE_CONFIRMATION.ROOT]: undefined; -}; - type NewTaskNavigatorParamList = { [SCREENS.NEW_TASK.ROOT]: { backTo?: Routes; @@ -1386,7 +1382,6 @@ type RightModalNavigatorParamList = { [SCREENS.RIGHT_MODAL.PARTICIPANTS]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.ROOM_MEMBERS]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.MONEY_REQUEST]: NavigatorScreenParams; - [SCREENS.RIGHT_MODAL.WORKSPACE_CONFIRMATION]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.NEW_TASK]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.TEACHERS_UNITE]: NavigatorScreenParams; [SCREENS.RIGHT_MODAL.TASK_DETAILS]: NavigatorScreenParams; @@ -1776,6 +1771,5 @@ export type { RestrictedActionParamList, MissingPersonalDetailsParamList, DebugParamList, - WorkspaceConfirmationNavigatorParamList, MigratedUserModalNavigatorParamList, }; diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index dc812c689c0a..61ce04655ae5 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -367,21 +367,10 @@ function endSignOnTransition() { * @param [transitionFromOldDot] Optional, if the user is transitioning from old dot * @param [makeMeAdmin] Optional, leave the calling account as an admin on the policy * @param [backTo] An optional return path. If provided, it will be URL-encoded and appended to the resulting URL. - * @param [policyID] Optional, Policy id. - * @param [file],file */ -function createWorkspaceWithPolicyDraftAndNavigateToIt( - policyOwnerEmail = '', - policyName = '', - transitionFromOldDot = false, - makeMeAdmin = false, - backTo = '', - policyID = '', - currency?: string, - file?: File, -) { - const genereatedPolicyID = Policy.generatePolicyID(); - Policy.createDraftInitialWorkspace(policyOwnerEmail, policyName, policyID || genereatedPolicyID, makeMeAdmin, currency, file); +function createWorkspaceWithPolicyDraftAndNavigateToIt(policyOwnerEmail = '', policyName = '', transitionFromOldDot = false, makeMeAdmin = false, backTo = '') { + const policyID = Policy.generatePolicyID(); + Policy.createDraftInitialWorkspace(policyOwnerEmail, policyName, policyID, makeMeAdmin); Navigation.isNavigationReady() .then(() => { @@ -389,7 +378,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt( // We must call goBack() to remove the /transition route from history Navigation.goBack(); } - savePolicyDraftByNewWorkspace(policyID, policyName, policyOwnerEmail, makeMeAdmin, currency, file); + savePolicyDraftByNewWorkspace(policyID, policyName, policyOwnerEmail, makeMeAdmin); Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID, backTo)); }) .then(endSignOnTransition); @@ -403,8 +392,8 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt( * @param [policyOwnerEmail] Optional, the email of the account to make the owner of the policy * @param [makeMeAdmin] Optional, leave the calling account as an admin on the policy */ -function savePolicyDraftByNewWorkspace(policyID?: string, policyName?: string, policyOwnerEmail = '', makeMeAdmin = false, currency = '', file?: File) { - Policy.createWorkspace(policyOwnerEmail, makeMeAdmin, policyName, policyID, '', currency, file); +function savePolicyDraftByNewWorkspace(policyID?: string, policyName?: string, policyOwnerEmail = '', makeMeAdmin = false) { + Policy.createWorkspace(policyOwnerEmail, makeMeAdmin, policyName, policyID); } /** diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 308c006de81c..35136a1691cf 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -1563,9 +1563,9 @@ function buildOptimisticDistanceRateCustomUnits(reportCurrency?: string): Optimi * @param [policyID] custom policy id we will use for created workspace * @param [makeMeAdmin] leave the calling account as an admin on the policy */ -function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', policyID = generatePolicyID(), makeMeAdmin = false, currency = '', file?: File) { +function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', policyID = generatePolicyID(), makeMeAdmin = false) { const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail); - const {customUnits, outputCurrency} = buildOptimisticDistanceRateCustomUnits(currency); + const {customUnits, outputCurrency} = buildOptimisticDistanceRateCustomUnits(); const optimisticData: OnyxUpdate[] = [ { @@ -1580,14 +1580,12 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol ownerAccountID: sessionAccountID, isPolicyExpenseChatEnabled: true, areCategoriesEnabled: true, - outputCurrency: currency || outputCurrency, + outputCurrency, pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, customUnits, makeMeAdmin, autoReporting: true, autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, - avatarURL: file?.uri ?? null, - originalFileName: file?.name, employeeList: { [sessionEmail]: { role: CONST.POLICY.ROLE.ADMIN, @@ -1619,18 +1617,10 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol * @param [policyID] custom policy id we will use for created workspace * @param [expenseReportId] the reportID of the expense report that is being used to create the workspace */ -function buildPolicyData( - policyOwnerEmail = '', - makeMeAdmin = false, - policyName = '', - policyID = generatePolicyID(), - expenseReportId?: string, - engagementChoice?: string, - currency = '', - file?: File, -) { +function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID(), expenseReportId?: string, engagementChoice?: string) { const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail); - const {customUnits, customUnitID, customUnitRateID, outputCurrency} = buildOptimisticDistanceRateCustomUnits(currency); + + const {customUnits, customUnitID, customUnitRateID, outputCurrency} = buildOptimisticDistanceRateCustomUnits(); const { adminsChatReportID, @@ -1690,8 +1680,6 @@ function buildPolicyData( address: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, description: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, }, - avatarURL: file?.uri, - originalFileName: file?.name, }, }, { @@ -1882,8 +1870,6 @@ function buildPolicyData( customUnitID, customUnitRateID, engagementChoice, - currency: outputCurrency, - file, }; return {successData, optimisticData, failureData, params}; @@ -1898,16 +1884,8 @@ function buildPolicyData( * @param [policyID] custom policy id we will use for created workspace * @param [engagementChoice] Purpose of using application selected by user in guided setup flow */ -function createWorkspace( - policyOwnerEmail = '', - makeMeAdmin = false, - policyName = '', - policyID = generatePolicyID(), - engagementChoice = '', - currency = '', - file?: File, -): CreateWorkspaceParams { - const {optimisticData, failureData, successData, params} = buildPolicyData(policyOwnerEmail, makeMeAdmin, policyName, policyID, undefined, engagementChoice, currency, file); +function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID(), engagementChoice = ''): CreateWorkspaceParams { + const {optimisticData, failureData, successData, params} = buildPolicyData(policyOwnerEmail, makeMeAdmin, policyName, policyID, undefined, engagementChoice); API.write(WRITE_COMMANDS.CREATE_WORKSPACE, params, {optimisticData, successData, failureData}); // Publish a workspace created event if this is their first policy @@ -2008,7 +1986,6 @@ function createDraftWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policy expenseCreatedReportActionID, customUnitID, customUnitRateID, - currency: outputCurrency, }; Onyx.update(optimisticData); diff --git a/src/pages/WorkspaceSwitcherPage/WorkspaceCardCreateAWorkspace.tsx b/src/pages/WorkspaceSwitcherPage/WorkspaceCardCreateAWorkspace.tsx index bf250a063582..4a6b6a473188 100644 --- a/src/pages/WorkspaceSwitcherPage/WorkspaceCardCreateAWorkspace.tsx +++ b/src/pages/WorkspaceSwitcherPage/WorkspaceCardCreateAWorkspace.tsx @@ -5,7 +5,7 @@ import Section, {CARD_LAYOUT} from '@components/Section'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; -import ROUTES from '@src/ROUTES'; +import * as App from '@userActions/App'; function WorkspaceCardCreateAWorkspace() { const styles = useThemeStyles(); @@ -22,7 +22,8 @@ function WorkspaceCardCreateAWorkspace() { >