Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d683905
Add offlinefeedback
Aug 30, 2022
a96a4d9
Add pending and error handling
Aug 31, 2022
1481056
add onclose
Aug 31, 2022
c3ac6be
pass plaid index
Sep 2, 2022
a500ed6
fix up onyxdata
Sep 7, 2022
c440439
fix persisting plaid data
Sep 7, 2022
b4c8291
dry up PM navigation
Sep 7, 2022
6456f3b
fix dependency cycle
Sep 7, 2022
31f5848
Fix lint issues
Sep 7, 2022
9a72191
if bank account is pending, naviagte to add-bank-account
Sep 7, 2022
7a4eccc
Add pending key
Sep 7, 2022
4208af0
dry up format numebr method
Sep 8, 2022
819aee1
add errors
Sep 8, 2022
b1f3c6a
add brick indicator
Sep 8, 2022
5c2be25
Add pending style
Sep 9, 2022
30b498b
Fix opacity
Sep 13, 2022
c4d7c30
move button to bottom
Sep 13, 2022
ec40de5
wrap button
Sep 14, 2022
1adc86f
merge main
Sep 14, 2022
39bd57a
style
Sep 14, 2022
f012515
merge main
Sep 19, 2022
4649fbc
fix merge misses
Sep 19, 2022
febddd9
dry up a bit
Sep 20, 2022
9706818
fix kyc navigation
Sep 20, 2022
b1e3837
Add personalBankAccount proptypes
Sep 20, 2022
7b61241
use new proptypes
Sep 20, 2022
bc2b1a6
change loading
Sep 20, 2022
5699964
fix last feedback
Sep 20, 2022
eccb515
add changes
Sep 21, 2022
783395e
Switch to handle general errors
Sep 22, 2022
b38afef
merge main
Sep 22, 2022
e906075
merge main
Sep 27, 2022
0b5ae00
remove index
Sep 27, 2022
5ea7e83
fix main merge
Sep 27, 2022
c6ba483
fix other merge issues
Sep 27, 2022
3c90f54
pass selectedPlaidAccount
Sep 27, 2022
b49d2fd
fix proptype
Sep 27, 2022
0f51bc7
fix lint
Sep 28, 2022
d26d1de
fix error handling
Sep 30, 2022
93e39d8
merge main and fix conflicts
Sep 30, 2022
b4f80b2
Add method to collect selected bank object"
Oct 3, 2022
4cb1d6b
update to handle pendingBankAccount
Oct 3, 2022
8704adb
update proptypes
Oct 3, 2022
caf1f08
clean up
Oct 4, 2022
147e723
don't show button spinner if action is offline
Oct 4, 2022
0ea6bc6
fix comment
Oct 6, 2022
cfcdf71
Alternate proposal for pattern B of AddPersonalBankAccount
nkuoch Oct 6, 2022
11da5c2
Apply Pattern B only when offline
nkuoch Oct 6, 2022
bc1ce2a
Merge pull request #11630 from Expensify/nat-ckt
MariaHCD Oct 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/AddPlaidBankAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const propTypes = {
/** Are we adding a withdrawal account? */
allowDebit: PropTypes.bool,

/** Any error we want to show? */
errorText: PropTypes.string,

...withLocalizePropTypes,
};

Expand All @@ -69,6 +72,7 @@ const defaultProps = {
plaidLinkOAuthToken: '',
allowDebit: false,
bankAccountID: 0,
errorText: '',
};

class AddPlaidBankAccount extends React.Component {
Expand Down Expand Up @@ -192,6 +196,7 @@ class AddPlaidBankAccount extends React.Component {
label: this.props.translate('bankAccount.chooseAnAccount'),
} : {}}
value={selectedPlaidBankAccount.plaidAccountID}
errorText={this.props.errorText}
/>
</View>
</View>
Expand Down
4 changes: 4 additions & 0 deletions src/components/KYCWall/BaseKYCWall.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ class KYCWall extends React.Component {
onItemSelected={(item) => {
this.setState({shouldShowAddPaymentMenu: false});
if (item === CONST.PAYMENT_METHODS.BANK_ACCOUNT) {
// If we are adding a new bank account and starting over, clear all plaid data, tokens, and saved personal bank account data
PaymentMethods.clearPersonalBankAccount();
PaymentMethods.clearPlaid();

Navigation.navigate(this.props.addBankAccountRoute);
} else if (item === CONST.PAYMENT_METHODS.DEBIT_CARD) {
Navigation.navigate(this.props.addDebitCardRoute);
Expand Down
3 changes: 2 additions & 1 deletion src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const defaultProps = {
iconFill: undefined,
focused: false,
disabled: false,
isPending: false,
isSelected: false,
subtitle: undefined,
iconType: 'icon',
Expand Down Expand Up @@ -76,7 +77,7 @@ const MenuItem = (props) => {
>
{({hovered, pressed}) => (
<>
<View style={[styles.flexRow, styles.pointerEventsNone, styles.flex1]}>
<View style={[styles.flexRow, styles.pointerEventsNone, styles.flex1, (props.isPending ? styles.offlineFeedback.pending : undefined)]}>
{(props.icon && props.iconType === CONST.ICON_TYPE_ICON) && (
<View
style={[
Expand Down
3 changes: 3 additions & 0 deletions src/components/bankAccountPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default PropTypes.shape({
/** The masked bank account number */
accountNumber: PropTypes.string,

/** The routing number */
routingNumber: PropTypes.string,

/** The bankAccountID in the bankAccounts db */
bankAccountID: PropTypes.number,

Expand Down
3 changes: 3 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const propTypes = {
/** Should we disable this menu item? */
disabled: PropTypes.bool,

/** Gives the menu item a pending style */
isPending: PropTypes.bool,

/** A right-aligned subtitle for this menu option */
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

Expand Down
25 changes: 25 additions & 0 deletions src/components/personalBankAccountPropTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import PropTypes from 'prop-types';

export default PropTypes.shape({
/** General errors */
errors: PropTypes.shape({
/** Key: timestamp - Value: Error message */
}),

/** Field specific errors */
errorFields: PropTypes.shape({
Comment thread
ctkochan22 marked this conversation as resolved.
/** Key: fieldID - bool */
}),

/** Is this pending to be added? */
pendingAction: PropTypes.string,

/** Plaid account ID of the pending bank account */
selectedPlaidAccountID: PropTypes.string,

/** Personal Bank Account successfully added. Show user success modal */
shouldShowSuccess: PropTypes.bool,

/** Show loader if still awaiting response */
isLoading: PropTypes.bool,
});
4 changes: 3 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export default {
notOwnerOfFund: 'There was an error setting this card as your default payment method.',
setDefaultFailure: 'Something went wrong. Please chat with Concierge for further assistance.',
},
addBankAccountFailure: 'And unexpected error occurred while trying to add your bank account. Please try again.',
addBankAccountFailure: 'An unexpected error occurred while trying to add your bank account. Please try again.',

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

},
transferAmountPage: {
transfer: ({amount}) => `Transfer${amount ? ` ${amount}` : ''}`,
Expand Down Expand Up @@ -588,6 +588,8 @@ export default {
chooseAccountLabel: 'Account',
successTitle: 'Personal bank account added!',
successMessage: 'Congrats, your bank account is set up and ready to receive reimbursements.',
passwordRequired: 'Please enter a password',
plaidBankAccountRequired: 'Please select a bank account',
},
attachmentView: {
unknownFilename: 'Unknown filename',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ export default {
chooseAccountLabel: 'Cuenta',
successTitle: '¡Cuenta bancaria personal añadida!',
successMessage: 'Enhorabuena, tu cuenta bancaria está lista para recibir reembolsos.',
passwordRequired: 'Por favor introduce tu contraseña',
plaidBankAccountRequired: 'Por favor seleccione una cuenta bancaria',
},
attachmentView: {
unknownFilename: 'Archivo desconocido',
Expand Down
4 changes: 2 additions & 2 deletions src/libs/PaymentUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function calculateWalletTransferBalanceFee(currentBalance, methodType) {
}

export {
hasExpensifyPaymentMethod,
formatPaymentMethods,
calculateWalletTransferBalanceFee,
formatPaymentMethods,
hasExpensifyPaymentMethod,
};
73 changes: 63 additions & 10 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as API from '../API';
import ONYXKEYS from '../../ONYXKEYS';
import * as Localize from '../Localize';
import DateUtils from '../DateUtils';
import Navigation from '../Navigation/Navigation';
import ROUTES from '../../ROUTES';
import * as NetworkStore from '../Network/NetworkStore';

export {
setupWithdrawalAccount,
Expand Down Expand Up @@ -31,10 +34,6 @@ export {
acceptWalletTerms,
} from './Wallet';

function clearPersonalBankAccount() {
Onyx.set(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {});
}

function clearPlaid() {
Onyx.set(ONYXKEYS.PLAID_DATA, {});
Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
Expand Down Expand Up @@ -116,7 +115,6 @@ function connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount) {
*
* @param {Object} account
* @param {String} password
* @TODO offline pattern for this command will have to be added later once the pattern B design doc is complete
*/
function addPersonalBankAccount(account, password) {
const commandName = 'AddPersonalBankAccount';
Expand All @@ -131,6 +129,7 @@ function addPersonalBankAccount(account, password) {
plaidAccountID: account.plaidAccountID,
plaidAccessToken: account.plaidAccessToken,
password,
isPending: true,
};

const onyxData = {
Expand All @@ -139,8 +138,10 @@ function addPersonalBankAccount(account, password) {
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
errors: null,
errorFields: null,
selectedPlaidAccountID: parameters.plaidAccountID,
isLoading: true,
error: '',
},
},
],
Expand All @@ -150,23 +151,72 @@ function addPersonalBankAccount(account, password) {
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
isLoading: false,
error: '',
shouldShowSuccess: true,
},
},
{
onyxMethod: CONST.ONYX.METHOD.SET,
key: ONYXKEYS.PLAID_DATA,
value: {},
},
{
onyxMethod: CONST.ONYX.METHOD.SET,
key: ONYXKEYS.PLAID_LINK_TOKEN,
value: '',
},
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
value: {
isLoading: false,
error: Localize.translateLocal('paymentsPage.addBankAccountFailure'),
},
},
],
};

if (NetworkStore.isOffline()) {
// If offline, Optimistically go to the list of bank accounts
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS);

// And build Onyx Data for pattern B
onyxData.optimisticData = onyxData.optimisticData.concat({
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.BANK_ACCOUNT_LIST,
value: {
0: {
title: account.addressName,
description: `${Localize.translateLocal('paymentMethodList.accountLastFour')} ${account.accountNumber.slice(-4)}`,
methodID: 0,
key: 'bankAccount-0',
accountType: CONST.PAYMENT_METHODS.BANK_ACCOUNT,
accountData: {...account, bankAccountID: 0},
errors: null,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
},
},
});
onyxData.successData = onyxData.successData.concat({
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.BANK_ACCOUNT_LIST,
value: {
0: null,
},
});
onyxData.failureData = onyxData.failureData.concat({
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.BANK_ACCOUNT_LIST,
value: {
0: {
errors: {
[DateUtils.getMicroseconds()]: Localize.translateLocal('paymentsPage.addBankAccountFailure'),
},
},
},
});
}

API.write(commandName, parameters, onyxData);
}

Expand All @@ -178,7 +228,11 @@ function deletePaymentBankAccount(bankAccountID) {
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: `${ONYXKEYS.BANK_ACCOUNT_LIST}`,
value: {[bankAccountID]: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}},
value: {
[bankAccountID]: {
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
},
},
},
],
});
Expand Down Expand Up @@ -295,7 +349,6 @@ export {
addPersonalBankAccount,
connectBankAccountManually,
deletePaymentBankAccount,
clearPersonalBankAccount,
clearPlaid,
clearOnfido,
updatePersonalInformationForBankAccount,
Expand Down
44 changes: 44 additions & 0 deletions src/libs/actions/PaymentMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,46 @@ function deletePaymentCard(fundID) {
});
}

function navigateToAddPaymentMethodPage(paymentType, allowPaypalPaymentTypes = true) {
// We don't always show Paypal as an option
if (paymentType === CONST.PAYMENT_METHODS.PAYPAL && allowPaypalPaymentTypes) {
Navigation.navigate(ROUTES.SETTINGS_ADD_PAYPAL_ME);
return;
}

if (paymentType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
Navigation.navigate(ROUTES.SETTINGS_ADD_DEBIT_CARD);
return;
}

if (paymentType === CONST.PAYMENT_METHODS.BANK_ACCOUNT) {
// If we are adding a new bank account and starting over, clear all plaid data, tokens, and saved personal bank account data
this.clearPersonalBankAccount();
this.clearPlaid();

Navigation.navigate(ROUTES.SETTINGS_ADD_BANK_ACCOUNT);
return;
}

throw new Error('Invalid payment method type selected');
}

function clearBankAccountPendingAdd() {
Onyx.merge(ONYXKEYS.BANK_ACCOUNT_LIST, {
0: null,
});
}

function clearPersonalBankAccount() {
Onyx.set(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {});
clearBankAccountPendingAdd();
}

function clearPlaid() {
Onyx.set(ONYXKEYS.PLAID_DATA, {});
Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
}

export {
deletePayPalMe,
deletePaymentCard,
Expand All @@ -390,5 +430,9 @@ export {
clearDeletePaymentMethodError,
clearAddPaymentMethodError,
clearWalletError,
navigateToAddPaymentMethodPage,
clearPersonalBankAccount,
clearBankAccountPendingAdd,
clearPlaid,
clearWalletTermsError,
};
9 changes: 9 additions & 0 deletions src/libs/actions/ReimbursementAccount/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ function setPersonalBankAccountFormValidationErrorFields(errorFields) {
Onyx.merge(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {errorFields});
}

/**
* Clear validation messages from personal bank account
*/
function resetPersonalBankAccountErrors() {
setPersonalBankAccountFormValidationErrorFields({});
Onyx.merge(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {errors: null});
}

/**
* Set the current fields with errors.
*
Expand Down Expand Up @@ -49,4 +57,5 @@ export {
setPersonalBankAccountFormValidationErrorFields,
showBankAccountFormValidationError,
resetReimbursementAccount,
resetPersonalBankAccountErrors,
};
1 change: 1 addition & 0 deletions src/libs/actions/ReimbursementAccount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {goToWithdrawalAccountSetupStep, navigateToBankAccountRoute} from './navi
export {
setBankAccountFormValidationErrors,
setPersonalBankAccountFormValidationErrorFields,
resetPersonalBankAccountErrors,
resetReimbursementAccount,
showBankAccountFormValidationError,
} from './errors';
Expand Down
Loading