From 109421eb954a76c78db04abe1e4ac216a433d94c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 25 May 2023 17:26:43 -0600 Subject: [PATCH 01/18] ask to change currency to USD --- src/pages/workspace/WorkspaceInitialPage.js | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index 775898670c46..7fd39bc29cff 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -66,6 +66,7 @@ function dismissError(policyID) { const WorkspaceInitialPage = (props) => { const policy = props.policy; const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [isUpdateCurrencyModalOpen, setIsUpdateCurrencyModalOpen] = useState(false); const hasPolicyCreationError = Boolean(policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && policy.errors); /** @@ -78,6 +79,15 @@ const WorkspaceInitialPage = (props) => { Navigation.navigate(ROUTES.SETTINGS_WORKSPACES); }, [props.reports, policy]); + /** + * Call the delete policy and hide the modal + */ + const confirmCurrencyChangeAndHideModal = useCallback(() => { + Policy.updateGeneralSettings(policy.id, policy.name, CONST.CURRENCY.USD); + setIsUpdateCurrencyModalOpen(false); + ReimbursementAccount.navigateToBankAccountRoute(policy.id) + }, [policy]); + const policyName = lodashGet(policy, 'name', ''); const hasMembersError = PolicyUtils.hasPolicyMemberError(props.policyMemberList); const hasGeneralSettingsError = !_.isEmpty(lodashGet(policy, 'errorFields.generalSettings', {})) || !_.isEmpty(lodashGet(policy, 'errorFields.avatar', {})); @@ -124,7 +134,7 @@ const WorkspaceInitialPage = (props) => { { translationKey: 'workspace.common.bankAccount', icon: Expensicons.Bank, - action: () => ReimbursementAccount.navigateToBankAccountRoute(policy.id), + action: () => policy.outputCurrency === CONST.CURRENCY.USD ? ReimbursementAccount.navigateToBankAccountRoute(policy.id) : setIsUpdateCurrencyModalOpen(true), brickRoadIndicator: !_.isEmpty(props.reimbursementAccount.errors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }, ]; @@ -214,6 +224,16 @@ const WorkspaceInitialPage = (props) => { + setIsUpdateCurrencyModalOpen(false)} + prompt={`Adding a bank account is currently limited to Workspaces using USD as a default currency. Would you like you update ${policy.name}'s default currency to USD?`} + confirmText="Update currency" + cancelText={props.translate('common.cancel')} + danger + /> Date: Tue, 30 May 2023 10:32:55 -0600 Subject: [PATCH 02/18] create WorkspaceUpdateCurrencyModal --- .../workspace/WorkspaceUpdateCurrencyModal.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/pages/workspace/WorkspaceUpdateCurrencyModal.js diff --git a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js new file mode 100644 index 000000000000..7ad589661094 --- /dev/null +++ b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js @@ -0,0 +1,48 @@ +import React from 'react'; +import {withOnyx} from 'react-native-onyx'; +import PropTypes from 'prop-types'; +import compose from '../../libs/compose'; +import ONYXKEYS from '../../ONYXKEYS'; +import ConfirmModal from '../../components/ConfirmModal'; +import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; + +const propTypes = { + /** Reimbursement account data */ + policy: PropTypes.shape({ + outputCurrency: PropTypes.string, + }), + + ...withLocalizePropTypes, +}; + +const defaultProps = { + policy: { + outputCurrency: 'USD', + }, +}; + +const WorkspaceUpdateCurrencyModal = (props) => ( + setIsDeleteModalOpen(false)} + prompt={props.translate('workspace.common.deleteConfirmation')} + confirmText={props.translate('common.delete')} + cancelText={props.translate('common.cancel')} + danger + /> +); + +WorkspaceUpdateCurrencyModal.displayName = 'WorkspaceUpdateCurrencyModal'; +WorkspaceUpdateCurrencyModal.propTypes = propTypes; +WorkspaceUpdateCurrencyModal.defaultProps = defaultProps; + +export default compose( + withLocalize, + withOnyx({ + policy: { + key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID}`, + }, + }), +)(WorkspaceUpdateCurrencyModal); From 742936a2c252e70a3e2534ed3ecc30b7138a7c2d Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 10:38:35 -0600 Subject: [PATCH 03/18] add state, callback methods --- .../workspace/WorkspaceUpdateCurrencyModal.js | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js index 7ad589661094..25e4d2201169 100644 --- a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js +++ b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js @@ -1,14 +1,19 @@ -import React from 'react'; +import React, {useState, useCallback} from 'react'; import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; +import CONST from '../../CONST'; import ConfirmModal from '../../components/ConfirmModal'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; +import * as Policy from '../../libs/actions/Policy'; +import * as ReimbursementAccount from '../../libs/actions/ReimbursementAccount'; const propTypes = { /** Reimbursement account data */ policy: PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, outputCurrency: PropTypes.string, }), @@ -17,22 +22,37 @@ const propTypes = { const defaultProps = { policy: { + id: '', + name: '', outputCurrency: 'USD', }, }; -const WorkspaceUpdateCurrencyModal = (props) => ( +const WorkspaceUpdateCurrencyModal = (props) => { + const [isVisible, setIsVisible] = useState(props.policy.outputCurrency !== CONST.CURRENCY.USD); + + /** + * Call update workspace currency and hide the modal + */ + const confirmCurrencyChangeAndHideModal = useCallback(() => { + Policy.updateGeneralSettings(props.policy.id, props.policy.name, CONST.CURRENCY.USD); + setIsVisible(false); + ReimbursementAccount.navigateToBankAccountRoute(props.policy.id) + }, [props.policy]); + + return ( setIsDeleteModalOpen(false)} - prompt={props.translate('workspace.common.deleteConfirmation')} - confirmText={props.translate('common.delete')} - cancelText={props.translate('common.cancel')} - danger - /> -); + title={props.translate('workspace.common.delete')} + isVisible={isVisible} + onConfirm={confirmCurrencyChangeAndHideModal} + onCancel={() => setIsVisible(false)} + prompt={props.translate('workspace.common.deleteConfirmation')} + confirmText={props.translate('common.delete')} + cancelText={props.translate('common.cancel')} + danger + /> + ) +}; WorkspaceUpdateCurrencyModal.displayName = 'WorkspaceUpdateCurrencyModal'; WorkspaceUpdateCurrencyModal.propTypes = propTypes; From 852597f50cc04248c3c43a4972725ee5e60f20a0 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 10:39:29 -0600 Subject: [PATCH 04/18] rename method --- src/pages/workspace/WorkspaceUpdateCurrencyModal.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js index 25e4d2201169..942c7e5d0c9f 100644 --- a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js +++ b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js @@ -31,10 +31,7 @@ const defaultProps = { const WorkspaceUpdateCurrencyModal = (props) => { const [isVisible, setIsVisible] = useState(props.policy.outputCurrency !== CONST.CURRENCY.USD); - /** - * Call update workspace currency and hide the modal - */ - const confirmCurrencyChangeAndHideModal = useCallback(() => { + const confirmUpdateCurrencyAndHideModal = useCallback(() => { Policy.updateGeneralSettings(props.policy.id, props.policy.name, CONST.CURRENCY.USD); setIsVisible(false); ReimbursementAccount.navigateToBankAccountRoute(props.policy.id) @@ -44,7 +41,7 @@ const WorkspaceUpdateCurrencyModal = (props) => { setIsVisible(false)} prompt={props.translate('workspace.common.deleteConfirmation')} confirmText={props.translate('common.delete')} From ea7b72bbfe1dd567881e0730cb2b7fc2f3c8ff91 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 12:39:52 -0600 Subject: [PATCH 05/18] redirect to workspace page --- .../ReimbursementAccount/ReimbursementAccountPage.js | 11 +++++++++++ src/pages/workspace/WorkspaceUpdateCurrencyModal.js | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 5ec8159d6761..20f5b5e1c230 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -100,6 +100,7 @@ class ReimbursementAccountPage extends React.Component { this.continue = this.continue.bind(this); this.getDefaultStateForField = this.getDefaultStateForField.bind(this); this.goBack = this.goBack.bind(this); + this.isNavigating = false; // The first time we open this page, the props.reimbursementAccount has not been loaded from the server. // Calculating shouldShowContinueSetupButton on the default data doesn't make sense, and we should recalculate @@ -112,10 +113,20 @@ class ReimbursementAccountPage extends React.Component { } componentDidMount() { + if (this.props.policy.outputCurrency !== CONST.CURRENCY.USD) { + Navigation.navigate(ROUTES.getWorkspaceInitialRoute(this.props.policy.id)); + this.isNavigating = true; + return; + } + this.fetchData(); } componentDidUpdate(prevProps) { + if (this.isNavigating) { + return; + } + if (prevProps.network.isOffline && !this.props.network.isOffline && prevProps.reimbursementAccount.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { this.fetchData(); } diff --git a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js index 942c7e5d0c9f..ec6bcad34940 100644 --- a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js +++ b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js @@ -57,9 +57,4 @@ WorkspaceUpdateCurrencyModal.defaultProps = defaultProps; export default compose( withLocalize, - withOnyx({ - policy: { - key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY}${route.params.policyID}`, - }, - }), )(WorkspaceUpdateCurrencyModal); From cac93b30dea1b2030205199ed48bc914741687c0 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 13:25:38 -0600 Subject: [PATCH 06/18] add error message --- src/languages/en.js | 1 + src/languages/es.js | 1 + .../ReimbursementAccountPage.js | 39 ++++++------------- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index cf01a68cb37a..184b04784f76 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -812,6 +812,7 @@ export default { 'In order to finish setting up your bank account, you must validate your account. Please check your email to validate your account, and return here to finish up!', hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', + hasCurrencyError: 'Unsupported currency', error: { noBankAccountAvailable: 'Sorry, no bank account is available', noBankAccountSelected: 'Please choose an account', diff --git a/src/languages/es.js b/src/languages/es.js index b845ed6b8a63..b196f189574f 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -814,6 +814,7 @@ export default { hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes agregar tu número de teléfono como nombre de usuario secundario.', hasBeenThrottledError: 'Se produjo un error al intentar agregar tu cuenta bancaria. Por favor, espera unos minutos e inténtalo de nuevo.', + hasCurrencyError: 'Unsupported currency', error: { noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible', noBankAccountSelected: 'Por favor, elige una cuenta bancaria', diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 20f5b5e1c230..9f55f6dbe105 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -113,20 +113,10 @@ class ReimbursementAccountPage extends React.Component { } componentDidMount() { - if (this.props.policy.outputCurrency !== CONST.CURRENCY.USD) { - Navigation.navigate(ROUTES.getWorkspaceInitialRoute(this.props.policy.id)); - this.isNavigating = true; - return; - } - this.fetchData(); } componentDidUpdate(prevProps) { - if (this.isNavigating) { - return; - } - if (prevProps.network.isOffline && !this.props.network.isOffline && prevProps.reimbursementAccount.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) { this.fetchData(); } @@ -364,27 +354,20 @@ class ReimbursementAccountPage extends React.Component { ); } - let errorComponent; + let errorText; const userHasPhonePrimaryEmail = Str.endsWith(this.props.session.email, CONST.SMS.DOMAIN); + const throttledDate = lodashGet(this.props.reimbursementAccount, 'throttledDate'); + const hasUnsupportedCurrency = lodashGet(this.props.policy, 'outputCurrency', '') !== CONST.CURRENCY.USD; if (userHasPhonePrimaryEmail) { - errorComponent = ( - - {this.props.translate('bankAccount.hasPhoneLoginError')} - - ); - } - - const throttledDate = lodashGet(this.props.reimbursementAccount, 'throttledDate'); - if (throttledDate) { - errorComponent = ( - - {this.props.translate('bankAccount.hasBeenThrottledError')} - - ); + errorText = this.props.translate('bankAccount.hasPhoneLoginError'); + } else if (throttledDate) { + errorText = this.props.translate('bankAccount.hasPhoneLoginError'); + } else if (hasUnsupportedCurrency) { + errorText = this.props.translate('bankAccount.hasCurrencyError'); } - if (errorComponent) { + if (errorText) { return ( - {errorComponent} + + {errorText} + ); } From d408b8cea070fb85af2bdb271d71ad9d469745f5 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 13:33:58 -0600 Subject: [PATCH 07/18] update translate --- src/languages/en.js | 5 +++-- src/languages/es.js | 5 +++-- .../ReimbursementAccountPage.js | 1 - src/pages/workspace/WorkspaceInitialPage.js | 14 +++++++------- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 184b04784f76..4622bb39dfec 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -1067,8 +1067,6 @@ export default { reconcileCards: 'Reconcile cards', settlementFrequency: 'Settlement frequency', deleteConfirmation: 'Are you sure you want to delete this workspace?', - growlMessageOnDelete: 'Workspace deleted', - growlMessageOnDeleteError: 'This workspace cannot be deleted right now because reports are actively being processed', unavailable: 'Unavailable workspace', memberNotFound: 'Member not found. To invite a new member to the workspace, please use the Invite button above.', goToRoom: ({roomName}) => `Go to ${roomName} room`, @@ -1200,6 +1198,9 @@ export default { bankAccountAnyTransactions: ' bank account. Any outstanding transactions for this account will still complete.', clearProgress: 'Starting over will clear the progress you have made so far.', areYouSure: 'Are you sure?', + updateCurrency: 'Update currency title', + updateCurrencyPrompt: 'Update currency prompt', + confirmUpdateCurrency: 'Update currency button', }, }, getAssistancePage: { diff --git a/src/languages/es.js b/src/languages/es.js index b196f189574f..f0452d5c3118 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -1071,9 +1071,7 @@ export default { issueAndManageCards: 'Emitir y gestionar tarjetas', reconcileCards: 'Reconciliar tarjetas', settlementFrequency: 'Frecuencia de liquidación', - growlMessageOnDelete: 'Espacio de trabajo eliminado', deleteConfirmation: '¿Estás seguro de que quieres eliminar este espacio de trabajo?', - growlMessageOnDeleteError: 'No se puede eliminar el espacio de trabajo porque tiene informes que están siendo procesados', unavailable: 'Espacio de trabajo no disponible', memberNotFound: 'Miembro no encontrado. Para invitar a un nuevo miembro al espacio de trabajo, por favor, utiliza el botón Invitar que está arriba.', goToRoom: ({roomName}) => `Ir a la sala ${roomName}`, @@ -1206,6 +1204,9 @@ export default { bankAccountAnyTransactions: '. Los reembolsos pendientes serán completados sin problemas.', clearProgress: 'Empezar de nuevo descartará lo completado hasta ahora.', areYouSure: '¿Estás seguro?', + updateCurrency: 'Update currency title', + updateCurrencyPrompt: 'Update currency prompt', + confirmUpdateCurrency: 'Update currency button', }, }, getAssistancePage: { diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 9f55f6dbe105..3c51853ea9bb 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -100,7 +100,6 @@ class ReimbursementAccountPage extends React.Component { this.continue = this.continue.bind(this); this.getDefaultStateForField = this.getDefaultStateForField.bind(this); this.goBack = this.goBack.bind(this); - this.isNavigating = false; // The first time we open this page, the props.reimbursementAccount has not been loaded from the server. // Calculating shouldShowContinueSetupButton on the default data doesn't make sense, and we should recalculate diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index 6b66880333db..3b3252a987ec 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -66,7 +66,7 @@ function dismissError(policyID) { const WorkspaceInitialPage = (props) => { const policy = props.policy; const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); - const [isUpdateCurrencyModalOpen, setIsUpdateCurrencyModalOpen] = useState(false); + const [isCurrencyModalOpen, setIsCurrencyModalOpen] = useState(false); const hasPolicyCreationError = Boolean(policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && policy.errors); /** @@ -84,7 +84,7 @@ const WorkspaceInitialPage = (props) => { */ const confirmCurrencyChangeAndHideModal = useCallback(() => { Policy.updateGeneralSettings(policy.id, policy.name, CONST.CURRENCY.USD); - setIsUpdateCurrencyModalOpen(false); + setIsCurrencyModalOpen(false); ReimbursementAccount.navigateToBankAccountRoute(policy.id) }, [policy]); @@ -249,12 +249,12 @@ const WorkspaceInitialPage = (props) => { setIsUpdateCurrencyModalOpen(false)} - prompt={`Adding a bank account is currently limited to Workspaces using USD as a default currency. Would you like you update ${policy.name}'s default currency to USD?`} - confirmText="Update currency" + onCancel={() => setIsCurrencyModalOpen(false)} + prompt={props.translate('workspace.bankAccount.updateCurrencyPrompt')} + confirmText={props.translate('workspace.bankAccount.confirmUpdateCurrency')} cancelText={props.translate('common.cancel')} danger /> From 6e3b32caec0d21c8e2f8832b44360881cde9625c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 13:35:19 -0600 Subject: [PATCH 08/18] fix callback type --- src/pages/workspace/WorkspaceInitialPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index 3b3252a987ec..e319fb61beed 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -146,7 +146,7 @@ const WorkspaceInitialPage = (props) => { { translationKey: 'workspace.common.bankAccount', icon: Expensicons.Bank, - action: () => policy.outputCurrency === CONST.CURRENCY.USD ? ReimbursementAccount.navigateToBankAccountRoute(policy.id) : setIsUpdateCurrencyModalOpen(true), + action: () => policy.outputCurrency === CONST.CURRENCY.USD ? ReimbursementAccount.navigateToBankAccountRoute(policy.id) : setIsCurrencyModalOpen(true), brickRoadIndicator: !_.isEmpty(props.reimbursementAccount.errors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }, ]; From f091adf2594049682f7e3ae04a8a5b825257dce9 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 13:37:51 -0600 Subject: [PATCH 09/18] update copy path --- src/pages/workspace/WorkspaceInitialPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index e319fb61beed..4daa6ce3dc56 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -249,7 +249,7 @@ const WorkspaceInitialPage = (props) => { setIsCurrencyModalOpen(false)} From c31bed2850323bd47497c3099d67163f89709913 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 13:38:35 -0600 Subject: [PATCH 10/18] rm WorkspaceUpdateCurrencyModal --- .../workspace/WorkspaceUpdateCurrencyModal.js | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 src/pages/workspace/WorkspaceUpdateCurrencyModal.js diff --git a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js b/src/pages/workspace/WorkspaceUpdateCurrencyModal.js deleted file mode 100644 index ec6bcad34940..000000000000 --- a/src/pages/workspace/WorkspaceUpdateCurrencyModal.js +++ /dev/null @@ -1,60 +0,0 @@ -import React, {useState, useCallback} from 'react'; -import {withOnyx} from 'react-native-onyx'; -import PropTypes from 'prop-types'; -import compose from '../../libs/compose'; -import ONYXKEYS from '../../ONYXKEYS'; -import CONST from '../../CONST'; -import ConfirmModal from '../../components/ConfirmModal'; -import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import * as Policy from '../../libs/actions/Policy'; -import * as ReimbursementAccount from '../../libs/actions/ReimbursementAccount'; - -const propTypes = { - /** Reimbursement account data */ - policy: PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - outputCurrency: PropTypes.string, - }), - - ...withLocalizePropTypes, -}; - -const defaultProps = { - policy: { - id: '', - name: '', - outputCurrency: 'USD', - }, -}; - -const WorkspaceUpdateCurrencyModal = (props) => { - const [isVisible, setIsVisible] = useState(props.policy.outputCurrency !== CONST.CURRENCY.USD); - - const confirmUpdateCurrencyAndHideModal = useCallback(() => { - Policy.updateGeneralSettings(props.policy.id, props.policy.name, CONST.CURRENCY.USD); - setIsVisible(false); - ReimbursementAccount.navigateToBankAccountRoute(props.policy.id) - }, [props.policy]); - - return ( - setIsVisible(false)} - prompt={props.translate('workspace.common.deleteConfirmation')} - confirmText={props.translate('common.delete')} - cancelText={props.translate('common.cancel')} - danger - /> - ) -}; - -WorkspaceUpdateCurrencyModal.displayName = 'WorkspaceUpdateCurrencyModal'; -WorkspaceUpdateCurrencyModal.propTypes = propTypes; -WorkspaceUpdateCurrencyModal.defaultProps = defaultProps; - -export default compose( - withLocalize, -)(WorkspaceUpdateCurrencyModal); From f5fe5f93baf02aa8c00fd613134b6a5e86a6ab2c Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Tue, 30 May 2023 13:47:45 -0600 Subject: [PATCH 11/18] fix style --- src/languages/en.js | 2 +- src/pages/workspace/WorkspaceInitialPage.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 4622bb39dfec..480150eebe74 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -812,7 +812,7 @@ export default { 'In order to finish setting up your bank account, you must validate your account. Please check your email to validate your account, and return here to finish up!', hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', - hasCurrencyError: 'Unsupported currency', + hasCurrencyError: 'Unsupported currency', error: { noBankAccountAvailable: 'Sorry, no bank account is available', noBankAccountSelected: 'Please choose an account', diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index 4daa6ce3dc56..b8783b15c81f 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -85,9 +85,9 @@ const WorkspaceInitialPage = (props) => { const confirmCurrencyChangeAndHideModal = useCallback(() => { Policy.updateGeneralSettings(policy.id, policy.name, CONST.CURRENCY.USD); setIsCurrencyModalOpen(false); - ReimbursementAccount.navigateToBankAccountRoute(policy.id) + ReimbursementAccount.navigateToBankAccountRoute(policy.id); }, [policy]); - + /** * Navigates to workspace rooms * @param {String} chatType @@ -146,7 +146,7 @@ const WorkspaceInitialPage = (props) => { { translationKey: 'workspace.common.bankAccount', icon: Expensicons.Bank, - action: () => policy.outputCurrency === CONST.CURRENCY.USD ? ReimbursementAccount.navigateToBankAccountRoute(policy.id) : setIsCurrencyModalOpen(true), + action: () => (policy.outputCurrency === CONST.CURRENCY.USD ? ReimbursementAccount.navigateToBankAccountRoute(policy.id) : setIsCurrencyModalOpen(true)), brickRoadIndicator: !_.isEmpty(props.reimbursementAccount.errors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }, ]; From 0b49f6c8b5ac235479a73badd4e3ca94a5f13e67 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 8 Jun 2023 12:39:28 -0600 Subject: [PATCH 12/18] update modal copy --- src/languages/en.js | 6 +++--- src/languages/es.js | 6 +++--- src/pages/workspace/WorkspaceInitialPage.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 9c5d03879291..51126b0eac17 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -1203,9 +1203,9 @@ export default { bankAccountAnyTransactions: ' bank account. Any outstanding transactions for this account will still complete.', clearProgress: 'Starting over will clear the progress you have made so far.', areYouSure: 'Are you sure?', - updateCurrency: 'Update currency title', - updateCurrencyPrompt: 'Update currency prompt', - confirmUpdateCurrency: 'Update currency button', + workspaceCurrency: 'Workspace currency', + updateCurrencyPrompt: 'It looks like your Workspace is currently set to a different currency than USD. Please click the button below to update your currency to USD now.', + updateToUSD: 'Update to USD', }, }, getAssistancePage: { diff --git a/src/languages/es.js b/src/languages/es.js index 68255899c218..3197eb2ffc54 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -1209,9 +1209,9 @@ export default { bankAccountAnyTransactions: '. Los reembolsos pendientes serán completados sin problemas.', clearProgress: 'Empezar de nuevo descartará lo completado hasta ahora.', areYouSure: '¿Estás seguro?', - updateCurrency: 'Update currency title', - updateCurrencyPrompt: 'Update currency prompt', - confirmUpdateCurrency: 'Update currency button', + workspaceCurrency: 'Moneda del espacio de trabajo', + updateCurrencyPrompt: 'Parece que tu espacio de trabajo está configurado actualmente en una moneda diferente a USD. Por favor, haz clic en el botón de abajo para actualizar tu moneda a USD ahora.', + updateToUSD: 'Actualizar a USD', }, }, getAssistancePage: { diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index b38e2d255813..825546aab0d4 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -248,12 +248,12 @@ const WorkspaceInitialPage = (props) => { setIsCurrencyModalOpen(false)} prompt={props.translate('workspace.bankAccount.updateCurrencyPrompt')} - confirmText={props.translate('workspace.bankAccount.confirmUpdateCurrency')} + confirmText={props.translate('workspace.bankAccount.updateToUSD')} cancelText={props.translate('common.cancel')} danger /> From e8af5b0e1449fa52e670be165cb6a190a21085ea Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 8 Jun 2023 12:56:47 -0600 Subject: [PATCH 13/18] update error copy --- src/languages/en.js | 2 +- src/languages/es.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 51126b0eac17..6fe593d1dae2 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -816,7 +816,7 @@ export default { 'In order to finish setting up your bank account, you must validate your account. Please check your email to validate your account, and return here to finish up!', hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', - hasCurrencyError: 'Unsupported currency', + hasCurrencyError: 'Oops! It appears that your workspace currency is set to a different currency than USD. To proceed, please update your workspace currency and try again', error: { noBankAccountAvailable: 'Sorry, no bank account is available', noBankAccountSelected: 'Please choose an account', diff --git a/src/languages/es.js b/src/languages/es.js index 3197eb2ffc54..fd3bf6afce93 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -818,7 +818,7 @@ export default { hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes agregar tu número de teléfono como nombre de usuario secundario.', hasBeenThrottledError: 'Se produjo un error al intentar agregar tu cuenta bancaria. Por favor, espera unos minutos e inténtalo de nuevo.', - hasCurrencyError: 'Unsupported currency', + hasCurrencyError: '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente a USD. Para continuar, por favor actualiza la moneda de tu espacio de trabajo e inténtalo nuevamente.', error: { noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible', noBankAccountSelected: 'Por favor, elige una cuenta bancaria', From 1841745ff082f5449948ff2bc903dc03becb9361 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 8 Jun 2023 13:01:25 -0600 Subject: [PATCH 14/18] use more explicit copy --- src/languages/en.js | 2 +- src/languages/es.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 6fe593d1dae2..8b0c7362c78d 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -816,7 +816,7 @@ export default { 'In order to finish setting up your bank account, you must validate your account. Please check your email to validate your account, and return here to finish up!', hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', - hasCurrencyError: 'Oops! It appears that your workspace currency is set to a different currency than USD. To proceed, please update your workspace currency and try again', + hasCurrencyError: 'Oops! It appears that your workspace currency is set to a different currency than USD. To proceed, please set it to USD and try again', error: { noBankAccountAvailable: 'Sorry, no bank account is available', noBankAccountSelected: 'Please choose an account', diff --git a/src/languages/es.js b/src/languages/es.js index fd3bf6afce93..289d8d5cf1d0 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -818,7 +818,7 @@ export default { hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes agregar tu número de teléfono como nombre de usuario secundario.', hasBeenThrottledError: 'Se produjo un error al intentar agregar tu cuenta bancaria. Por favor, espera unos minutos e inténtalo de nuevo.', - hasCurrencyError: '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente a USD. Para continuar, por favor actualiza la moneda de tu espacio de trabajo e inténtalo nuevamente.', + hasCurrencyError: '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente al USD. Para continuar, por favor configúrala en USD e inténtalo nuevamente.', error: { noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible', noBankAccountSelected: 'Por favor, elige una cuenta bancaria', From 23e5c97308ded3a26452dd118cb2c1c2ffeec005 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 8 Jun 2023 13:02:00 -0600 Subject: [PATCH 15/18] fix typo --- src/languages/es.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.js b/src/languages/es.js index 289d8d5cf1d0..cedfa0acce91 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -818,7 +818,7 @@ export default { hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes agregar tu número de teléfono como nombre de usuario secundario.', hasBeenThrottledError: 'Se produjo un error al intentar agregar tu cuenta bancaria. Por favor, espera unos minutos e inténtalo de nuevo.', - hasCurrencyError: '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente al USD. Para continuar, por favor configúrala en USD e inténtalo nuevamente.', + hasCurrencyError: '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente a USD. Para continuar, por favor configúrala en USD e inténtalo nuevamente.', error: { noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible', noBankAccountSelected: 'Por favor, elige una cuenta bancaria', From 96dee89a9d5af57f6d8ae59df894622f99a91f8b Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 8 Jun 2023 13:23:44 -0600 Subject: [PATCH 16/18] fix style --- src/languages/es.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/languages/es.js b/src/languages/es.js index cedfa0acce91..8ea21ca65800 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -818,7 +818,8 @@ export default { hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes agregar tu número de teléfono como nombre de usuario secundario.', hasBeenThrottledError: 'Se produjo un error al intentar agregar tu cuenta bancaria. Por favor, espera unos minutos e inténtalo de nuevo.', - hasCurrencyError: '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente a USD. Para continuar, por favor configúrala en USD e inténtalo nuevamente.', + hasCurrencyError: + '¡Ups! Parece que la moneda de tu espacio de trabajo está configurada en una moneda diferente a USD. Para continuar, por favor configúrala en USD e inténtalo nuevamente.', error: { noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible', noBankAccountSelected: 'Por favor, elige una cuenta bancaria', @@ -1210,7 +1211,8 @@ export default { clearProgress: 'Empezar de nuevo descartará lo completado hasta ahora.', areYouSure: '¿Estás seguro?', workspaceCurrency: 'Moneda del espacio de trabajo', - updateCurrencyPrompt: 'Parece que tu espacio de trabajo está configurado actualmente en una moneda diferente a USD. Por favor, haz clic en el botón de abajo para actualizar tu moneda a USD ahora.', + updateCurrencyPrompt: + 'Parece que tu espacio de trabajo está configurado actualmente en una moneda diferente a USD. Por favor, haz clic en el botón de abajo para actualizar tu moneda a USD ahora.', updateToUSD: 'Actualizar a USD', }, }, From d3d6256b5a24816aef5ae7ed976de22d4e0dc06f Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 14 Jun 2023 12:28:28 -0600 Subject: [PATCH 17/18] use onyx set --- src/libs/actions/Policy.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 66bcf0ba1392..f413604e93ec 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -512,9 +512,12 @@ function clearAvatarErrors(policyID) { function updateGeneralSettings(policyID, name, currency) { const optimisticData = [ { - onyxMethod: Onyx.METHOD.MERGE, + // We use SET because it's faster than merge and avoids a race condition when setting the currency and navigating the user to the Bank account page in confirmCurrencyChangeAndHideModal + onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { + ...allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`], + pendingFields: { generalSettings: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, From e3bc7d9806c449a77ac97ab3243136e21309a0c6 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 16 Jun 2023 09:13:44 -0600 Subject: [PATCH 18/18] add correct error --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index b1a81c49608a..c11aa17a355d 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -361,7 +361,7 @@ class ReimbursementAccountPage extends React.Component { if (userHasPhonePrimaryEmail) { errorText = this.props.translate('bankAccount.hasPhoneLoginError'); } else if (throttledDate) { - errorText = this.props.translate('bankAccount.hasPhoneLoginError'); + errorText = this.props.translate('bankAccount.hasBeenThrottledError'); } else if (hasUnsupportedCurrency) { errorText = this.props.translate('bankAccount.hasCurrencyError'); }