Skip to content

Commit

Permalink
Merge pull request #5928 from Expensify/jasper-sendMoneyKYCFlow
Browse files Browse the repository at this point in the history
Navigate to the Enable Payments Flow from within the Send Money Flow
  • Loading branch information
jasperhuangg committed Oct 25, 2021
2 parents 5fa8364 + 228c722 commit 3d675a4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default {
getIouSplitRoute: reportID => `${IOU_BILL}/${reportID}`,
getIOUSendRoute: reportID => `${IOU_SEND}/${reportID}`,
IOU_BILL_CURRENCY: `${IOU_BILL_CURRENCY}/:reportID?`,
IOU_ENABLE_PAYMENTS: 'iou/enable-payments',
IOU_REQUEST_CURRENCY: `${IOU_REQUEST_CURRENCY}/:reportID?`,
IOU_SEND_CURRENCY: `${IOU_SEND_CURRENCY}/:reportID?`,
getIouRequestCurrencyRoute: reportID => `${IOU_REQUEST_CURRENCY}/${reportID}`,
Expand Down
21 changes: 20 additions & 1 deletion src/components/ButtonWithMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
import styles from '../styles/styles';
import Button from './Button';
import ButtonWithDropdown from './ButtonWithDropdown';
import PopoverMenu from './PopoverMenu';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
import userWalletPropTypes from '../pages/EnablePayments/userWalletPropTypes';
import Navigation from '../libs/Navigation/Navigation';
import ROUTES from '../ROUTES';

const propTypes = {
/** Text to display for the menu header */
Expand All @@ -32,6 +38,9 @@ const propTypes = {
iconHeight: PropTypes.number,
iconDescription: PropTypes.string,
})).isRequired,

/** The user's current wallet status and step */
userWallet: userWalletPropTypes.isRequired,
};

const defaultProps = {
Expand All @@ -51,6 +60,12 @@ class ButtonWithMenu extends PureComponent {
};
}

componentDidMount() {
if (!this.props.userWallet.tierName || this.props.userWallet.tierName === CONST.WALLET.TIER_NAME.SILVER) {
Navigation.navigate(ROUTES.IOU_ENABLE_PAYMENTS);
}
}

setMenuVisibility(isMenuVisible) {
this.setState({isMenuVisible});
}
Expand Down Expand Up @@ -105,4 +120,8 @@ class ButtonWithMenu extends PureComponent {
ButtonWithMenu.propTypes = propTypes;
ButtonWithMenu.defaultProps = defaultProps;

export default ButtonWithMenu;
export default withOnyx({
userWallet: {
key: ONYXKEYS.USER_WALLET,
},
})(ButtonWithMenu);
3 changes: 2 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {getPolicyList} from '../../actions/Policy';
import modalCardStyleInterpolator from './modalCardStyleInterpolator';
import createCustomModalStackNavigator from './createCustomModalStackNavigator';
import getOperatingSystem from '../../getOperatingSystem';
import {fetchFreePlanVerifiedBankAccount} from '../../actions/BankAccounts';
import {fetchFreePlanVerifiedBankAccount, fetchUserWallet} from '../../actions/BankAccounts';

// Main drawer navigator
import MainDrawerNavigator from './MainDrawerNavigator';
Expand Down Expand Up @@ -163,6 +163,7 @@ class AuthScreens extends React.Component {
fetchCountryCodeByRequestIP();
UnreadIndicatorUpdater.listenForReportChanges();
fetchFreePlanVerifiedBankAccount();
fetchUserWallet();

// Load policies, maybe creating a new policy first.
Linking.getInitialURL()
Expand Down
4 changes: 4 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const IOUSendModalStackNavigator = createModalStackNavigator([{
{
Component: IOUCurrencySelection,
name: 'IOU_Send_Currency',
},
{
Component: EnablePaymentsPage,
name: 'IOU_Enable_Payments',
}]);

const IOUDetailsModalStackNavigator = createModalStackNavigator([{
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export default {
EnablePayments: {
screens: {
EnablePayments_Root: ROUTES.ENABLE_PAYMENTS,
IOU_Enable_Payments: ROUTES.IOU_ENABLE_PAYMENTS,
},
},
WorkspaceInvite: {
Expand Down

0 comments on commit 3d675a4

Please sign in to comment.