From 91f797b1c51d7421ce7c740688c8865534a28372 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 22 Jul 2021 07:31:27 -1000 Subject: [PATCH] Merge pull request #4019 from Expensify/cmartins-offline-currency Add offline message to IOU and Split bill and allow currency selection while offline (cherry picked from commit fd92e19ef4288480c08ee6c5503688a6ad7e54d5) --- src/CONST.js | 2 +- src/components/IOUConfirmationList.js | 46 ++++++++----- src/languages/en.js | 3 +- src/languages/es.js | 3 +- .../Navigation/AppNavigator/AuthScreens.js | 2 +- src/libs/OptionsListUtils.js | 1 - src/libs/actions/IOU.js | 10 +++ src/libs/actions/PersonalDetails.js | 15 ++-- src/libs/actions/Session.js | 2 +- src/pages/iou/IOUCurrencySelection.js | 52 +++++++------- src/pages/iou/IOUModal.js | 69 +++++-------------- src/pages/iou/steps/IOUAmountPage.js | 37 ++++++---- src/pages/iou/steps/IOUConfirmPage.js | 10 --- 13 files changed, 119 insertions(+), 133 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 511ba361a309..430fe9979a65 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -197,7 +197,7 @@ const CONST = { DEFAULT: 'default', }, ERROR: { - API_OFFLINE: 'session.offlineMessage', + API_OFFLINE: 'session.offlineMessageRetry', }, NETWORK: { METHOD: { diff --git a/src/components/IOUConfirmationList.js b/src/components/IOUConfirmationList.js index 3c4bcefc44e4..8b46974f39ad 100755 --- a/src/components/IOUConfirmationList.js +++ b/src/components/IOUConfirmationList.js @@ -19,20 +19,12 @@ import SafeAreaInsetPropTypes from '../pages/SafeAreaInsetPropTypes'; import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; import compose from '../libs/compose'; import FixedFooter from './FixedFooter'; +import CONST from '../CONST'; const propTypes = { /** Callback to inform parent modal of success */ onConfirm: PropTypes.func.isRequired, - // User's currency preference - selectedCurrency: PropTypes.shape({ - // Currency code for the selected currency - currencyCode: PropTypes.string, - - // Currency symbol for the selected currency - currencySymbol: PropTypes.string, - }).isRequired, - // Callback to update comment from IOUModal onUpdateComment: PropTypes.func, @@ -80,20 +72,33 @@ const propTypes = { /** Primary login of the user */ login: PropTypes.string, - }).isRequired, + }), /** Holds data related to IOU view state, rather than the underlying IOU data. */ iou: PropTypes.shape({ /** Whether or not the IOU step is loading (creating the IOU Report) */ loading: PropTypes.bool, + + // Selected Currency Code of the current IOU + selectedCurrencyCode: PropTypes.string, + }), + + /** Information about the network */ + network: PropTypes.shape({ + /** Is the network currently offline or not */ + isOffline: PropTypes.bool, }), }; const defaultProps = { - iou: {}, + iou: { + selectedCurrencyCode: CONST.CURRENCY.USD, + }, onUpdateComment: null, comment: '', + network: {}, + myPersonalDetails: {}, }; // Gives minimum height to offset the height of @@ -115,14 +120,14 @@ class IOUConfirmationList extends Component { this.props.myPersonalDetails, this.props.numberFormat(this.calculateAmount() / 100, { style: 'currency', - currency: this.props.selectedCurrency.currencyCode, + currency: this.props.iou.selectedCurrencyCode, }), ); const formattedParticipants = getIOUConfirmationOptionsFromParticipants(this.props.participants, this.props.numberFormat(this.calculateAmount() / 100, { style: 'currency', - currency: this.props.selectedCurrency.currencyCode, + currency: this.props.iou.selectedCurrencyCode, })); sections.push({ @@ -141,7 +146,7 @@ class IOUConfirmationList extends Component { const formattedParticipants = getIOUConfirmationOptionsFromParticipants(this.props.participants, this.props.numberFormat(this.props.iouAmount, { style: 'currency', - currency: this.props.selectedCurrency.currencyCode, + currency: this.props.iou.selectedCurrencyCode, })); sections.push({ @@ -237,7 +242,7 @@ class IOUConfirmationList extends Component { this.props.hasMultipleParticipants ? 'iou.split' : 'iou.request', { amount: this.props.numberFormat( this.props.iouAmount, - {style: 'currency', currency: this.props.selectedCurrency.currencyCode}, + {style: 'currency', currency: this.props.iou.selectedCurrencyCode}, ), }, ); @@ -274,10 +279,16 @@ class IOUConfirmationList extends Component { + {this.props.network.isOffline && ( + + {this.props.translate('session.offlineMessage')} + + )}