diff --git a/src/languages/en.js b/src/languages/en.js index 4602931ff120..8b0c7362c78d 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -816,6 +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 set it to USD and try again', error: { noBankAccountAvailable: 'Sorry, no bank account is available', noBankAccountSelected: 'Please choose an account', @@ -1070,8 +1071,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.', notAuthorized: `You do not have access to this page. Are you trying to join the workspace? Please reach out to the owner of this workspace so they can add you as a member! Something else? Reach out to ${CONST.EMAIL.CONCIERGE}`, @@ -1204,6 +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?', + 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 a787607c465d..8ea21ca65800 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -818,6 +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.', error: { noBankAccountAvailable: 'Lo sentimos, no hay ninguna cuenta bancaria disponible', noBankAccountSelected: 'Por favor, elige una cuenta bancaria', @@ -1074,9 +1076,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.', notAuthorized: `No tienes acceso a esta página. ¿Estás tratando de unirte al espacio de trabajo? Comunícate con el propietario de este espacio de trabajo para que pueda agregarte como miembro. ¿Necesitas algo más? Comunícate con ${CONST.EMAIL.CONCIERGE}`, @@ -1210,6 +1210,10 @@ export default { bankAccountAnyTransactions: '. Los reembolsos pendientes serán completados sin problemas.', 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.', + updateToUSD: 'Actualizar a USD', }, }, getAssistancePage: { 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, }, diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 7e18a7edbdc2..c11aa17a355d 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -343,27 +343,30 @@ class ReimbursementAccountPage extends React.Component { ); } - let errorComponent; - const userHasPhonePrimaryEmail = Str.endsWith(this.props.session.email, CONST.SMS.DOMAIN); - - if (userHasPhonePrimaryEmail) { - errorComponent = ( - - {this.props.translate('bankAccount.hasPhoneLoginError')} - + if (this.state.shouldShowContinueSetupButton) { + return ( + ); } + let errorText; + const userHasPhonePrimaryEmail = Str.endsWith(this.props.session.email, CONST.SMS.DOMAIN); const throttledDate = lodashGet(this.props.reimbursementAccount, 'throttledDate'); - if (throttledDate) { - errorComponent = ( - - {this.props.translate('bankAccount.hasBeenThrottledError')} - - ); + const hasUnsupportedCurrency = lodashGet(this.props.policy, 'outputCurrency', '') !== CONST.CURRENCY.USD; + + if (userHasPhonePrimaryEmail) { + errorText = this.props.translate('bankAccount.hasPhoneLoginError'); + } else if (throttledDate) { + errorText = this.props.translate('bankAccount.hasBeenThrottledError'); + } else if (hasUnsupportedCurrency) { + errorText = this.props.translate('bankAccount.hasCurrencyError'); } - if (errorComponent) { + if (errorText) { return ( Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} /> - {errorComponent} + + {errorText} + ); } diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index e08ee256ca3c..2177d2860dd6 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -67,6 +67,7 @@ function dismissError(policyID) { const WorkspaceInitialPage = (props) => { const policy = props.policy; const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [isCurrencyModalOpen, setIsCurrencyModalOpen] = useState(false); const hasPolicyCreationError = Boolean(policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD && policy.errors); /** @@ -79,6 +80,15 @@ const WorkspaceInitialPage = (props) => { Navigation.navigate(ROUTES.SETTINGS_WORKSPACES); }, [props.reports, policy]); + /** + * Call update workspace currency and hide the modal + */ + const confirmCurrencyChangeAndHideModal = useCallback(() => { + Policy.updateGeneralSettings(policy.id, policy.name, CONST.CURRENCY.USD); + setIsCurrencyModalOpen(false); + ReimbursementAccount.navigateToBankAccountRoute(policy.id); + }, [policy]); + /** * Navigates to workspace rooms * @param {String} chatType @@ -137,7 +147,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) : setIsCurrencyModalOpen(true)), brickRoadIndicator: !_.isEmpty(props.reimbursementAccount.errors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '', }, ]; @@ -242,6 +252,16 @@ const WorkspaceInitialPage = (props) => { + setIsCurrencyModalOpen(false)} + prompt={props.translate('workspace.bankAccount.updateCurrencyPrompt')} + confirmText={props.translate('workspace.bankAccount.updateToUSD')} + cancelText={props.translate('common.cancel')} + danger + />