From 1a1a489541a6522bd27c2fd601befefc1ac69743 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Thu, 11 Aug 2022 16:05:34 -0700 Subject: [PATCH 001/144] initial code --- src/libs/actions/Policy.js | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 9470ea25f4e0..8d06d107edec 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -2,6 +2,7 @@ import _ from 'underscore'; import Onyx from 'react-native-onyx'; import lodashGet from 'lodash/get'; import * as DeprecatedAPI from '../deprecatedAPI'; +import * as API from '../API'; import ONYXKEYS from '../../ONYXKEYS'; import * as PersonalDetails from './PersonalDetails'; import Growl from '../Growl'; @@ -13,6 +14,7 @@ import ROUTES from '../../ROUTES'; import * as OptionsListUtils from '../OptionsListUtils'; import * as Report from './Report'; import * as Pusher from '../Pusher/pusher'; +import DateUtils from '../DateUtils'; const allPolicies = {}; Onyx.connect({ @@ -319,6 +321,60 @@ function removeMembers(members, policyID) { }); } +/** + * Adds members to the specified workspace/policyID + * + * @param {Array} memberLogins + * @param {String} welcomeNote + * @param {String} policyID + */ +function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { + const membersListKey = `${ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST}${policyID}`; + const logins = _.map(memberLogins, memberLogin => OptionsListUtils.addSMSDomainIfPhoneNumber(memberLogin)); + + const optimisticData = [ + { + onyxMethod: 'merge', + key: membersListKey, + + // Convert to object with each key containing {pendingAction: ‘add’} + value: _.object(logins, Array(logins.length).fill({pendingAction: 'add'})), + }, + ]; + + const successData = [ + { + onyxMethod: 'merge', + key: membersListKey, + + // Convert to object with each key clearing pendingAction. We don’t + // need to remove the members since that will be handled by onClose of OfflineWithFeedback. + value: _.object(logins, Array(logins.length).fill({pendingAction: null})), + }, + ]; + + const failureData = [ + { + onyxMethod: 'merge', + key: membersListKey, + + // Convert to object with each key containing the error. We don’t + // need to remove the members since that is handled by onClose of OfflineWithFeedback. + value: _.object(logins, Array(logins.length).fill({ + errors: { + [DateUtils.getMicroseconds()]: 'some generic error', + }, + })), + }, + ]; + + API.write('AddMembersToWorkspace', { + employees: JSON.stringify(_.map(logins, login => ({email: login}))), + welcomeNote, + policyID, + }, {optimisticData, successData, failureData}); +} + /** * Merges the passed in login into the specified policy * @@ -327,6 +383,7 @@ function removeMembers(members, policyID) { * @param {String} policyID */ function invite(logins, welcomeNote, policyID) { + // addMembersToWorkspace(logins, welcomeNote, policyID); const key = `${ONYXKEYS.COLLECTION.POLICY}${policyID}`; const newEmployeeList = _.map(logins, login => OptionsListUtils.addSMSDomainIfPhoneNumber(login)); @@ -580,6 +637,7 @@ export { loadFullPolicy, removeMembers, invite, + addMembersToWorkspace, isAdminOfFreePolicy, create, uploadAvatar, From 36f1a725b191e74f8b1aa5f5409a9ce12773956c Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Tue, 16 Aug 2022 17:23:46 -0700 Subject: [PATCH 002/144] testing addMembersToWorkspace --- src/libs/actions/Policy.js | 85 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 8d06d107edec..c157af0f6bb2 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -369,7 +369,8 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { ]; API.write('AddMembersToWorkspace', { - employees: JSON.stringify(_.map(logins, login => ({email: login}))), + // employees: JSON.stringify(_.map(logins, login => ({email: login}))), + employees: JSON.stringify(logins), welcomeNote, policyID, }, {optimisticData, successData, failureData}); @@ -383,47 +384,47 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { * @param {String} policyID */ function invite(logins, welcomeNote, policyID) { - // addMembersToWorkspace(logins, welcomeNote, policyID); - const key = `${ONYXKEYS.COLLECTION.POLICY}${policyID}`; - const newEmployeeList = _.map(logins, login => OptionsListUtils.addSMSDomainIfPhoneNumber(login)); - - // Make a shallow copy to preserve original data, and concat the login - const policy = _.clone(allPolicies[key]); - policy.employeeList = [...policy.employeeList, ...newEmployeeList]; - policy.alertMessage = ''; - - // Optimistically add the user to the policy - Onyx.merge(key, policy); - - // Make the API call to merge the login into the policy - DeprecatedAPI.Policy_Employees_Merge({ - employees: JSON.stringify(_.map(logins, login => ({email: login}))), - welcomeNote, - policyID, - }) - .then((data) => { - // Save the personalDetails for the invited user in Onyx and fetch the latest policyExpenseChats - if (data.jsonCode === 200) { - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, PersonalDetails.formatPersonalDetails(data.personalDetails)); - Navigation.goBack(); - if (!_.isEmpty(data.policyExpenseChatIDs)) { - Report.fetchChatReportsByIDs(data.policyExpenseChatIDs); - } - return; - } - - // If the operation failed, undo the optimistic addition - const policyDataWithoutLogin = _.clone(allPolicies[key]); - policyDataWithoutLogin.employeeList = _.without(allPolicies[key].employeeList, ...newEmployeeList); - - // Show the user feedback that the addition failed - policyDataWithoutLogin.alertMessage = Localize.translateLocal('workspace.invite.genericFailureMessage'); - if (data.jsonCode === 402) { - policyDataWithoutLogin.alertMessage += ` ${Localize.translateLocal('workspace.invite.pleaseEnterValidLogin')}`; - } - - Onyx.set(key, policyDataWithoutLogin); - }); + addMembersToWorkspace(logins, welcomeNote, policyID); + // const key = `${ONYXKEYS.COLLECTION.POLICY}${policyID}`; + // const newEmployeeList = _.map(logins, login => OptionsListUtils.addSMSDomainIfPhoneNumber(login)); + // + // // Make a shallow copy to preserve original data, and concat the login + // const policy = _.clone(allPolicies[key]); + // policy.employeeList = [...policy.employeeList, ...newEmployeeList]; + // policy.alertMessage = ''; + // + // // Optimistically add the user to the policy + // Onyx.merge(key, policy); + // + // // Make the API call to merge the login into the policy + // DeprecatedAPI.Policy_Employees_Merge({ + // employees: JSON.stringify(_.map(logins, login => ({email: login}))), + // welcomeNote, + // policyID, + // }) + // .then((data) => { + // // Save the personalDetails for the invited user in Onyx and fetch the latest policyExpenseChats + // if (data.jsonCode === 200) { + // Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, PersonalDetails.formatPersonalDetails(data.personalDetails)); + // Navigation.goBack(); + // if (!_.isEmpty(data.policyExpenseChatIDs)) { + // Report.fetchChatReportsByIDs(data.policyExpenseChatIDs); + // } + // return; + // } + // + // // If the operation failed, undo the optimistic addition + // const policyDataWithoutLogin = _.clone(allPolicies[key]); + // policyDataWithoutLogin.employeeList = _.without(allPolicies[key].employeeList, ...newEmployeeList); + // + // // Show the user feedback that the addition failed + // policyDataWithoutLogin.alertMessage = Localize.translateLocal('workspace.invite.genericFailureMessage'); + // if (data.jsonCode === 402) { + // policyDataWithoutLogin.alertMessage += ` ${Localize.translateLocal('workspace.invite.pleaseEnterValidLogin')}`; + // } + // + // Onyx.set(key, policyDataWithoutLogin); + // }); } /** From 81218a8a01ca24488ce6a98349e6263f8d829bc2 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 18 Aug 2022 14:35:38 +0000 Subject: [PATCH 003/144] restructure format payment methods --- src/ONYXKEYS.js | 3 ++ src/components/paymentMethodPropTypes.js | 24 +++++++++++++ src/libs/PaymentUtils.js | 36 +++++++++++++++++++ .../settings/Payments/PaymentMethodList.js | 16 +++++++-- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/components/paymentMethodPropTypes.js diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index af8b937e2bbf..fdefe40099a6 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -125,6 +125,9 @@ export default { // The user's bank accounts BANK_ACCOUNT_LIST: 'bankAccountList', + // The user's payment methods + PAYMENT_METHOD_LIST: 'paymentMethodList', + // The user's credit cards CARD_LIST: 'cardList', diff --git a/src/components/paymentMethodPropTypes.js b/src/components/paymentMethodPropTypes.js new file mode 100644 index 000000000000..2ea2ce458b3d --- /dev/null +++ b/src/components/paymentMethodPropTypes.js @@ -0,0 +1,24 @@ +import PropTypes from 'prop-types'; + +export default PropTypes.shape({ + /** The name of the payment method (bank of Plaid Checking, etc) */ + title: PropTypes.string, + + /** The masked bank account number */ + description: PropTypes.string, + + /** The bankAccountID in the bankAccounts db */ + methodID: PropTypes.number, + + /** The unique key for the payment method */ + key: PropTypes.string, + + /** The type of account ( bankAccount, payPalMe etc */ + accountType: PropTypes.string, + + /** The whole data of the payment method */ + accountData: PropTypes.shape, + + /** Indicates if this is the default payment method */ + isDefault: PropTypes.bool, +}); diff --git a/src/libs/PaymentUtils.js b/src/libs/PaymentUtils.js index 4089701ecd60..ab94a57050c7 100644 --- a/src/libs/PaymentUtils.js +++ b/src/libs/PaymentUtils.js @@ -25,6 +25,41 @@ function hasExpensifyPaymentMethod(cardList = [], bankAccountList = []) { return validBankAccount || validDebitCard; } +/** + * Get the PaymentMethod list with icons + * @param {Array} paymentMethodList + * @returns {Array} + */ +function formatPaymentMethods2(paymentMethodList) { + const paymentMethods = [...paymentMethodList]; + _.each(paymentMethods, (paymentMethod, index) => { + switch (paymentMethod.accountType) { + case CONST.PAYMENT_METHODS.BANK_ACCOUNT: { + const {icon, iconSize} = getBankIcon(lodashGet(paymentMethod, 'additionalData.bankName', '')); + paymentMethods[index].icon = icon; + paymentMethods[index].iconSize = iconSize; + break; + } + case CONST.PAYMENT_METHODS.DEBIT_CARD: { + const {icon, iconSize} = getBankIcon(paymentMethod.accountData.bank, true); + paymentMethods[index].icon = icon; + paymentMethods[index].iconSize = iconSize; + break; + } + case CONST.PAYMENT_METHODS.PAYPAL: { + paymentMethods[index].icon = Expensicons.PayPal; + break; + } + default: { + paymentMethods[index].icon = ''; + paymentMethods[index].iconSize = ''; + break; + } + } + }); + return paymentMethods; +} + /** * Get the PaymentMethods list * @param {Array} bankAccountList @@ -119,4 +154,5 @@ export { hasExpensifyPaymentMethod, formatPaymentMethods, calculateWalletTransferBalanceFee, + formatPaymentMethods2, }; diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 3e2cce3409c1..d3f6f8d5a3b3 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -21,6 +21,7 @@ import FormAlertWrapper from '../../../components/FormAlertWrapper'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import Log from '../../../libs/Log'; +import paymentMethodPropTypes from '../../../components/paymentMethodPropTypes'; const MENU_ITEM = 'menuItem'; const BUTTON = 'button'; @@ -35,6 +36,9 @@ const propTypes = { /** List of bank accounts */ bankAccountList: PropTypes.objectOf(bankAccountPropTypes), + /** List of bank payment methods */ + paymentMethodList: PropTypes.objectOf(paymentMethodPropTypes), + /** List of cards */ cardList: PropTypes.objectOf(cardPropTypes), @@ -68,6 +72,7 @@ const propTypes = { const defaultProps = { payPalMeUsername: '', bankAccountList: {}, + paymentMethodList: {}, cardList: {}, userWallet: { walletLinkedAccountID: 0, @@ -113,9 +118,13 @@ class PaymentMethodList extends Component { */ getFilteredPaymentMethods() { // Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them - const filteredCardList = _.filter(this.props.cardList, card => card.additionalData.isP2PDebitCard); + const filteredPaymentMethods = _.filter( + this.props.paymentMethodList, paymentMethod => !(paymentMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD + && paymentMethod.accountData.additionalData + && paymentMethod.accountData.additionalData.isP2PDebitCard) + ); - let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, filteredCardList, this.props.payPalMeUsername, this.props.userWallet); + let combinedPaymentMethods = PaymentUtils.formatPaymentMethods2(filteredPaymentMethods); if (!_.isEmpty(this.props.filterType)) { combinedPaymentMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === this.props.filterType); @@ -290,5 +299,8 @@ export default compose( userWallet: { key: ONYXKEYS.USER_WALLET, }, + paymentMethodList: { + key: ONYXKEYS.PAYMENT_METHOD_LIST, + }, }), )(PaymentMethodList); From 35b6dca724ceae2cf9457b7bd1304895ba44ee54 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 18 Aug 2022 14:41:10 +0000 Subject: [PATCH 004/144] remove usages of formatPaymentDetails from BasePayments --- .../Payments/PaymentsPage/BasePaymentsPage.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index 148f27fa8672..29513404b495 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -227,13 +227,7 @@ class BasePaymentsPage extends React.Component { makeDefaultPaymentMethod(password) { // Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors - const paymentMethods = PaymentUtils.formatPaymentMethods( - this.props.bankAccountList, - this.props.cardList, - '', - this.props.userWallet, - ); - const previousPaymentMethod = _.find(paymentMethods, method => method.isDefault); + const previousPaymentMethod = _.find(this.props.paymentMethodList, method => method.isDefault); const previousPaymentMethodID = lodashGet(previousPaymentMethod, 'methodID'); const previousPaymentMethodType = lodashGet(previousPaymentMethod, 'accountType'); if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.BANK_ACCOUNT) { @@ -457,11 +451,8 @@ export default compose( userWallet: { key: ONYXKEYS.USER_WALLET, }, - bankAccountList: { - key: ONYXKEYS.BANK_ACCOUNT_LIST, - }, - cardList: { - key: ONYXKEYS.CARD_LIST, + paymentMethodList: { + key: ONYXKEYS.PAYMENT_METHOD_LIST, }, }), )(BasePaymentsPage); From 3d8704bac14442ca83b7e60247700a967ee415a1 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 18 Aug 2022 15:12:07 +0000 Subject: [PATCH 005/144] add usages of propTypes --- src/components/paymentMethodPropTypes.js | 5 +- .../settings/Payments/PaymentMethodList.js | 43 ++--------------- .../Payments/PaymentsPage/BasePaymentsPage.js | 5 +- .../PaymentsPage/paymentsPagePropTypes.js | 7 ++- .../settings/Payments/TransferBalancePage.js | 48 ++++--------------- 5 files changed, 25 insertions(+), 83 deletions(-) diff --git a/src/components/paymentMethodPropTypes.js b/src/components/paymentMethodPropTypes.js index 2ea2ce458b3d..9bbf4eb455fc 100644 --- a/src/components/paymentMethodPropTypes.js +++ b/src/components/paymentMethodPropTypes.js @@ -8,7 +8,10 @@ export default PropTypes.shape({ description: PropTypes.string, /** The bankAccountID in the bankAccounts db */ - methodID: PropTypes.number, + methodID: PropTypes.oneOfType([ + PropTypes.number, + PropTypes.string, + ]), /** The unique key for the payment method */ key: PropTypes.string, diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index d3f6f8d5a3b3..fb02929057c0 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -30,17 +30,8 @@ const propTypes = { /** What to do when a menu item is pressed */ onPress: PropTypes.func.isRequired, - /** User's paypal.me username if they have one */ - payPalMeUsername: PropTypes.string, - - /** List of bank accounts */ - bankAccountList: PropTypes.objectOf(bankAccountPropTypes), - - /** List of bank payment methods */ - paymentMethodList: PropTypes.objectOf(paymentMethodPropTypes), - - /** List of cards */ - cardList: PropTypes.objectOf(cardPropTypes), + /** List of payment methods */ + paymentMethodList: PropTypes.arrayOf(paymentMethodPropTypes), /** Whether the add Payment button be shown on the list */ shouldShowAddPaymentMethodButton: PropTypes.bool, @@ -48,15 +39,6 @@ const propTypes = { /** Type to filter the payment Method list */ filterType: PropTypes.oneOf([CONST.PAYMENT_METHODS.DEBIT_CARD, CONST.PAYMENT_METHODS.BANK_ACCOUNT, '']), - /** User wallet props */ - userWallet: PropTypes.shape({ - /** The ID of the linked account */ - walletLinkedAccountID: PropTypes.number, - - /** The type of the linked account (debitCard or bankAccount) */ - walletLinkedAccountType: PropTypes.string, - }), - /** Type of active/highlighted payment method */ actionPaymentMethodType: PropTypes.oneOf([..._.values(CONST.PAYMENT_METHODS), '']), @@ -70,14 +52,7 @@ const propTypes = { }; const defaultProps = { - payPalMeUsername: '', - bankAccountList: {}, - paymentMethodList: {}, - cardList: {}, - userWallet: { - walletLinkedAccountID: 0, - walletLinkedAccountType: '', - }, + paymentMethodList: [], shouldShowAddPaymentMethodButton: true, filterType: '', actionPaymentMethodType: '', @@ -287,18 +262,6 @@ PaymentMethodList.defaultProps = defaultProps; export default compose( withLocalize, withOnyx({ - bankAccountList: { - key: ONYXKEYS.BANK_ACCOUNT_LIST, - }, - cardList: { - key: ONYXKEYS.CARD_LIST, - }, - payPalMeUsername: { - key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, - }, - userWallet: { - key: ONYXKEYS.USER_WALLET, - }, paymentMethodList: { key: ONYXKEYS.PAYMENT_METHOD_LIST, }, diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index 29513404b495..6fd6bc426a7a 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -31,7 +31,6 @@ import * as Expensicons from '../../../../components/Icon/Expensicons'; import KYCWall from '../../../../components/KYCWall'; import {propTypes, defaultProps} from './paymentsPagePropTypes'; import {withNetwork} from '../../../../components/OnyxProvider'; -import * as PaymentUtils from '../../../../libs/PaymentUtils'; import OfflineWithFeedback from '../../../../components/OfflineWithFeedback'; class BasePaymentsPage extends React.Component { @@ -227,7 +226,9 @@ class BasePaymentsPage extends React.Component { makeDefaultPaymentMethod(password) { // Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors - const previousPaymentMethod = _.find(this.props.paymentMethodList, method => method.isDefault); + const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); + + const previousPaymentMethod = _.find(paymentMethods, method => method.isDefault); const previousPaymentMethodID = lodashGet(previousPaymentMethod, 'methodID'); const previousPaymentMethodType = lodashGet(previousPaymentMethod, 'accountType'); if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.BANK_ACCOUNT) { diff --git a/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js b/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js index 53dca3d790c9..76cf4d8c0af5 100644 --- a/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js +++ b/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js @@ -6,6 +6,7 @@ import networkPropTypes from '../../../../components/networkPropTypes'; import bankAccountPropTypes from '../../../../components/bankAccountPropTypes'; import cardPropTypes from '../../../../components/cardPropTypes'; import userWalletPropTypes from '../../../EnablePayments/userWalletPropTypes'; +import paymentMethodPropTypes from '../../../../components/paymentMethodPropTypes'; const propTypes = { /** Wallet balance transfer props */ @@ -32,6 +33,9 @@ const propTypes = { /** List of cards */ cardList: PropTypes.objectOf(cardPropTypes), + /** List of payment methods */ + paymentMethodList: PropTypes.arrayOf(paymentMethodPropTypes), + ...withLocalizePropTypes, ...windowDimensionsPropTypes, @@ -45,8 +49,7 @@ const defaultProps = { isLoadingPaymentMethods: true, shouldListenForResize: false, userWallet: {}, - bankAccountList: {}, - cardList: {}, + paymentMethodList: [], }; export {propTypes, defaultProps}; diff --git a/src/pages/settings/Payments/TransferBalancePage.js b/src/pages/settings/Payments/TransferBalancePage.js index 7f97bb1ffb89..82c08206389f 100644 --- a/src/pages/settings/Payments/TransferBalancePage.js +++ b/src/pages/settings/Payments/TransferBalancePage.js @@ -24,33 +24,18 @@ import CurrentWalletBalance from '../../../components/CurrentWalletBalance'; import walletTransferPropTypes from './walletTransferPropTypes'; import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import * as PaymentUtils from '../../../libs/PaymentUtils'; -import cardPropTypes from '../../../components/cardPropTypes'; import userWalletPropTypes from '../../EnablePayments/userWalletPropTypes'; import ROUTES from '../../../ROUTES'; import FormAlertWithSubmitButton from '../../../components/FormAlertWithSubmitButton'; import {withNetwork} from '../../../components/OnyxProvider'; +import paymentMethodPropTypes from '../../../components/paymentMethodPropTypes'; const propTypes = { /** User's wallet information */ userWallet: PropTypes.objectOf(userWalletPropTypes), - /** List of bank accounts */ - bankAccountList: PropTypes.objectOf(PropTypes.shape({ - /** The name of the institution (bank of america, etc) */ - addressName: PropTypes.string, - - /** The masked bank account number */ - accountNumber: PropTypes.string, - - /** The bankAccountID in the bankAccounts db */ - bankAccountID: PropTypes.number, - - /** The bank account type */ - type: PropTypes.string, - })), - - /** List of card objects */ - cardList: PropTypes.objectOf(cardPropTypes), + /** List of payment methods */ + paymentMethodList: PropTypes.arrayOf(paymentMethodPropTypes), /** Wallet balance transfer props */ walletTransfer: walletTransferPropTypes, @@ -59,9 +44,8 @@ const propTypes = { }; const defaultProps = { + paymentMethodList: [], userWallet: {}, - bankAccountList: {}, - cardList: {}, walletTransfer: {}, }; @@ -112,12 +96,7 @@ class TransferBalancePage extends React.Component { * @returns {Object|undefined} */ getSelectedPaymentMethodAccount() { - const paymentMethods = PaymentUtils.formatPaymentMethods( - this.props.bankAccountList, - this.props.cardList, - '', - this.props.userWallet, - ); + const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); const defaultAccount = _.find(paymentMethods, method => method.isDefault); const selectedAccount = _.find( @@ -135,14 +114,10 @@ class TransferBalancePage extends React.Component { PaymentMethods.saveWalletTransferMethodType(filterPaymentMethodType); // If we only have a single option for the given paymentMethodType do not force the user to make a selection - const combinedPaymentMethods = PaymentUtils.formatPaymentMethods( - this.props.bankAccountList, - this.props.cardList, - '', - this.props.userWallet, - ); + const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); - const filteredMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === filterPaymentMethodType); + + const filteredMethods = _.filter(paymentMethods, paymentMethod => paymentMethod.accountType === filterPaymentMethodType); if (filteredMethods.length === 1) { const account = _.first(filteredMethods); PaymentMethods.saveWalletTransferAccountTypeAndID( @@ -313,11 +288,8 @@ export default compose( walletTransfer: { key: ONYXKEYS.WALLET_TRANSFER, }, - bankAccountList: { - key: ONYXKEYS.BANK_ACCOUNT_LIST, - }, - cardList: { - key: ONYXKEYS.CARD_LIST, + paymentMethodList: { + key: ONYXKEYS.PAYMENT_METHOD_LIST, }, }), )(TransferBalancePage); From 51ceab083609a236cad20eb4a67d05baf2b8e255 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 18 Aug 2022 15:39:45 +0000 Subject: [PATCH 006/144] apply linting --- src/pages/settings/Payments/PaymentMethodList.js | 4 +--- src/pages/settings/Payments/TransferBalancePage.js | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index fb02929057c0..b8a060cad611 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -14,8 +14,6 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal import ONYXKEYS from '../../../ONYXKEYS'; import CONST from '../../../CONST'; import * as Expensicons from '../../../components/Icon/Expensicons'; -import bankAccountPropTypes from '../../../components/bankAccountPropTypes'; -import cardPropTypes from '../../../components/cardPropTypes'; import * as PaymentUtils from '../../../libs/PaymentUtils'; import FormAlertWrapper from '../../../components/FormAlertWrapper'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; @@ -96,7 +94,7 @@ class PaymentMethodList extends Component { const filteredPaymentMethods = _.filter( this.props.paymentMethodList, paymentMethod => !(paymentMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD && paymentMethod.accountData.additionalData - && paymentMethod.accountData.additionalData.isP2PDebitCard) + && paymentMethod.accountData.additionalData.isP2PDebitCard), ); let combinedPaymentMethods = PaymentUtils.formatPaymentMethods2(filteredPaymentMethods); diff --git a/src/pages/settings/Payments/TransferBalancePage.js b/src/pages/settings/Payments/TransferBalancePage.js index 82c08206389f..48e08bb8927a 100644 --- a/src/pages/settings/Payments/TransferBalancePage.js +++ b/src/pages/settings/Payments/TransferBalancePage.js @@ -116,7 +116,6 @@ class TransferBalancePage extends React.Component { // If we only have a single option for the given paymentMethodType do not force the user to make a selection const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); - const filteredMethods = _.filter(paymentMethods, paymentMethod => paymentMethod.accountType === filterPaymentMethodType); if (filteredMethods.length === 1) { const account = _.first(filteredMethods); From 86055efd7a58f066c697a32a526bf2f9a90972cd Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Thu, 18 Aug 2022 14:43:46 -0700 Subject: [PATCH 007/144] cleanup and navigate back --- src/libs/actions/Policy.js | 52 ---------------------- src/pages/workspace/WorkspaceInvitePage.js | 3 +- 2 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index c157af0f6bb2..a9f62671b600 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -376,57 +376,6 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { }, {optimisticData, successData, failureData}); } -/** - * Merges the passed in login into the specified policy - * - * @param {Array} logins - * @param {String} welcomeNote - * @param {String} policyID - */ -function invite(logins, welcomeNote, policyID) { - addMembersToWorkspace(logins, welcomeNote, policyID); - // const key = `${ONYXKEYS.COLLECTION.POLICY}${policyID}`; - // const newEmployeeList = _.map(logins, login => OptionsListUtils.addSMSDomainIfPhoneNumber(login)); - // - // // Make a shallow copy to preserve original data, and concat the login - // const policy = _.clone(allPolicies[key]); - // policy.employeeList = [...policy.employeeList, ...newEmployeeList]; - // policy.alertMessage = ''; - // - // // Optimistically add the user to the policy - // Onyx.merge(key, policy); - // - // // Make the API call to merge the login into the policy - // DeprecatedAPI.Policy_Employees_Merge({ - // employees: JSON.stringify(_.map(logins, login => ({email: login}))), - // welcomeNote, - // policyID, - // }) - // .then((data) => { - // // Save the personalDetails for the invited user in Onyx and fetch the latest policyExpenseChats - // if (data.jsonCode === 200) { - // Onyx.merge(ONYXKEYS.PERSONAL_DETAILS, PersonalDetails.formatPersonalDetails(data.personalDetails)); - // Navigation.goBack(); - // if (!_.isEmpty(data.policyExpenseChatIDs)) { - // Report.fetchChatReportsByIDs(data.policyExpenseChatIDs); - // } - // return; - // } - // - // // If the operation failed, undo the optimistic addition - // const policyDataWithoutLogin = _.clone(allPolicies[key]); - // policyDataWithoutLogin.employeeList = _.without(allPolicies[key].employeeList, ...newEmployeeList); - // - // // Show the user feedback that the addition failed - // policyDataWithoutLogin.alertMessage = Localize.translateLocal('workspace.invite.genericFailureMessage'); - // if (data.jsonCode === 402) { - // policyDataWithoutLogin.alertMessage += ` ${Localize.translateLocal('workspace.invite.pleaseEnterValidLogin')}`; - // } - // - // Onyx.set(key, policyDataWithoutLogin); - // }); -} - /** * Sets local values for the policy * @param {String} policyID @@ -637,7 +586,6 @@ export { getPolicyList, loadFullPolicy, removeMembers, - invite, addMembersToWorkspace, isAdminOfFreePolicy, create, diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index ae2c8627e1e9..626452d9894b 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -202,7 +202,8 @@ class WorkspaceInvitePage extends React.Component { const logins = _.map(this.state.selectedOptions, option => option.login); const filteredLogins = _.uniq(_.compact(_.map(logins, login => login.toLowerCase().trim()))); - Policy.invite(filteredLogins, this.state.welcomeNote || this.getWelcomeNote(), this.props.route.params.policyID); + Policy.addMembersToWorkspace(filteredLogins, this.state.welcomeNote || this.getWelcomeNote(), this.props.route.params.policyID); + Navigation.goBack() } /** From 2a2392b6e83c806b4450e47fd2dde639aeebbedd Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Thu, 18 Aug 2022 15:36:22 -0700 Subject: [PATCH 008/144] updating WorkspaceMembersPage to display member list --- src/pages/workspace/WorkspaceInvitePage.js | 2 +- src/pages/workspace/WorkspaceMembersPage.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index 626452d9894b..b57ed4557521 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -203,7 +203,7 @@ class WorkspaceInvitePage extends React.Component { const logins = _.map(this.state.selectedOptions, option => option.login); const filteredLogins = _.uniq(_.compact(_.map(logins, login => login.toLowerCase().trim()))); Policy.addMembersToWorkspace(filteredLogins, this.state.welcomeNote || this.getWelcomeNote(), this.props.route.params.policyID); - Navigation.goBack() + Navigation.goBack(); } /** diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 8f10c91b1992..b72fcdb00610 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -42,6 +42,9 @@ const propTypes = { }), }).isRequired, + /** List of members on this policy */ + memberList: PropTypes.arrayOf(PropTypes.object), + ...fullPolicyPropTypes, ...withLocalizePropTypes, ...windowDimensionsPropTypes, @@ -263,7 +266,7 @@ class WorkspaceMembersPage extends React.Component { } render() { - const policyEmployeeList = lodashGet(this.props, 'policy.employeeList', []); + const policyEmployeeList = _.keys(this.props.memberList); const removableMembers = _.without(this.props.policy.employeeList, this.props.session.email, this.props.policy.owner); const data = _.chain(policyEmployeeList) .map(email => this.props.personalDetails[email]) @@ -353,5 +356,8 @@ export default compose( session: { key: ONYXKEYS.SESSION, }, + memberList: { + key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST}${route.params.policyID}`, + }, }), )(WorkspaceMembersPage); From addfd8049eacdc7a8f9dbb34bde2c573a82cc96b Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Fri, 19 Aug 2022 09:26:58 +0000 Subject: [PATCH 009/144] remove usages of formatPaymentMethod --- src/libs/PaymentUtils.js | 81 +------------------ .../settings/Payments/PaymentMethodList.js | 2 +- 2 files changed, 2 insertions(+), 81 deletions(-) diff --git a/src/libs/PaymentUtils.js b/src/libs/PaymentUtils.js index ab94a57050c7..a08867bae531 100644 --- a/src/libs/PaymentUtils.js +++ b/src/libs/PaymentUtils.js @@ -4,7 +4,6 @@ import BankAccount from './models/BankAccount'; import * as Expensicons from '../components/Icon/Expensicons'; import getBankIcon from '../components/Icon/BankIcons'; import CONST from '../CONST'; -import * as Localize from './Localize'; /** * Check to see if user has either a debit card or personal bank account added @@ -30,7 +29,7 @@ function hasExpensifyPaymentMethod(cardList = [], bankAccountList = []) { * @param {Array} paymentMethodList * @returns {Array} */ -function formatPaymentMethods2(paymentMethodList) { +function formatPaymentMethods(paymentMethodList) { const paymentMethods = [...paymentMethodList]; _.each(paymentMethods, (paymentMethod, index) => { switch (paymentMethod.accountType) { @@ -60,83 +59,6 @@ function formatPaymentMethods2(paymentMethodList) { return paymentMethods; } -/** - * Get the PaymentMethods list - * @param {Array} bankAccountList - * @param {Array} cardList - * @param {String} [payPalMeUsername=''] - * @param {Object} userWallet - * @returns {Array} - */ -function formatPaymentMethods(bankAccountList, cardList, payPalMeUsername = '', userWallet) { - const combinedPaymentMethods = []; - - _.each(bankAccountList, (bankAccount) => { - // Add all bank accounts besides the wallet - if (bankAccount.type === CONST.BANK_ACCOUNT_TYPES.WALLET) { - return; - } - - const formattedBankAccountNumber = bankAccount.accountNumber - ? `${Localize.translateLocal('paymentMethodList.accountLastFour')} ${bankAccount.accountNumber.slice(-4) - }` - : null; - const isDefault = userWallet.walletLinkedAccountType === CONST.PAYMENT_METHODS.BANK_ACCOUNT && userWallet.walletLinkedAccountID === bankAccount.bankAccountID; - const {icon, iconSize} = getBankIcon(lodashGet(bankAccount, 'additionalData.bankName', '')); - combinedPaymentMethods.push({ - title: bankAccount.addressName, - description: formattedBankAccountNumber, - methodID: bankAccount.bankAccountID, - icon, - iconSize, - key: `bankAccount-${bankAccount.bankAccountID}`, - accountType: CONST.PAYMENT_METHODS.BANK_ACCOUNT, - accountData: _.extend({}, bankAccount, {icon}), - isDefault, - errors: bankAccount.errors, - pendingAction: bankAccount.pendingAction, - }); - }); - - _.each(cardList, (card) => { - const formattedCardNumber = card.cardNumber - ? `${Localize.translateLocal('paymentMethodList.cardLastFour')} ${card.cardNumber.slice(-4)}` - : null; - const isDefault = userWallet.walletLinkedAccountType === CONST.PAYMENT_METHODS.DEBIT_CARD && userWallet.walletLinkedAccountID === card.fundID; - const {icon, iconSize} = getBankIcon(card.bank, true); - combinedPaymentMethods.push({ - title: card.addressName, - description: formattedCardNumber, - methodID: card.fundID, - icon, - iconSize, - key: `card-${card.cardNumber}`, - accountType: CONST.PAYMENT_METHODS.DEBIT_CARD, - accountData: _.extend({}, card, {icon}), - isDefault, - errors: card.errors, - pendingAction: card.pendingAction, - }); - }); - - if (payPalMeUsername) { - combinedPaymentMethods.push({ - title: 'PayPal.me', - methodID: CONST.PAYMENT_METHODS.PAYPAL, - description: payPalMeUsername, - icon: Expensicons.PayPal, - key: 'payPalMePaymentMethod', - accountType: CONST.PAYMENT_METHODS.PAYPAL, - accountData: { - username: payPalMeUsername, - icon: Expensicons.PayPal, - }, - }); - } - - return combinedPaymentMethods; -} - /** * @param {Number} currentBalance, in cents * @param {String} methodType @@ -154,5 +76,4 @@ export { hasExpensifyPaymentMethod, formatPaymentMethods, calculateWalletTransferBalanceFee, - formatPaymentMethods2, }; diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index b8a060cad611..44d322546ba9 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -97,7 +97,7 @@ class PaymentMethodList extends Component { && paymentMethod.accountData.additionalData.isP2PDebitCard), ); - let combinedPaymentMethods = PaymentUtils.formatPaymentMethods2(filteredPaymentMethods); + let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(filteredPaymentMethods); if (!_.isEmpty(this.props.filterType)) { combinedPaymentMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === this.props.filterType); From 989eaba6eb25d897bb61dc760d18de92e1c337c5 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Wed, 24 Aug 2022 16:57:35 -0700 Subject: [PATCH 010/144] using key email to future proof code so role can be passed easily in future --- src/libs/actions/Policy.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 09a2aa1d31c5..c36f1057fa91 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -362,8 +362,7 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { ]; API.write('AddMembersToWorkspace', { - // employees: JSON.stringify(_.map(logins, login => ({email: login}))), - employees: JSON.stringify(logins), + employees: JSON.stringify(_.map(logins, login => ({email: login}))), welcomeNote, policyID, }, {optimisticData, successData, failureData}); From 7755c74aad43ecb8ab27da9cae8f5b514c68e60b Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Wed, 24 Aug 2022 17:03:47 -0700 Subject: [PATCH 011/144] removing unnecessary params --- src/pages/workspace/WorkspaceMembersPage.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index ee50a96a463b..eca3a2bcbe5f 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -42,9 +42,6 @@ const propTypes = { }), }).isRequired, - /** List of members on this policy */ - memberList: PropTypes.arrayOf(PropTypes.object), - ...fullPolicyPropTypes, ...withLocalizePropTypes, ...windowDimensionsPropTypes, @@ -357,8 +354,5 @@ export default compose( session: { key: ONYXKEYS.SESSION, }, - memberList: { - key: ({route}) => `${ONYXKEYS.COLLECTION.POLICY_MEMBER_LIST}${route.params.policyID}`, - }, }), )(WorkspaceMembersPage); From 8bdb1c1486ef6e4056320d51966891a6a4a68d37 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 1 Sep 2022 13:01:52 +0000 Subject: [PATCH 012/144] revert changes --- src/ONYXKEYS.js | 3 - src/components/bankAccountPropTypes.js | 8 +-- src/components/paymentMethodPropTypes.js | 27 -------- src/libs/PaymentUtils.js | 65 ++++++++++--------- .../settings/Payments/PaymentMethodList.js | 52 +++++++++++---- .../Payments/PaymentsPage/BasePaymentsPage.js | 13 +++- .../PaymentsPage/paymentsPagePropTypes.js | 7 +- .../settings/Payments/TransferBalancePage.js | 43 +++++++++--- 8 files changed, 124 insertions(+), 94 deletions(-) delete mode 100644 src/components/paymentMethodPropTypes.js diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 61c8cf397e8c..ab94c4dff47c 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -116,9 +116,6 @@ export default { // The user's bank accounts BANK_ACCOUNT_LIST: 'bankAccountList', - // The user's payment methods - PAYMENT_METHOD_LIST: 'paymentMethodList', - // The user's credit cards CARD_LIST: 'cardList', diff --git a/src/components/bankAccountPropTypes.js b/src/components/bankAccountPropTypes.js index 3331a617cbce..06011ff92048 100644 --- a/src/components/bankAccountPropTypes.js +++ b/src/components/bankAccountPropTypes.js @@ -2,14 +2,14 @@ import PropTypes from 'prop-types'; export default PropTypes.shape({ /** The name of the institution (bank of america, etc */ - addressName: PropTypes.string, + title: PropTypes.string, /** The masked bank account number */ - accountNumber: PropTypes.string, + description: PropTypes.string, /** The bankAccountID in the bankAccounts db */ - bankAccountID: PropTypes.number, + methodID: PropTypes.number, /** The bank account type */ - type: PropTypes.string, + accountType: PropTypes.string, }); diff --git a/src/components/paymentMethodPropTypes.js b/src/components/paymentMethodPropTypes.js deleted file mode 100644 index 9bbf4eb455fc..000000000000 --- a/src/components/paymentMethodPropTypes.js +++ /dev/null @@ -1,27 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - /** The name of the payment method (bank of Plaid Checking, etc) */ - title: PropTypes.string, - - /** The masked bank account number */ - description: PropTypes.string, - - /** The bankAccountID in the bankAccounts db */ - methodID: PropTypes.oneOfType([ - PropTypes.number, - PropTypes.string, - ]), - - /** The unique key for the payment method */ - key: PropTypes.string, - - /** The type of account ( bankAccount, payPalMe etc */ - accountType: PropTypes.string, - - /** The whole data of the payment method */ - accountData: PropTypes.shape, - - /** Indicates if this is the default payment method */ - isDefault: PropTypes.bool, -}); diff --git a/src/libs/PaymentUtils.js b/src/libs/PaymentUtils.js index a08867bae531..6f1536041561 100644 --- a/src/libs/PaymentUtils.js +++ b/src/libs/PaymentUtils.js @@ -1,7 +1,6 @@ import _ from 'underscore'; import lodashGet from 'lodash/get'; import BankAccount from './models/BankAccount'; -import * as Expensicons from '../components/Icon/Expensicons'; import getBankIcon from '../components/Icon/BankIcons'; import CONST from '../CONST'; @@ -25,38 +24,44 @@ function hasExpensifyPaymentMethod(cardList = [], bankAccountList = []) { } /** - * Get the PaymentMethod list with icons - * @param {Array} paymentMethodList + * Get the PaymentMethods list + * @param {Array} bankAccountList + * @param {Array} cardList + * @param {Object} [payPalDetails = null] * @returns {Array} */ -function formatPaymentMethods(paymentMethodList) { - const paymentMethods = [...paymentMethodList]; - _.each(paymentMethods, (paymentMethod, index) => { - switch (paymentMethod.accountType) { - case CONST.PAYMENT_METHODS.BANK_ACCOUNT: { - const {icon, iconSize} = getBankIcon(lodashGet(paymentMethod, 'additionalData.bankName', '')); - paymentMethods[index].icon = icon; - paymentMethods[index].iconSize = iconSize; - break; - } - case CONST.PAYMENT_METHODS.DEBIT_CARD: { - const {icon, iconSize} = getBankIcon(paymentMethod.accountData.bank, true); - paymentMethods[index].icon = icon; - paymentMethods[index].iconSize = iconSize; - break; - } - case CONST.PAYMENT_METHODS.PAYPAL: { - paymentMethods[index].icon = Expensicons.PayPal; - break; - } - default: { - paymentMethods[index].icon = ''; - paymentMethods[index].iconSize = ''; - break; - } - } +function formatPaymentMethods(bankAccountList, cardList, payPalDetails = null) { + const combinedPaymentMethods = []; + + _.each(bankAccountList, (bankAccount) => { + const {icon, iconSize} = getBankIcon(lodashGet(bankAccount, 'additionalData.bankName', '')); + combinedPaymentMethods.push({ + ...bankAccount, + icon, + iconSize, + errors: bankAccount.errors, + pendingAction: bankAccount.pendingAction, + }); + }); + + _.each(cardList, (card) => { + const {icon, iconSize} = getBankIcon(card.bank, true); + combinedPaymentMethods.push({ + ...card, + icon, + iconSize, + errors: card.errors, + pendingAction: card.pendingAction, + }); }); - return paymentMethods; + + if (payPalDetails) { + combinedPaymentMethods.push({ + ...payPalDetails, + }); + } + + return combinedPaymentMethods; } /** diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 7df3ecc38497..6d4882834abd 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -14,12 +14,13 @@ import withLocalize, {withLocalizePropTypes} from '../../../components/withLocal import ONYXKEYS from '../../../ONYXKEYS'; import CONST from '../../../CONST'; import * as Expensicons from '../../../components/Icon/Expensicons'; +import bankAccountPropTypes from '../../../components/bankAccountPropTypes'; +import cardPropTypes from '../../../components/cardPropTypes'; import * as PaymentUtils from '../../../libs/PaymentUtils'; import FormAlertWrapper from '../../../components/FormAlertWrapper'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import Log from '../../../libs/Log'; -import paymentMethodPropTypes from '../../../components/paymentMethodPropTypes'; const MENU_ITEM = 'menuItem'; const BUTTON = 'button'; @@ -28,8 +29,14 @@ const propTypes = { /** What to do when a menu item is pressed */ onPress: PropTypes.func.isRequired, - /** List of payment methods */ - paymentMethodList: PropTypes.arrayOf(paymentMethodPropTypes), + /** User's paypal.me username if they have one */ + payPalUserDetails: bankAccountPropTypes, + + /** List of bank accounts */ + bankAccountList: PropTypes.objectOf(bankAccountPropTypes), + + /** List of cards */ + cardList: PropTypes.objectOf(cardPropTypes), /** Whether the add Payment button be shown on the list */ shouldShowAddPaymentMethodButton: PropTypes.bool, @@ -37,6 +44,15 @@ const propTypes = { /** Type to filter the payment Method list */ filterType: PropTypes.oneOf([CONST.PAYMENT_METHODS.DEBIT_CARD, CONST.PAYMENT_METHODS.BANK_ACCOUNT, '']), + /** User wallet props */ + userWallet: PropTypes.shape({ + /** The ID of the linked account */ + walletLinkedAccountID: PropTypes.number, + + /** The type of the linked account (debitCard or bankAccount) */ + walletLinkedAccountType: PropTypes.string, + }), + /** Type of active/highlighted payment method */ actionPaymentMethodType: PropTypes.oneOf([..._.values(CONST.PAYMENT_METHODS), '']), @@ -50,7 +66,13 @@ const propTypes = { }; const defaultProps = { - paymentMethodList: [], + payPalUserDetails: {}, + bankAccountList: {}, + cardList: {}, + userWallet: { + walletLinkedAccountID: 0, + walletLinkedAccountType: '', + }, shouldShowAddPaymentMethodButton: true, filterType: '', actionPaymentMethodType: '', @@ -91,13 +113,8 @@ class PaymentMethodList extends Component { */ getFilteredPaymentMethods() { // Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them - const filteredPaymentMethods = _.filter( - this.props.paymentMethodList, paymentMethod => !(paymentMethod.accountType === CONST.PAYMENT_METHODS.DEBIT_CARD - && paymentMethod.accountData.additionalData - && paymentMethod.accountData.additionalData.isP2PDebitCard), - ); - - let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(filteredPaymentMethods); + const filteredCardList = _.filter(this.props.cardList, card => card.accountData.additionalData.isP2PDebitCard); + let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, filteredCardList, this.props.payPalUserDetails); if (!_.isEmpty(this.props.filterType)) { combinedPaymentMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === this.props.filterType); @@ -260,8 +277,17 @@ PaymentMethodList.defaultProps = defaultProps; export default compose( withLocalize, withOnyx({ - paymentMethodList: { - key: ONYXKEYS.PAYMENT_METHOD_LIST, + bankAccountList: { + key: ONYXKEYS.BANK_ACCOUNT_LIST, + }, + cardList: { + key: ONYXKEYS.CARD_LIST, + }, + payPalMeUsername: { + key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, + }, + userWallet: { + key: ONYXKEYS.USER_WALLET, }, }), )(PaymentMethodList); diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index aeaa00b80aac..1290f751426b 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -31,6 +31,7 @@ import * as Expensicons from '../../../../components/Icon/Expensicons'; import KYCWall from '../../../../components/KYCWall'; import {propTypes, defaultProps} from './paymentsPagePropTypes'; import {withNetwork} from '../../../../components/OnyxProvider'; +import * as PaymentUtils from '../../../../libs/PaymentUtils'; import OfflineWithFeedback from '../../../../components/OfflineWithFeedback'; class BasePaymentsPage extends React.Component { @@ -226,7 +227,10 @@ class BasePaymentsPage extends React.Component { makeDefaultPaymentMethod(password) { // Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors - const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); + const paymentMethods = PaymentUtils.formatPaymentMethods( + this.props.bankAccountList, + this.props.cardList, + ); const previousPaymentMethod = _.find(paymentMethods, method => method.isDefault); const previousPaymentMethodID = lodashGet(previousPaymentMethod, 'methodID'); @@ -452,8 +456,11 @@ export default compose( userWallet: { key: ONYXKEYS.USER_WALLET, }, - paymentMethodList: { - key: ONYXKEYS.PAYMENT_METHOD_LIST, + bankAccountList: { + key: ONYXKEYS.BANK_ACCOUNT_LIST, + }, + cardList: { + key: ONYXKEYS.CARD_LIST, }, }), )(BasePaymentsPage); diff --git a/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js b/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js index 76cf4d8c0af5..53dca3d790c9 100644 --- a/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js +++ b/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js @@ -6,7 +6,6 @@ import networkPropTypes from '../../../../components/networkPropTypes'; import bankAccountPropTypes from '../../../../components/bankAccountPropTypes'; import cardPropTypes from '../../../../components/cardPropTypes'; import userWalletPropTypes from '../../../EnablePayments/userWalletPropTypes'; -import paymentMethodPropTypes from '../../../../components/paymentMethodPropTypes'; const propTypes = { /** Wallet balance transfer props */ @@ -33,9 +32,6 @@ const propTypes = { /** List of cards */ cardList: PropTypes.objectOf(cardPropTypes), - /** List of payment methods */ - paymentMethodList: PropTypes.arrayOf(paymentMethodPropTypes), - ...withLocalizePropTypes, ...windowDimensionsPropTypes, @@ -49,7 +45,8 @@ const defaultProps = { isLoadingPaymentMethods: true, shouldListenForResize: false, userWallet: {}, - paymentMethodList: [], + bankAccountList: {}, + cardList: {}, }; export {propTypes, defaultProps}; diff --git a/src/pages/settings/Payments/TransferBalancePage.js b/src/pages/settings/Payments/TransferBalancePage.js index 48e08bb8927a..a8d6fa283682 100644 --- a/src/pages/settings/Payments/TransferBalancePage.js +++ b/src/pages/settings/Payments/TransferBalancePage.js @@ -24,18 +24,33 @@ import CurrentWalletBalance from '../../../components/CurrentWalletBalance'; import walletTransferPropTypes from './walletTransferPropTypes'; import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; import * as PaymentUtils from '../../../libs/PaymentUtils'; +import cardPropTypes from '../../../components/cardPropTypes'; import userWalletPropTypes from '../../EnablePayments/userWalletPropTypes'; import ROUTES from '../../../ROUTES'; import FormAlertWithSubmitButton from '../../../components/FormAlertWithSubmitButton'; import {withNetwork} from '../../../components/OnyxProvider'; -import paymentMethodPropTypes from '../../../components/paymentMethodPropTypes'; const propTypes = { /** User's wallet information */ userWallet: PropTypes.objectOf(userWalletPropTypes), - /** List of payment methods */ - paymentMethodList: PropTypes.arrayOf(paymentMethodPropTypes), + /** List of bank accounts */ + bankAccountList: PropTypes.objectOf(PropTypes.shape({ + /** The name of the institution (bank of america, etc) */ + addressName: PropTypes.string, + + /** The masked bank account number */ + accountNumber: PropTypes.string, + + /** The bankAccountID in the bankAccounts db */ + bankAccountID: PropTypes.number, + + /** The bank account type */ + type: PropTypes.string, + })), + + /** List of card objects */ + cardList: PropTypes.objectOf(cardPropTypes), /** Wallet balance transfer props */ walletTransfer: walletTransferPropTypes, @@ -44,7 +59,8 @@ const propTypes = { }; const defaultProps = { - paymentMethodList: [], + bankAccountList: {}, + cardList: {}, userWallet: {}, walletTransfer: {}, }; @@ -96,7 +112,10 @@ class TransferBalancePage extends React.Component { * @returns {Object|undefined} */ getSelectedPaymentMethodAccount() { - const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); + const paymentMethods = PaymentUtils.formatPaymentMethods( + this.props.bankAccountList, + this.props.cardList, + ); const defaultAccount = _.find(paymentMethods, method => method.isDefault); const selectedAccount = _.find( @@ -114,9 +133,12 @@ class TransferBalancePage extends React.Component { PaymentMethods.saveWalletTransferMethodType(filterPaymentMethodType); // If we only have a single option for the given paymentMethodType do not force the user to make a selection - const paymentMethods = _.filter(this.props.paymentMethodList, paymentMethod => paymentMethod.accountType !== CONST.PAYMENT_METHODS.PAYPAL); + const combinedPaymentMethods = PaymentUtils.formatPaymentMethods( + this.props.bankAccountList, + this.props.cardList, + ); - const filteredMethods = _.filter(paymentMethods, paymentMethod => paymentMethod.accountType === filterPaymentMethodType); + const filteredMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === filterPaymentMethodType); if (filteredMethods.length === 1) { const account = _.first(filteredMethods); PaymentMethods.saveWalletTransferAccountTypeAndID( @@ -287,8 +309,11 @@ export default compose( walletTransfer: { key: ONYXKEYS.WALLET_TRANSFER, }, - paymentMethodList: { - key: ONYXKEYS.PAYMENT_METHOD_LIST, + bankAccountList: { + key: ONYXKEYS.BANK_ACCOUNT_LIST, + }, + cardList: { + key: ONYXKEYS.CARD_LIST, }, }), )(TransferBalancePage); From 75352c154bfaa8b3c3cf50a486117d0853562ec1 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 1 Sep 2022 14:10:25 +0000 Subject: [PATCH 013/144] fix duplicated payment list --- src/components/AddPaymentMethodMenu.js | 9 +++++---- src/components/bankAccountPropTypes.js | 4 ++-- src/pages/settings/Payments/PaymentMethodList.js | 8 ++++---- .../Payments/PaymentsPage/paymentsPagePropTypes.js | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index 1727cc719a19..b7052a20492b 100644 --- a/src/components/AddPaymentMethodMenu.js +++ b/src/components/AddPaymentMethodMenu.js @@ -9,6 +9,7 @@ import CONST from '../CONST'; import withWindowDimensions from './withWindowDimensions'; import Permissions from '../libs/Permissions'; import PopoverMenu from './PopoverMenu'; +import bankAccountPropTypes from './bankAccountPropTypes'; const propTypes = { isVisible: PropTypes.bool.isRequired, @@ -19,7 +20,7 @@ const propTypes = { }), /** Username for PayPal.Me */ - payPalMeUsername: PropTypes.string, + payPalMeUserDetails: bankAccountPropTypes, /** Should we show the Paypal option */ shouldShowPaypal: PropTypes.bool, @@ -32,7 +33,7 @@ const propTypes = { const defaultProps = { anchorPosition: {}, - payPalMeUsername: '', + payPalMeUserDetails: {}, shouldShowPaypal: true, betas: [], }; @@ -55,7 +56,7 @@ const AddPaymentMethodMenu = props => ( onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD), }, ] : []), - ...(props.shouldShowPaypal && !props.payPalMeUsername ? [{ + ...(props.shouldShowPaypal && !props.payPalMeUserDetails.description ? [{ text: props.translate('common.payPalMe'), icon: Expensicons.PayPal, onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.PAYPAL), @@ -72,7 +73,7 @@ export default compose( withWindowDimensions, withLocalize, withOnyx({ - payPalMeUsername: { + payPalMeUserDetails: { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, }, betas: { diff --git a/src/components/bankAccountPropTypes.js b/src/components/bankAccountPropTypes.js index 06011ff92048..5ec1c43d846c 100644 --- a/src/components/bankAccountPropTypes.js +++ b/src/components/bankAccountPropTypes.js @@ -5,10 +5,10 @@ export default PropTypes.shape({ title: PropTypes.string, /** The masked bank account number */ - description: PropTypes.string, + description: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** The bankAccountID in the bankAccounts db */ - methodID: PropTypes.number, + methodID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** The bank account type */ accountType: PropTypes.string, diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 6d4882834abd..79450aa48e6f 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -30,7 +30,7 @@ const propTypes = { onPress: PropTypes.func.isRequired, /** User's paypal.me username if they have one */ - payPalUserDetails: bankAccountPropTypes, + payPalMeUserDetails: bankAccountPropTypes, /** List of bank accounts */ bankAccountList: PropTypes.objectOf(bankAccountPropTypes), @@ -66,7 +66,7 @@ const propTypes = { }; const defaultProps = { - payPalUserDetails: {}, + payPalMeUserDetails: {}, bankAccountList: {}, cardList: {}, userWallet: { @@ -114,7 +114,7 @@ class PaymentMethodList extends Component { getFilteredPaymentMethods() { // Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them const filteredCardList = _.filter(this.props.cardList, card => card.accountData.additionalData.isP2PDebitCard); - let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, filteredCardList, this.props.payPalUserDetails); + let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, filteredCardList, this.props.payPalMeUserDetails); if (!_.isEmpty(this.props.filterType)) { combinedPaymentMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === this.props.filterType); @@ -283,7 +283,7 @@ export default compose( cardList: { key: ONYXKEYS.CARD_LIST, }, - payPalMeUsername: { + payPalMeUserDetails: { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, }, userWallet: { diff --git a/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js b/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js index 53dca3d790c9..3bae92599c97 100644 --- a/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js +++ b/src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js @@ -21,7 +21,7 @@ const propTypes = { shouldListenForResize: PropTypes.bool, /** The user's wallet account */ - userWallet: PropTypes.objectOf(userWalletPropTypes), + userWallet: userWalletPropTypes, /** Information about the network */ network: networkPropTypes.isRequired, From 052be303edb82d32f686a595723d6b048ac51deb Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 1 Sep 2022 14:22:51 +0000 Subject: [PATCH 014/144] rename the paypalMe username --- src/pages/settings/Payments/AddPayPalMePage.js | 16 ++++++++-------- src/pages/settings/Payments/PaymentMethodList.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/settings/Payments/AddPayPalMePage.js b/src/pages/settings/Payments/AddPayPalMePage.js index 2e8bdff1d8e7..fa03e097bd49 100644 --- a/src/pages/settings/Payments/AddPayPalMePage.js +++ b/src/pages/settings/Payments/AddPayPalMePage.js @@ -1,6 +1,5 @@ import React from 'react'; import {View} from 'react-native'; -import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import CONST from '../../../CONST'; import ONYXKEYS from '../../../ONYXKEYS'; @@ -18,16 +17,17 @@ import Growl from '../../../libs/Growl'; import TextInput from '../../../components/TextInput'; import * as ValidationUtils from '../../../libs/ValidationUtils'; import * as User from '../../../libs/actions/User'; +import bankAccountPropTypes from '../../../components/bankAccountPropTypes'; const propTypes = { - /** Username for PayPal.Me */ - payPalMeUsername: PropTypes.string, + /** Account details for PayPal.Me */ + payPalMeUserDetails: bankAccountPropTypes, ...withLocalizePropTypes, }; const defaultProps = { - payPalMeUsername: '', + payPalMeUserDetails: {}, }; class AddPayPalMePage extends React.Component { @@ -35,7 +35,7 @@ class AddPayPalMePage extends React.Component { super(props); this.state = { - payPalMeUsername: props.payPalMeUsername, + payPalMeUsername: props.payPalMeUserDetails.description, payPalMeUsernameError: false, }; this.setPayPalMeUsername = this.setPayPalMeUsername.bind(this); @@ -90,8 +90,8 @@ class AddPayPalMePage extends React.Component { onPress={this.setPayPalMeUsername} pressOnEnter style={[styles.mt3]} - isDisabled={this.state.payPalMeUsername === this.props.payPalMeUsername} - text={this.props.payPalMeUsername + isDisabled={this.state.payPalMeUsername === this.props.payPalMeUserDetails.description} + text={this.props.payPalMeUserDetails.description ? this.props.translate('addPayPalMePage.editPayPalAccount') : this.props.translate('addPayPalMePage.addPayPalAccount')} /> @@ -108,7 +108,7 @@ AddPayPalMePage.displayName = 'AddPayPalMePage'; export default compose( withLocalize, withOnyx({ - payPalMeUsername: { + payPalMeUserDetails: { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, }, }), diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 79450aa48e6f..d1767497a33c 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -29,7 +29,7 @@ const propTypes = { /** What to do when a menu item is pressed */ onPress: PropTypes.func.isRequired, - /** User's paypal.me username if they have one */ + /** User's paypal.me account details if they have one */ payPalMeUserDetails: bankAccountPropTypes, /** List of bank accounts */ From c00154ea5603500859f7e109d0329ddbfe0870a8 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 8 Sep 2022 13:02:43 +0000 Subject: [PATCH 015/144] resolve possible regression --- src/libs/actions/PaymentMethods.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/PaymentMethods.js b/src/libs/actions/PaymentMethods.js index 9d648b489815..d271d8dee5cc 100644 --- a/src/libs/actions/PaymentMethods.js +++ b/src/libs/actions/PaymentMethods.js @@ -107,7 +107,9 @@ function openPaymentsPage() { ], }; - return API.read('OpenPaymentsPage', {}, onyxData); + return API.read('OpenPaymentsPage', { + massageData: true, + }, onyxData); } /** From 8e7b0b42ef7ec6628f837cfee03e38925da0caf8 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Mon, 12 Sep 2022 13:23:53 +0000 Subject: [PATCH 016/144] add paypal me proptypes --- src/components/paypalMeDataPropTypes.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/components/paypalMeDataPropTypes.js diff --git a/src/components/paypalMeDataPropTypes.js b/src/components/paypalMeDataPropTypes.js new file mode 100644 index 000000000000..5ec1c43d846c --- /dev/null +++ b/src/components/paypalMeDataPropTypes.js @@ -0,0 +1,15 @@ +import PropTypes from 'prop-types'; + +export default PropTypes.shape({ + /** The name of the institution (bank of america, etc */ + title: PropTypes.string, + + /** The masked bank account number */ + description: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + + /** The bankAccountID in the bankAccounts db */ + methodID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + + /** The bank account type */ + accountType: PropTypes.string, +}); From f005b706c79439dabfe02e94ac7b269a155c9aff Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Mon, 12 Sep 2022 13:24:12 +0000 Subject: [PATCH 017/144] address changes --- src/components/AddPaymentMethodMenu.js | 12 ++++++------ src/components/bankAccountPropTypes.js | 8 ++++---- src/libs/PaymentUtils.js | 14 +++++++------- src/libs/actions/PaymentMethods.js | 3 +++ src/pages/settings/Payments/AddPayPalMePage.js | 14 +++++++------- src/pages/settings/Payments/PaymentMethodList.js | 11 ++++++----- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index b7052a20492b..eab3d5f21a69 100644 --- a/src/components/AddPaymentMethodMenu.js +++ b/src/components/AddPaymentMethodMenu.js @@ -9,7 +9,7 @@ import CONST from '../CONST'; import withWindowDimensions from './withWindowDimensions'; import Permissions from '../libs/Permissions'; import PopoverMenu from './PopoverMenu'; -import bankAccountPropTypes from './bankAccountPropTypes'; +import paypalMeDataPropTypes from './paypalMeDataPropTypes'; const propTypes = { isVisible: PropTypes.bool.isRequired, @@ -19,8 +19,8 @@ const propTypes = { left: PropTypes.number, }), - /** Username for PayPal.Me */ - payPalMeUserDetails: bankAccountPropTypes, + /** Account details for PayPal.Me */ + payPalMeData: paypalMeDataPropTypes, /** Should we show the Paypal option */ shouldShowPaypal: PropTypes.bool, @@ -33,7 +33,7 @@ const propTypes = { const defaultProps = { anchorPosition: {}, - payPalMeUserDetails: {}, + payPalMeData: {}, shouldShowPaypal: true, betas: [], }; @@ -56,7 +56,7 @@ const AddPaymentMethodMenu = props => ( onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD), }, ] : []), - ...(props.shouldShowPaypal && !props.payPalMeUserDetails.description ? [{ + ...(props.shouldShowPaypal && !props.payPalMeData.description ? [{ text: props.translate('common.payPalMe'), icon: Expensicons.PayPal, onSelected: () => props.onItemSelected(CONST.PAYMENT_METHODS.PAYPAL), @@ -73,7 +73,7 @@ export default compose( withWindowDimensions, withLocalize, withOnyx({ - payPalMeUserDetails: { + payPalMeData: { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, }, betas: { diff --git a/src/components/bankAccountPropTypes.js b/src/components/bankAccountPropTypes.js index 5ec1c43d846c..3331a617cbce 100644 --- a/src/components/bankAccountPropTypes.js +++ b/src/components/bankAccountPropTypes.js @@ -2,14 +2,14 @@ import PropTypes from 'prop-types'; export default PropTypes.shape({ /** The name of the institution (bank of america, etc */ - title: PropTypes.string, + addressName: PropTypes.string, /** The masked bank account number */ - description: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + accountNumber: PropTypes.string, /** The bankAccountID in the bankAccounts db */ - methodID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + bankAccountID: PropTypes.number, /** The bank account type */ - accountType: PropTypes.string, + type: PropTypes.string, }); diff --git a/src/libs/PaymentUtils.js b/src/libs/PaymentUtils.js index 6f1536041561..76b92006d853 100644 --- a/src/libs/PaymentUtils.js +++ b/src/libs/PaymentUtils.js @@ -18,7 +18,7 @@ function hasExpensifyPaymentMethod(cardList = [], bankAccountList = []) { }); // Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them - const validDebitCard = _.some(cardList, card => lodashGet(card, 'additionalData.isP2PDebitCard', false)); + const validDebitCard = _.some(cardList, card => lodashGet(card, 'accountData.additionalData.isP2PDebitCard', false)); return validBankAccount || validDebitCard; } @@ -27,14 +27,14 @@ function hasExpensifyPaymentMethod(cardList = [], bankAccountList = []) { * Get the PaymentMethods list * @param {Array} bankAccountList * @param {Array} cardList - * @param {Object} [payPalDetails = null] + * @param {Object} [payPalMeData = null] * @returns {Array} */ -function formatPaymentMethods(bankAccountList, cardList, payPalDetails = null) { +function formatPaymentMethods(bankAccountList, cardList, payPalMeData = null) { const combinedPaymentMethods = []; _.each(bankAccountList, (bankAccount) => { - const {icon, iconSize} = getBankIcon(lodashGet(bankAccount, 'additionalData.bankName', '')); + const {icon, iconSize} = getBankIcon(lodashGet(bankAccount, 'accountData.additionalData.bankName', '')); combinedPaymentMethods.push({ ...bankAccount, icon, @@ -45,7 +45,7 @@ function formatPaymentMethods(bankAccountList, cardList, payPalDetails = null) { }); _.each(cardList, (card) => { - const {icon, iconSize} = getBankIcon(card.bank, true); + const {icon, iconSize} = getBankIcon(lodashGet(card, 'accountData.bank', ''), true); combinedPaymentMethods.push({ ...card, icon, @@ -55,9 +55,9 @@ function formatPaymentMethods(bankAccountList, cardList, payPalDetails = null) { }); }); - if (payPalDetails) { + if (payPalMeData) { combinedPaymentMethods.push({ - ...payPalDetails, + ...payPalMeData, }); } diff --git a/src/libs/actions/PaymentMethods.js b/src/libs/actions/PaymentMethods.js index d271d8dee5cc..1563d8309bc6 100644 --- a/src/libs/actions/PaymentMethods.js +++ b/src/libs/actions/PaymentMethods.js @@ -108,6 +108,9 @@ function openPaymentsPage() { }; return API.read('OpenPaymentsPage', { + // We're passing this to have the data returned in the right format. + // This can be removed when the massageData parameter + // is removed from here https://github.com/Expensify/Web-Expensify/blob/main/lib/BankAccountAPI.php#L1064. massageData: true, }, onyxData); } diff --git a/src/pages/settings/Payments/AddPayPalMePage.js b/src/pages/settings/Payments/AddPayPalMePage.js index fa03e097bd49..43e9381c55da 100644 --- a/src/pages/settings/Payments/AddPayPalMePage.js +++ b/src/pages/settings/Payments/AddPayPalMePage.js @@ -17,17 +17,17 @@ import Growl from '../../../libs/Growl'; import TextInput from '../../../components/TextInput'; import * as ValidationUtils from '../../../libs/ValidationUtils'; import * as User from '../../../libs/actions/User'; -import bankAccountPropTypes from '../../../components/bankAccountPropTypes'; +import paypalMeDataPropTypes from '../../../components/paypalMeDataPropTypes'; const propTypes = { /** Account details for PayPal.Me */ - payPalMeUserDetails: bankAccountPropTypes, + payPalMeData: paypalMeDataPropTypes, ...withLocalizePropTypes, }; const defaultProps = { - payPalMeUserDetails: {}, + payPalMeData: {}, }; class AddPayPalMePage extends React.Component { @@ -35,7 +35,7 @@ class AddPayPalMePage extends React.Component { super(props); this.state = { - payPalMeUsername: props.payPalMeUserDetails.description, + payPalMeUsername: props.payPalMeData.description, payPalMeUsernameError: false, }; this.setPayPalMeUsername = this.setPayPalMeUsername.bind(this); @@ -90,8 +90,8 @@ class AddPayPalMePage extends React.Component { onPress={this.setPayPalMeUsername} pressOnEnter style={[styles.mt3]} - isDisabled={this.state.payPalMeUsername === this.props.payPalMeUserDetails.description} - text={this.props.payPalMeUserDetails.description + isDisabled={this.state.payPalMeUsername === this.props.payPalMeData.description} + text={this.props.payPalMeData.description ? this.props.translate('addPayPalMePage.editPayPalAccount') : this.props.translate('addPayPalMePage.addPayPalAccount')} /> @@ -108,7 +108,7 @@ AddPayPalMePage.displayName = 'AddPayPalMePage'; export default compose( withLocalize, withOnyx({ - payPalMeUserDetails: { + payPalMeData: { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, }, }), diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index d1767497a33c..d6121ba4d228 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -15,6 +15,7 @@ import ONYXKEYS from '../../../ONYXKEYS'; import CONST from '../../../CONST'; import * as Expensicons from '../../../components/Icon/Expensicons'; import bankAccountPropTypes from '../../../components/bankAccountPropTypes'; +import paypalMeDataPropTypes from '../../../components/paypalMeDataPropTypes'; import cardPropTypes from '../../../components/cardPropTypes'; import * as PaymentUtils from '../../../libs/PaymentUtils'; import FormAlertWrapper from '../../../components/FormAlertWrapper'; @@ -29,8 +30,8 @@ const propTypes = { /** What to do when a menu item is pressed */ onPress: PropTypes.func.isRequired, - /** User's paypal.me account details if they have one */ - payPalMeUserDetails: bankAccountPropTypes, + /** Account details for PayPal.Me */ + payPalMeData: paypalMeDataPropTypes, /** List of bank accounts */ bankAccountList: PropTypes.objectOf(bankAccountPropTypes), @@ -66,7 +67,7 @@ const propTypes = { }; const defaultProps = { - payPalMeUserDetails: {}, + payPalMeData: {}, bankAccountList: {}, cardList: {}, userWallet: { @@ -114,7 +115,7 @@ class PaymentMethodList extends Component { getFilteredPaymentMethods() { // Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them const filteredCardList = _.filter(this.props.cardList, card => card.accountData.additionalData.isP2PDebitCard); - let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, filteredCardList, this.props.payPalMeUserDetails); + let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(this.props.bankAccountList, filteredCardList, this.props.payPalMeData); if (!_.isEmpty(this.props.filterType)) { combinedPaymentMethods = _.filter(combinedPaymentMethods, paymentMethod => paymentMethod.accountType === this.props.filterType); @@ -283,7 +284,7 @@ export default compose( cardList: { key: ONYXKEYS.CARD_LIST, }, - payPalMeUserDetails: { + payPalMeData: { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, }, userWallet: { From 11099190c27ad5cd63b6326ab456f9e765b83334 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Tue, 13 Sep 2022 17:35:41 +0000 Subject: [PATCH 018/144] add onyx key --- src/ONYXKEYS.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index ab94c4dff47c..a484b7db52bc 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -67,6 +67,9 @@ export default { // Contains the user's payPalMe address NVP_PAYPAL_ME_ADDRESS: 'nvp_paypalMeAddress', + // Contains the user's payPalMe data + NVP_PAYPAL: 'nvp_paypalMe', + // Contains the user preference for the LHN priority mode NVP_PRIORITY_MODE: 'nvp_priorityMode', From 493cf01d0e7a247dceabec139c20f5a07f90f003 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Tue, 13 Sep 2022 17:36:22 +0000 Subject: [PATCH 019/144] delete paypal me data --- src/components/AddPaymentMethodMenu.js | 2 +- src/libs/PaymentUtils.js | 2 +- src/libs/actions/User.js | 22 ++++++++++++++++++- .../settings/Payments/AddPayPalMePage.js | 2 +- .../settings/Payments/PaymentMethodList.js | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index eab3d5f21a69..fa8998866483 100644 --- a/src/components/AddPaymentMethodMenu.js +++ b/src/components/AddPaymentMethodMenu.js @@ -74,7 +74,7 @@ export default compose( withLocalize, withOnyx({ payPalMeData: { - key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, + key: ONYXKEYS.NVP_PAYPAL, }, betas: { key: ONYXKEYS.BETAS, diff --git a/src/libs/PaymentUtils.js b/src/libs/PaymentUtils.js index 76b92006d853..a28fcddfb5c4 100644 --- a/src/libs/PaymentUtils.js +++ b/src/libs/PaymentUtils.js @@ -55,7 +55,7 @@ function formatPaymentMethods(bankAccountList, cardList, payPalMeData = null) { }); }); - if (payPalMeData) { + if (!_.isEmpty(payPalMeData)) { combinedPaymentMethods.push({ ...payPalMeData, }); diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index a7b71d9fd3b5..098987b0dd7a 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -272,6 +272,21 @@ function addPaypalMeAddress(address) { key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, value: address, }, + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.NVP_PAYPAL, + value: { + title: 'PayPal.me', + description: address, + methodID: CONST.PAYMENT_METHODS.PAYPAL, + key: 'payPalMePaymentMethod', + accountType: CONST.PAYMENT_METHODS.PAYPAL, + accountData: { + username: address, + }, + isDefault: false, + }, + }, ]; API.write('AddPaypalMeAddress', { value: address, @@ -285,10 +300,15 @@ function addPaypalMeAddress(address) { function deletePaypalMeAddress() { const optimisticData = [ { - onyxMethod: CONST.ONYX.METHOD.MERGE, + onyxMethod: CONST.ONYX.METHOD.SET, key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, value: '', }, + { + onyxMethod: CONST.ONYX.METHOD.SET, + key: ONYXKEYS.NVP_PAYPAL, + value: {}, + }, ]; API.write('DeletePaypalMeAddress', {}, {optimisticData}); Growl.show(Localize.translateLocal('paymentsPage.deletePayPalSuccess'), CONST.GROWL.SUCCESS, 3000); diff --git a/src/pages/settings/Payments/AddPayPalMePage.js b/src/pages/settings/Payments/AddPayPalMePage.js index 43e9381c55da..6161d8c8b1a3 100644 --- a/src/pages/settings/Payments/AddPayPalMePage.js +++ b/src/pages/settings/Payments/AddPayPalMePage.js @@ -109,7 +109,7 @@ export default compose( withLocalize, withOnyx({ payPalMeData: { - key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, + key: ONYXKEYS.NVP_PAYPAL, }, }), )(AddPayPalMePage); diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index d6121ba4d228..9fec802aa40b 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -285,7 +285,7 @@ export default compose( key: ONYXKEYS.CARD_LIST, }, payPalMeData: { - key: ONYXKEYS.NVP_PAYPAL_ME_ADDRESS, + key: ONYXKEYS.NVP_PAYPAL, }, userWallet: { key: ONYXKEYS.USER_WALLET, From 4713df2ca6b9a869a8ef876c7664e93436be156b Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Tue, 13 Sep 2022 16:24:01 -0700 Subject: [PATCH 020/144] Adding translations --- src/languages/en.js | 1 + src/languages/es.js | 1 + src/libs/actions/Policy.js | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/languages/en.js b/src/languages/en.js index c70131508112..716f709b2937 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -810,6 +810,7 @@ export default { removeMembersTitle: 'Remove members', selectAll: 'Select all', error: { + genericAdd: 'There was a problem adding this workspace member.', cannotRemove: 'You cannot remove yourself or the workspace owner.', }, }, diff --git a/src/languages/es.js b/src/languages/es.js index 68b50e078565..87bc60f59c61 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -812,6 +812,7 @@ export default { removeMembersTitle: 'Eliminar miembros', selectAll: 'Seleccionar todo', error: { + genericAdd: '', cannotRemove: 'No puedes eliminarte ni a ti mismo ni al dueño del espacio de trabajo.', }, }, diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index cd5428b7ba3b..87856569d434 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -283,7 +283,7 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { // need to remove the members since that is handled by onClose of OfflineWithFeedback. value: _.object(logins, Array(logins.length).fill({ errors: { - [DateUtils.getMicroseconds()]: 'some generic error', + [DateUtils.getMicroseconds()]: Localize.translateLocal('workspace.people.error.genericAdd'), }, })), }, From cf80a10bee1e6fbd0b50a90289ef266c68671241 Mon Sep 17 00:00:00 2001 From: madmax330 Date: Wed, 14 Sep 2022 13:26:18 +0100 Subject: [PATCH 021/144] Add UpdatePersonalInformationForBankAccount --- src/libs/actions/BankAccounts.js | 3 +- .../actions/ReimbursementAccount/index.js | 2 ++ ...updatePersonalInformationForBankAccount.js | 30 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index d2242b028962..546e3290c5cc 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -7,6 +7,7 @@ import DateUtils from '../DateUtils'; export { setupWithdrawalAccount, + updatePersonalInformationForBankAccount, fetchFreePlanVerifiedBankAccount, goToWithdrawalAccountSetupStep, showBankAccountErrorModal, @@ -48,7 +49,6 @@ function clearPlaid() { * @returns {Object} */ // We'll remove the below once this function is used by the VBBA commands that are yet to be implemented -/* eslint-disable no-unused-vars */ function getVBBADataForOnyx() { return { optimisticData: [ @@ -164,4 +164,5 @@ export { deletePaymentBankAccount, clearPersonalBankAccount, clearPlaid, + getVBBADataForOnyx, }; diff --git a/src/libs/actions/ReimbursementAccount/index.js b/src/libs/actions/ReimbursementAccount/index.js index 40481a15a06a..39c0256b0470 100644 --- a/src/libs/actions/ReimbursementAccount/index.js +++ b/src/libs/actions/ReimbursementAccount/index.js @@ -5,6 +5,7 @@ import setupWithdrawalAccount from './setupWithdrawalAccount'; import fetchFreePlanVerifiedBankAccount from './fetchFreePlanVerifiedBankAccount'; import resetFreePlanBankAccount from './resetFreePlanBankAccount'; import deleteFromBankAccountList from './deleteFromBankAccountList'; +import updatePersonalInformationForBankAccount from './updatePersonalInformationForBankAccount'; export {goToWithdrawalAccountSetupStep, navigateToBankAccountRoute} from './navigation'; export { @@ -65,4 +66,5 @@ export { requestResetFreePlanBankAccount, cancelResetFreePlanBankAccount, deleteFromBankAccountList, + updatePersonalInformationForBankAccount, }; diff --git a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js new file mode 100644 index 000000000000..003ffd74d9de --- /dev/null +++ b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js @@ -0,0 +1,30 @@ +import * as API from '../../API'; +import * as BankAccounts from '../BankAccounts'; + +/** +* Create or update the bank account in db with the updated data. +* +* This action is called by several steps in the Verified Bank Account flow and is coupled tightly with SetupWithdrawalAccount in Auth +* Each time the command is called the state of the bank account progresses a bit further and when handling the response we redirect +* to the appropriate next step in the flow. +* +* @param {Object} params +* +* // RequestorStep +* @param {String} [params.dob] +* @param {String} [params.firstName] +* @param {String} [params.lastName] +* @param {String} [params.requestorAddressStreet] +* @param {String} [params.requestorAddressCity] +* @param {String} [params.requestorAddressState] +* @param {String} [params.requestorAddressZipCode] +* @param {String} [params.ssnLast4] +* @param {String} [params.isControllingOfficer] +* @param {Object} [params.onfidoData] +* @param {Boolean} [params.isOnfidoSetupComplete] +*/ +function updatePersonalInformationForBankAccount(params) { + API.write('UpdatePersonalInformationForBankAccount', params, BankAccounts.getVBBADataForOnyx()); +} + +export default updatePersonalInformationForBankAccount; From 0c210403e579f019d2132a51518f354d61f0885a Mon Sep 17 00:00:00 2001 From: madmax330 Date: Wed, 14 Sep 2022 15:46:06 +0100 Subject: [PATCH 022/144] fix import cycle --- src/libs/BankAccountUtils.js | 47 +++++++++++++++++++ src/libs/actions/BankAccounts.js | 45 ------------------ ...updatePersonalInformationForBankAccount.js | 10 ++-- .../ReimbursementAccount/vbaOnyxData.js | 0 .../ReimbursementAccount/RequestorStep.js | 2 +- 5 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 src/libs/BankAccountUtils.js create mode 100644 src/libs/actions/ReimbursementAccount/vbaOnyxData.js diff --git a/src/libs/BankAccountUtils.js b/src/libs/BankAccountUtils.js new file mode 100644 index 000000000000..249294de6093 --- /dev/null +++ b/src/libs/BankAccountUtils.js @@ -0,0 +1,47 @@ +import CONST from '../CONST'; +import DateUtils from './DateUtils'; + +/** + * Helper method to build the Onyx data required during setup of a Verified Business Bank Account + * + * @returns {Object} + */ +// We'll remove the below once this function is used by the VBBA commands that are yet to be implemented +function getVBBADataForOnyx() { + return { + optimisticData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: true, + errors: null, + }, + }, + ], + successData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + errors: null, + }, + }, + ], + failureData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + errors: { + [DateUtils.getMicroseconds()]: Localize.translateLocal('paymentsPage.addBankAccountFailure'), + }, + }, + }, + ], + }; +} + +export {getVBBADataForOnyx}; diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 546e3290c5cc..e6de6402c1e8 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -3,7 +3,6 @@ import CONST from '../../CONST'; import * as API from '../API'; import ONYXKEYS from '../../ONYXKEYS'; import * as Localize from '../Localize'; -import DateUtils from '../DateUtils'; export { setupWithdrawalAccount, @@ -43,49 +42,6 @@ function clearPlaid() { Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, ''); } -/** - * Helper method to build the Onyx data required during setup of a Verified Business Bank Account - * - * @returns {Object} - */ -// We'll remove the below once this function is used by the VBBA commands that are yet to be implemented -function getVBBADataForOnyx() { - return { - optimisticData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: { - isLoading: true, - errors: null, - }, - }, - ], - successData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: { - isLoading: false, - errors: null, - }, - }, - ], - failureData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: { - isLoading: false, - errors: { - [DateUtils.getMicroseconds()]: Localize.translateLocal('paymentsPage.addBankAccountFailure'), - }, - }, - }, - ], - }; -} - /** * Adds a bank account via Plaid * @@ -164,5 +120,4 @@ export { deletePaymentBankAccount, clearPersonalBankAccount, clearPlaid, - getVBBADataForOnyx, }; diff --git a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js index 003ffd74d9de..8046b48db1f1 100644 --- a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js +++ b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js @@ -1,12 +1,10 @@ import * as API from '../../API'; -import * as BankAccounts from '../BankAccounts'; +import * as BankAccountUtils from '../../BankAccountUtils'; /** -* Create or update the bank account in db with the updated data. +* Update the user's personal information on the bank account in database. * -* This action is called by several steps in the Verified Bank Account flow and is coupled tightly with SetupWithdrawalAccount in Auth -* Each time the command is called the state of the bank account progresses a bit further and when handling the response we redirect -* to the appropriate next step in the flow. +* This action is called by the requestor step in the Verified Bank Account flow * * @param {Object} params * @@ -24,7 +22,7 @@ import * as BankAccounts from '../BankAccounts'; * @param {Boolean} [params.isOnfidoSetupComplete] */ function updatePersonalInformationForBankAccount(params) { - API.write('UpdatePersonalInformationForBankAccount', params, BankAccounts.getVBBADataForOnyx()); + API.write('UpdatePersonalInformationForBankAccount', params, BankAccountUtils.getVBBADataForOnyx()); } export default updatePersonalInformationForBankAccount; diff --git a/src/libs/actions/ReimbursementAccount/vbaOnyxData.js b/src/libs/actions/ReimbursementAccount/vbaOnyxData.js new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/pages/ReimbursementAccount/RequestorStep.js b/src/pages/ReimbursementAccount/RequestorStep.js index 0f947beef32a..54a10dbb1753 100644 --- a/src/pages/ReimbursementAccount/RequestorStep.js +++ b/src/pages/ReimbursementAccount/RequestorStep.js @@ -139,7 +139,7 @@ class RequestorStep extends React.Component { dob: moment(this.state.dob).format(CONST.DATE.MOMENT_FORMAT_STRING), }; - BankAccounts.setupWithdrawalAccount(payload); + BankAccounts.updatePersonalInformationForBankAccount(payload); } render() { From 7fec9ac0c5f267f139174b982b58c8822a75eef8 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Wed, 14 Sep 2022 14:50:43 +0000 Subject: [PATCH 023/144] fix default payment method bug --- src/libs/actions/PaymentMethods.js | 30 +++++++++++++++---- .../settings/Payments/PaymentMethodList.js | 2 +- .../Payments/PaymentsPage/BasePaymentsPage.js | 13 ++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/libs/actions/PaymentMethods.js b/src/libs/actions/PaymentMethods.js index 1563d8309bc6..31f9e093516c 100644 --- a/src/libs/actions/PaymentMethods.js +++ b/src/libs/actions/PaymentMethods.js @@ -121,11 +121,11 @@ function openPaymentsPage() { * @param {String} password * @param {Number} bankAccountID * @param {Number} fundID - * @param {Number} previousPaymentMethodID - * @param {String} previousPaymentMethodType + * @param {Object} previousPaymentMethod + * @param {Object} currentPaymentMethod * */ -function makeDefaultPaymentMethod(password, bankAccountID, fundID, previousPaymentMethodID, previousPaymentMethodType) { +function makeDefaultPaymentMethod(password, bankAccountID, fundID, previousPaymentMethod, currentPaymentMethod) { API.write('MakeDefaultPaymentMethod', { password, bankAccountID, @@ -141,14 +141,34 @@ function makeDefaultPaymentMethod(password, bankAccountID, fundID, previousPayme errors: null, }, }, + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: previousPaymentMethod.accountType === CONST.PAYMENT_METHODS.BANK_ACCOUNT ? ONYXKEYS.BANK_ACCOUNT_LIST : ONYXKEYS.CARD_LIST, + value: { + [previousPaymentMethod.methodID]: { + ...previousPaymentMethod, + isDefault: false, + }, + }, + }, + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: currentPaymentMethod.accountType === CONST.PAYMENT_METHODS.BANK_ACCOUNT ? ONYXKEYS.BANK_ACCOUNT_LIST : ONYXKEYS.CARD_LIST, + value: { + [currentPaymentMethod.methodID]: { + ...currentPaymentMethod, + isDefault: true, + }, + }, + }, ], failureData: [ { onyxMethod: CONST.ONYX.METHOD.MERGE, key: ONYXKEYS.USER_WALLET, value: { - walletLinkedAccountID: previousPaymentMethodID, - walletLinkedAccountType: previousPaymentMethodType, + walletLinkedAccountID: previousPaymentMethod.methodID, + walletLinkedAccountType: previousPaymentMethod.accountType, }, }, ], diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 9fec802aa40b..97f801692aad 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -124,7 +124,7 @@ class PaymentMethodList extends Component { combinedPaymentMethods = _.map(combinedPaymentMethods, paymentMethod => ({ ...paymentMethod, type: MENU_ITEM, - onPress: e => this.props.onPress(e, paymentMethod.accountType, paymentMethod.accountData, paymentMethod.isDefault), + onPress: e => this.props.onPress(e, paymentMethod.accountType, paymentMethod.accountData, paymentMethod.isDefault, paymentMethod.methodID), iconFill: this.isPaymentMethodActive(paymentMethod) ? StyleUtils.getIconFillColor(CONST.BUTTON_STATES.PRESSED) : null, wrapperStyle: this.isPaymentMethodActive(paymentMethod) ? [StyleUtils.getButtonBackgroundColorStyle(CONST.BUTTON_STATES.PRESSED)] : null, })); diff --git a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js index 1290f751426b..7cd1aae46d96 100644 --- a/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js +++ b/src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js @@ -4,7 +4,6 @@ import { } from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import lodashGet from 'lodash/get'; import PaymentMethodList from '../PaymentMethodList'; import ROUTES from '../../../../ROUTES'; import HeaderWithCloseButton from '../../../../components/HeaderWithCloseButton'; @@ -51,6 +50,7 @@ class BasePaymentsPage extends React.Component { anchorPositionTop: 0, anchorPositionLeft: 0, addPaymentMethodButton: null, + methodID: null, }; this.paymentMethodPressed = this.paymentMethodPressed.bind(this); @@ -127,8 +127,9 @@ class BasePaymentsPage extends React.Component { * @param {String} accountType * @param {String} account * @param {Boolean} isDefault + * @param {String|Number} methodID */ - paymentMethodPressed(nativeEvent, accountType, account, isDefault) { + paymentMethodPressed(nativeEvent, accountType, account, isDefault, methodID) { const position = getClickedTargetLocation(nativeEvent.currentTarget); this.setState({ addPaymentMethodButton: nativeEvent.currentTarget, @@ -163,6 +164,7 @@ class BasePaymentsPage extends React.Component { selectedPaymentMethod: account, selectedPaymentMethodType: accountType, formattedSelectedPaymentMethod, + methodID, }); this.setPositionAddPaymentMenu(position); return; @@ -233,12 +235,11 @@ class BasePaymentsPage extends React.Component { ); const previousPaymentMethod = _.find(paymentMethods, method => method.isDefault); - const previousPaymentMethodID = lodashGet(previousPaymentMethod, 'methodID'); - const previousPaymentMethodType = lodashGet(previousPaymentMethod, 'accountType'); + const currentPaymentMethod = _.find(paymentMethods, method => method.methodID === this.state.methodID); if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.BANK_ACCOUNT) { - PaymentMethods.makeDefaultPaymentMethod(password, this.state.selectedPaymentMethod.bankAccountID, null, previousPaymentMethodID, previousPaymentMethodType); + PaymentMethods.makeDefaultPaymentMethod(password, this.state.selectedPaymentMethod.bankAccountID, null, previousPaymentMethod, currentPaymentMethod); } else if (this.state.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD) { - PaymentMethods.makeDefaultPaymentMethod(password, null, this.state.selectedPaymentMethod.fundID, previousPaymentMethodID, previousPaymentMethodType); + PaymentMethods.makeDefaultPaymentMethod(password, null, this.state.selectedPaymentMethod.fundID, previousPaymentMethod, currentPaymentMethod); } } From 1631f006641f683a32fe5f661fa58ab7efc2def4 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Wed, 14 Sep 2022 14:56:07 +0000 Subject: [PATCH 024/144] update paypal comments --- src/components/paypalMeDataPropTypes.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/paypalMeDataPropTypes.js b/src/components/paypalMeDataPropTypes.js index 5ec1c43d846c..5498186748a5 100644 --- a/src/components/paypalMeDataPropTypes.js +++ b/src/components/paypalMeDataPropTypes.js @@ -1,15 +1,15 @@ import PropTypes from 'prop-types'; export default PropTypes.shape({ - /** The name of the institution (bank of america, etc */ + /** This is always 'PayPal.me' */ title: PropTypes.string, - /** The masked bank account number */ - description: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + /** The paypalMe address */ + description: PropTypes.string, - /** The bankAccountID in the bankAccounts db */ - methodID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + /** This is always 'payPalMe' */ + methodID: PropTypes.string, - /** The bank account type */ + /** This is always 'payPalMe' */ accountType: PropTypes.string, }); From a437a91ff68127c5bb93139968f6cc89514cc079 Mon Sep 17 00:00:00 2001 From: madmax330 Date: Wed, 14 Sep 2022 16:08:49 +0100 Subject: [PATCH 025/144] lint --- src/libs/BankAccountUtils.js | 6 +++++- .../updatePersonalInformationForBankAccount.js | 2 +- src/libs/actions/ReimbursementAccount/vbaOnyxData.js | 0 3 files changed, 6 insertions(+), 2 deletions(-) delete mode 100644 src/libs/actions/ReimbursementAccount/vbaOnyxData.js diff --git a/src/libs/BankAccountUtils.js b/src/libs/BankAccountUtils.js index 249294de6093..10ec9b29f712 100644 --- a/src/libs/BankAccountUtils.js +++ b/src/libs/BankAccountUtils.js @@ -1,5 +1,7 @@ import CONST from '../CONST'; +import ONYXKEYS from '../ONYXKEYS'; import DateUtils from './DateUtils'; +import * as Localize from './Localize'; /** * Helper method to build the Onyx data required during setup of a Verified Business Bank Account @@ -44,4 +46,6 @@ function getVBBADataForOnyx() { }; } -export {getVBBADataForOnyx}; +export default { + getVBBADataForOnyx, +}; diff --git a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js index 8046b48db1f1..987c4334b94c 100644 --- a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js +++ b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js @@ -1,5 +1,5 @@ import * as API from '../../API'; -import * as BankAccountUtils from '../../BankAccountUtils'; +import BankAccountUtils from '../../BankAccountUtils'; /** * Update the user's personal information on the bank account in database. diff --git a/src/libs/actions/ReimbursementAccount/vbaOnyxData.js b/src/libs/actions/ReimbursementAccount/vbaOnyxData.js deleted file mode 100644 index e69de29bb2d1..000000000000 From 736575c071b2cde618fa3bae6c9dba0531c82eac Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 15 Sep 2022 09:34:22 +0000 Subject: [PATCH 026/144] rename onyx key --- src/ONYXKEYS.js | 2 +- src/components/AddPaymentMethodMenu.js | 2 +- src/libs/actions/User.js | 4 ++-- src/pages/settings/Payments/AddPayPalMePage.js | 2 +- src/pages/settings/Payments/PaymentMethodList.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index a484b7db52bc..9167df61f9ad 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -68,7 +68,7 @@ export default { NVP_PAYPAL_ME_ADDRESS: 'nvp_paypalMeAddress', // Contains the user's payPalMe data - NVP_PAYPAL: 'nvp_paypalMe', + PAYPAL: 'paypal', // Contains the user preference for the LHN priority mode NVP_PRIORITY_MODE: 'nvp_priorityMode', diff --git a/src/components/AddPaymentMethodMenu.js b/src/components/AddPaymentMethodMenu.js index fa8998866483..d86a83cf645a 100644 --- a/src/components/AddPaymentMethodMenu.js +++ b/src/components/AddPaymentMethodMenu.js @@ -74,7 +74,7 @@ export default compose( withLocalize, withOnyx({ payPalMeData: { - key: ONYXKEYS.NVP_PAYPAL, + key: ONYXKEYS.PAYPAL, }, betas: { key: ONYXKEYS.BETAS, diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 098987b0dd7a..aa0683f36fa2 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -274,7 +274,7 @@ function addPaypalMeAddress(address) { }, { onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.NVP_PAYPAL, + key: ONYXKEYS.PAYPAL, value: { title: 'PayPal.me', description: address, @@ -306,7 +306,7 @@ function deletePaypalMeAddress() { }, { onyxMethod: CONST.ONYX.METHOD.SET, - key: ONYXKEYS.NVP_PAYPAL, + key: ONYXKEYS.PAYPAL, value: {}, }, ]; diff --git a/src/pages/settings/Payments/AddPayPalMePage.js b/src/pages/settings/Payments/AddPayPalMePage.js index 6161d8c8b1a3..dc2e708af84b 100644 --- a/src/pages/settings/Payments/AddPayPalMePage.js +++ b/src/pages/settings/Payments/AddPayPalMePage.js @@ -109,7 +109,7 @@ export default compose( withLocalize, withOnyx({ payPalMeData: { - key: ONYXKEYS.NVP_PAYPAL, + key: ONYXKEYS.PAYPAL, }, }), )(AddPayPalMePage); diff --git a/src/pages/settings/Payments/PaymentMethodList.js b/src/pages/settings/Payments/PaymentMethodList.js index 97f801692aad..403d68c18cda 100644 --- a/src/pages/settings/Payments/PaymentMethodList.js +++ b/src/pages/settings/Payments/PaymentMethodList.js @@ -285,7 +285,7 @@ export default compose( key: ONYXKEYS.CARD_LIST, }, payPalMeData: { - key: ONYXKEYS.NVP_PAYPAL, + key: ONYXKEYS.PAYPAL, }, userWallet: { key: ONYXKEYS.USER_WALLET, From 68c85e102cb3cc08c03e192319d3b50fd5b00dd5 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Thu, 15 Sep 2022 14:17:08 +0000 Subject: [PATCH 027/144] skip bank account of type wallet --- src/libs/PaymentUtils.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/PaymentUtils.js b/src/libs/PaymentUtils.js index a28fcddfb5c4..204a6b1f94e2 100644 --- a/src/libs/PaymentUtils.js +++ b/src/libs/PaymentUtils.js @@ -34,6 +34,11 @@ function formatPaymentMethods(bankAccountList, cardList, payPalMeData = null) { const combinedPaymentMethods = []; _.each(bankAccountList, (bankAccount) => { + // Add all bank accounts besides the wallet + if (bankAccount.type === CONST.BANK_ACCOUNT_TYPES.WALLET) { + return; + } + const {icon, iconSize} = getBankIcon(lodashGet(bankAccount, 'accountData.additionalData.bankName', '')); combinedPaymentMethods.push({ ...bankAccount, From e385ace93761c5eb1b79f2e96b28f27280994030 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 15 Sep 2022 15:44:02 -0600 Subject: [PATCH 028/144] create updateCompanyInformationForBankAccount --- src/libs/actions/BankAccounts.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 7b52777e6e18..7f0b5f569e92 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -47,7 +47,6 @@ function clearPlaid() { * @returns {Object} */ // We'll remove the below once this function is used by the VBBA commands that are yet to be implemented -/* eslint-disable no-unused-vars */ function getVBBADataForOnyx() { return { optimisticData: [ @@ -192,10 +191,18 @@ function validateBankAccount(bankAccountID, validateCode) { }); } +function updateCompanyInformationForBankAccount() { + API.write('UpdateCompanyInformationForBankAccount', { + routingNumber: 'routingNumber', + }, + getVBBADataForOnyx()); +} + export { addPersonalBankAccount, deletePaymentBankAccount, clearPersonalBankAccount, clearPlaid, validateBankAccount, + updateCompanyInformationForBankAccount, }; From 3aaa093c94fad84f824a03c8558235b68997d3a7 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 15 Sep 2022 15:51:51 -0600 Subject: [PATCH 029/144] use updateCompanyInformationForBankAccount, add jsdocs --- src/libs/actions/BankAccounts.js | 24 +++++++++++++++---- src/pages/ReimbursementAccount/CompanyStep.js | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 7f0b5f569e92..31b5cc215790 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -191,11 +191,25 @@ function validateBankAccount(bankAccountID, validateCode) { }); } -function updateCompanyInformationForBankAccount() { - API.write('UpdateCompanyInformationForBankAccount', { - routingNumber: 'routingNumber', - }, - getVBBADataForOnyx()); +/** + * Updates the bank account in db with the company step data + * + * @param {Object} params + * @param {String} [params.companyName] + * @param {String} [params.addressStreet] + * @param {String} [params.addressCity] + * @param {String} [params.addressState] + * @param {String} [params.addressZipCode] + * @param {String} [params.companyPhone] + * @param {String} [params.website] + * @param {String} [params.companyTaxID] + * @param {String} [params.incorporationType] + * @param {String} [params.incorporationState] + * @param {String} [params.incorporationDate] + * @param {Boolean} [params.hasNoConnectionToCannabis] + */ +function updateCompanyInformationForBankAccount(params) { + API.write('UpdateCompanyInformationForBankAccount', params, getVBBADataForOnyx()); } export { diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index 21aa54fdf57d..8f45c6025568 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -177,7 +177,7 @@ class CompanyStep extends React.Component { } const incorporationDate = moment(this.state.incorporationDate).format(CONST.DATE.MOMENT_FORMAT_STRING); - BankAccounts.setupWithdrawalAccount({ + BankAccounts.updateCompanyInformationForBankAccount({ ...this.state, incorporationDate, companyTaxID: this.state.companyTaxID.replace(CONST.REGEX.NON_NUMERIC, ''), From 42bd32e1d4b089fb003367550050b1b99106acd4 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 15 Sep 2022 16:18:16 -0600 Subject: [PATCH 030/144] create mergeWithLocalACHData --- src/libs/actions/BankAccounts.js | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 31b5cc215790..356cbfc69443 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -1,4 +1,6 @@ import Onyx from 'react-native-onyx'; +import lodashGet from 'lodash/get'; +import _ from 'underscore'; import CONST from '../../CONST'; import * as API from '../API'; import ONYXKEYS from '../../ONYXKEYS'; @@ -41,6 +43,15 @@ function clearPlaid() { Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, ''); } +/** Reimbursement account actively being set up */ +let reimbursementAccountInSetup = {}; +Onyx.connect({ + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + callback: (val) => { + reimbursementAccountInSetup = lodashGet(val, 'achData', {}); + }, +}); + /** * Helper method to build the Onyx data required during setup of a Verified Business Bank Account * @@ -191,6 +202,33 @@ function validateBankAccount(bankAccountID, validateCode) { }); } +/** + * @param {Object} data + * @returns {Object} + */ +function mergeWithLocalACHData(data) { + const updatedACHData = { + ...reimbursementAccountInSetup, + ...data, + + // This param tells Web-Secure that this bank account is from NewDot so we can modify links back to the correct + // app in any communications. It also will be used to provision a customer for the Expensify card automatically + // once their bank account is successfully validated. + enableCardAfterVerified: true, + }; + + if (data && !_.isUndefined(data.isSavings)) { + updatedACHData.isSavings = Boolean(data.isSavings); + } + if (!updatedACHData.setupType) { + updatedACHData.setupType = updatedACHData.plaidAccountID + ? CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID + : CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL; + } + + return updatedACHData; +} + /** * Updates the bank account in db with the company step data * @@ -209,7 +247,8 @@ function validateBankAccount(bankAccountID, validateCode) { * @param {Boolean} [params.hasNoConnectionToCannabis] */ function updateCompanyInformationForBankAccount(params) { - API.write('UpdateCompanyInformationForBankAccount', params, getVBBADataForOnyx()); + const achData = mergeWithLocalACHData(params); + API.write('UpdateCompanyInformationForBankAccount', achData, getVBBADataForOnyx()); } export { From 761ef2150154276357dd7d7094ccdb48d47522b3 Mon Sep 17 00:00:00 2001 From: Chirag Chandrakant Salian Date: Thu, 15 Sep 2022 17:48:22 -0700 Subject: [PATCH 031/144] Update src/languages/es.js Co-authored-by: Ionatan Wiznia --- 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 87bc60f59c61..1b034506ca22 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -812,7 +812,7 @@ export default { removeMembersTitle: 'Eliminar miembros', selectAll: 'Seleccionar todo', error: { - genericAdd: '', + genericAdd: 'Ha ocurrido un problema al agregar el miembro al espacio de trabajo', cannotRemove: 'No puedes eliminarte ni a ti mismo ni al dueño del espacio de trabajo.', }, }, From e11e68286846bc1473a667a2f89e9f53b7e5a14b Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Thu, 15 Sep 2022 17:50:15 -0700 Subject: [PATCH 032/144] using const --- src/libs/actions/Policy.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 96c7a69a11d3..e7e14e730221 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -255,17 +255,17 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { const optimisticData = [ { - onyxMethod: 'merge', + onyxMethod: CONST.ONYX.METHOD.MERGE, key: membersListKey, // Convert to object with each key containing {pendingAction: ‘add’} - value: _.object(logins, Array(logins.length).fill({pendingAction: 'add'})), + value: _.object(logins, Array(logins.length).fill({pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD})), }, ]; const successData = [ { - onyxMethod: 'merge', + onyxMethod: CONST.ONYX.METHOD.MERGE, key: membersListKey, // Convert to object with each key clearing pendingAction. We don’t @@ -276,7 +276,7 @@ function addMembersToWorkspace(memberLogins, welcomeNote, policyID) { const failureData = [ { - onyxMethod: 'merge', + onyxMethod: CONST.ONYX.METHOD.MERGE, key: membersListKey, // Convert to object with each key containing the error. We don’t From be5e4d7031891c9844e75acaa26e4762dc53a7d6 Mon Sep 17 00:00:00 2001 From: madmax330 Date: Fri, 16 Sep 2022 11:56:59 +0100 Subject: [PATCH 033/144] fix requestor step --- src/libs/BankAccountUtils.js | 7 +++++++ .../updatePersonalInformationForBankAccount.js | 5 ++++- src/pages/ReimbursementAccount/RequestorStep.js | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libs/BankAccountUtils.js b/src/libs/BankAccountUtils.js index 10ec9b29f712..736f5e36d9ff 100644 --- a/src/libs/BankAccountUtils.js +++ b/src/libs/BankAccountUtils.js @@ -2,6 +2,7 @@ import CONST from '../CONST'; import ONYXKEYS from '../ONYXKEYS'; import DateUtils from './DateUtils'; import * as Localize from './Localize'; +import _ from 'underscore'; /** * Helper method to build the Onyx data required during setup of a Verified Business Bank Account @@ -46,6 +47,12 @@ function getVBBADataForOnyx() { }; } +function getOnfidoSDKTokenFromACHData(achData) { + const sdkToken = _.get(achData, ['verifications', 'externalApiResponses', 'requestorIdentityOnfido', 'apiResult', 'sdkToken']); + return sdkToken ? sdkToken : achData.sdkToken; +} + export default { getVBBADataForOnyx, + getOnfidoSDKTokenFromACHData, }; diff --git a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js index 987c4334b94c..e5878cf747fa 100644 --- a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js +++ b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js @@ -1,5 +1,6 @@ import * as API from '../../API'; import BankAccountUtils from '../../BankAccountUtils'; +import * as store from './store'; /** * Update the user's personal information on the bank account in database. @@ -22,7 +23,9 @@ import BankAccountUtils from '../../BankAccountUtils'; * @param {Boolean} [params.isOnfidoSetupComplete] */ function updatePersonalInformationForBankAccount(params) { - API.write('UpdatePersonalInformationForBankAccount', params, BankAccountUtils.getVBBADataForOnyx()); + const bankAccount = store.getReimbursementAccountInSetup(); + console.log(bankAccount); + API.write('UpdatePersonalInformationForBankAccount', {bankAccountID: bankAccount.bankAccountID, additionalData: JSON.stringify(params)}, BankAccountUtils.getVBBADataForOnyx()); } export default updatePersonalInformationForBankAccount; diff --git a/src/pages/ReimbursementAccount/RequestorStep.js b/src/pages/ReimbursementAccount/RequestorStep.js index 54a10dbb1753..f7baed373267 100644 --- a/src/pages/ReimbursementAccount/RequestorStep.js +++ b/src/pages/ReimbursementAccount/RequestorStep.js @@ -23,6 +23,7 @@ import Growl from '../../libs/Growl'; import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; import ReimbursementAccountForm from './ReimbursementAccountForm'; import * as Link from '../../libs/actions/Link'; +import BankAccountUtils from '../../libs/BankAccountUtils'; const propTypes = { /** Bank account currently in setup */ @@ -154,10 +155,10 @@ class RequestorStep extends React.Component { onBackButtonPress={() => BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY)} onCloseButtonPress={Navigation.dismissModal} /> - {this.props.achData.useOnfido && this.props.achData.sdkToken && !this.state.isOnfidoSetupComplete ? ( + {this.props.achData.useOnfido && BankAccountUtils.getOnfidoSDKTokenFromACHData(this.props.achData) && !this.state.isOnfidoSetupComplete ? ( { // We're taking the user back to the company step. They will need to come back to the requestor step to make the Onfido flow appear again. BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); From 9496c4fa71dc386404b3600295f52f1de4a3e30f Mon Sep 17 00:00:00 2001 From: madmax330 Date: Fri, 16 Sep 2022 12:07:28 +0100 Subject: [PATCH 034/144] style --- src/libs/BankAccountUtils.js | 12 +++++++++--- .../updatePersonalInformationForBankAccount.js | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libs/BankAccountUtils.js b/src/libs/BankAccountUtils.js index 736f5e36d9ff..3c13ec476ec2 100644 --- a/src/libs/BankAccountUtils.js +++ b/src/libs/BankAccountUtils.js @@ -1,8 +1,8 @@ +import _ from 'underscore'; import CONST from '../CONST'; import ONYXKEYS from '../ONYXKEYS'; import DateUtils from './DateUtils'; import * as Localize from './Localize'; -import _ from 'underscore'; /** * Helper method to build the Onyx data required during setup of a Verified Business Bank Account @@ -47,9 +47,15 @@ function getVBBADataForOnyx() { }; } +/** + * Helper method to get the onfido sdk token from the bank account's achdata + * + * @param {Object} achData + * @returns {string} + */ function getOnfidoSDKTokenFromACHData(achData) { - const sdkToken = _.get(achData, ['verifications', 'externalApiResponses', 'requestorIdentityOnfido', 'apiResult', 'sdkToken']); - return sdkToken ? sdkToken : achData.sdkToken; + const sdkToken = _.get(achData, ['verifications', 'externalApiResponses', 'requestorIdentityOnfido', 'apiResult', 'sdkToken'], ''); + return sdkToken || _.get(achData, ['sdkToken'], ''); } export default { diff --git a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js index e5878cf747fa..60eab4808a2b 100644 --- a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js +++ b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js @@ -24,7 +24,6 @@ import * as store from './store'; */ function updatePersonalInformationForBankAccount(params) { const bankAccount = store.getReimbursementAccountInSetup(); - console.log(bankAccount); API.write('UpdatePersonalInformationForBankAccount', {bankAccountID: bankAccount.bankAccountID, additionalData: JSON.stringify(params)}, BankAccountUtils.getVBBADataForOnyx()); } From 3cc4022906dd690d9913f352503ba177a0493dc7 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Fri, 16 Sep 2022 14:39:42 +0300 Subject: [PATCH 035/144] Desktop dev: watch and rebuild desktop/main.js --- desktop/start.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/desktop/start.js b/desktop/start.js index 79e62d7187ed..c744ee223c62 100644 --- a/desktop/start.js +++ b/desktop/start.js @@ -9,27 +9,33 @@ portfinder.getPortPromise({ port: basePort, }).then((port) => { const devServer = `webpack-dev-server --config config/webpack/webpack.dev.js --port ${port} --env platform=desktop`; - const buildMain = 'webpack --config config/webpack/webpack.desktop.js --config-name desktop-main --mode=development'; + const buildMain = 'webpack watch --config config/webpack/webpack.desktop.js --config-name desktop-main --mode=development'; const processes = [ + { + command: buildMain, + name: 'Main', + prefixColor: 'blue.dim', + }, { command: devServer, name: 'Renderer', prefixColor: 'red.dim', }, { - command: `${buildMain} && wait-port localhost:${port} && electron desktop/dist/main.js`, - name: 'Main', + command: `wait-port localhost:${port} && electron desktop/dist/main.js`, + name: 'Electron', prefixColor: 'cyan.dim', - env: { - PORT: port, - NODE_ENV: 'development', - }, }, ]; + concurrently(processes, { inputStream: process.stdin, prefix: 'name', + env: { + PORT: port, + NODE_ENV: 'development', + }, // Like Harry Potter and he-who-must-not-be-named, "neither can live while the other survives" killOthers: ['success', 'failure'], From 4cf7d0f30a4e81f8c4a76e7eb9f3d8cde60558ae Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Fri, 16 Sep 2022 15:14:03 +0300 Subject: [PATCH 036/144] Desktop DEV: reload electron process with electron-reload --- desktop/main.js | 13 ++ desktop/package-lock.json | 299 ++++++++++++++++++++++++++++++++++++++ desktop/package.json | 1 + 3 files changed, 313 insertions(+) diff --git a/desktop/main.js b/desktop/main.js index f7bd55411f4d..587152a95910 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -6,6 +6,7 @@ const { shell, ipcMain, } = require('electron'); +const path = require('path'); const _ = require('underscore'); const serve = require('electron-serve'); const contextMenu = require('electron-context-menu'); @@ -17,6 +18,18 @@ const CONFIG = require('../src/CONFIG').default; const port = process.env.PORT || 8080; +// Setup electron process restart on main code change (only applicable to DEV) +if (__DEV__) { + const electronReload = require('electron-reload'); + + // __dirname refers to src/desktop/dist + electronReload(path.join(__dirname, '*.js'), { + electron: path.join(__dirname, '../../node_modules', '.bin', 'electron'), + electronArgv: ['desktop/dist/main.js'], + forceHardReset: true, + }); +} + app.setName('New Expensify'); /** diff --git a/desktop/package-lock.json b/desktop/package-lock.json index df18cde3a3d1..42e748294353 100644 --- a/desktop/package-lock.json +++ b/desktop/package-lock.json @@ -9,6 +9,7 @@ "dependencies": { "electron-context-menu": "^2.3.0", "electron-log": "^4.4.7", + "electron-reload": "^2.0.0-alpha.1", "electron-serve": "^1.0.0", "electron-updater": "^4.3.4" } @@ -40,6 +41,18 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -53,6 +66,25 @@ "node": ">=8" } }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/builder-util-runtime": { "version": "8.9.2", "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz", @@ -65,6 +97,32 @@ "node": ">=12.0.0" } }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/cli-truncate": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", @@ -148,6 +206,14 @@ "resolved": "https://registry.npmjs.org/electron-log/-/electron-log-4.4.7.tgz", "integrity": "sha512-uFZQdgevOp9Fn5lDOrJMU/bmmYxDLZitbIHJM7VXN+cpB59ZnPt1FQL4bOf/Dl2gaIMPYJEfXx38GvJma5iV6A==" }, + "node_modules/electron-reload": { + "version": "2.0.0-alpha.1", + "resolved": "https://registry.npmjs.org/electron-reload/-/electron-reload-2.0.0-alpha.1.tgz", + "integrity": "sha512-hTde7gv0TEqxbxlB3pj2CwoyCQ9sdiQrcP8GkpzhosxyVeYM3mZbMEVKCZK3L0fED7Mz5A9IWmK7zEvi4H3P1g==", + "dependencies": { + "chokidar": "^3.5.2" + } + }, "node_modules/electron-serve": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/electron-serve/-/electron-serve-1.1.0.tgz", @@ -204,6 +270,17 @@ "node": ">=4" } }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/fs-extra": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", @@ -217,11 +294,54 @@ "node": ">=12" } }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/graceful-fs": { "version": "4.2.9", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -230,6 +350,25 @@ "node": ">=8" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -307,6 +446,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -315,6 +462,17 @@ "node": ">=8" } }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/pupa": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz", @@ -326,6 +484,17 @@ "node": ">=8" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", @@ -404,6 +573,17 @@ "node": ">=8" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", @@ -449,6 +629,15 @@ "color-convert": "^2.0.1" } }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -459,6 +648,19 @@ "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==" }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, "builder-util-runtime": { "version": "8.9.2", "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.9.2.tgz", @@ -468,6 +670,21 @@ "sax": "^1.2.4" } }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, "cli-truncate": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", @@ -528,6 +745,14 @@ "resolved": "https://registry.npmjs.org/electron-log/-/electron-log-4.4.7.tgz", "integrity": "sha512-uFZQdgevOp9Fn5lDOrJMU/bmmYxDLZitbIHJM7VXN+cpB59ZnPt1FQL4bOf/Dl2gaIMPYJEfXx38GvJma5iV6A==" }, + "electron-reload": { + "version": "2.0.0-alpha.1", + "resolved": "https://registry.npmjs.org/electron-reload/-/electron-reload-2.0.0-alpha.1.tgz", + "integrity": "sha512-hTde7gv0TEqxbxlB3pj2CwoyCQ9sdiQrcP8GkpzhosxyVeYM3mZbMEVKCZK3L0fED7Mz5A9IWmK7zEvi4H3P1g==", + "requires": { + "chokidar": "^3.5.2" + } + }, "electron-serve": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/electron-serve/-/electron-serve-1.1.0.tgz", @@ -575,6 +800,14 @@ "sort-keys-length": "^1.0.0" } }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, "fs-extra": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz", @@ -585,16 +818,56 @@ "universalify": "^2.0.0" } }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, "graceful-fs": { "version": "4.2.9", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -655,11 +928,21 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, "pupa": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz", @@ -668,6 +951,14 @@ "escape-goat": "^2.0.0" } }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", @@ -725,6 +1016,14 @@ "ansi-regex": "^5.0.1" } }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, "universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", diff --git a/desktop/package.json b/desktop/package.json index a31d0db4e5bd..5fdd1be3cedb 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -6,6 +6,7 @@ "dependencies": { "electron-context-menu": "^2.3.0", "electron-log": "^4.4.7", + "electron-reload": "^2.0.0-alpha.1", "electron-serve": "^1.0.0", "electron-updater": "^4.3.4" }, From 3dd6c3ab26db5b187d8b9bb97cfbc94e6dcb6338 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Fri, 16 Sep 2022 15:15:07 +0300 Subject: [PATCH 037/144] package.json: remove `electron-reloader` - unused --- package-lock.json | 203 +--------------------------------------------- package.json | 1 - 2 files changed, 2 insertions(+), 202 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50f91287d1fd..a9a8d069ac03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -130,7 +130,6 @@ "electron": "^17.4.11", "electron-builder": "23.3.1", "electron-notarize": "^1.2.1", - "electron-reloader": "^1.2.1", "eslint": "^7.6.0", "eslint-config-expensify": "2.0.30", "eslint-loader": "^4.0.2", @@ -161,8 +160,8 @@ "webpack-merge": "^5.8.0" }, "engines": { - "node": "16.15.1", - "npm": "8.11.0" + "node": ">=16.15.1", + "npm": ">=8.11.0" } }, "node_modules/@actions/core": { @@ -18974,18 +18973,6 @@ "url": "https://opencollective.com/date-fns" } }, - "node_modules/date-time": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", - "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", - "dev": true, - "dependencies": { - "time-zone": "^1.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/dayjs": { "version": "1.11.5", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz", @@ -19961,12 +19948,6 @@ "node": ">=12" } }, - "node_modules/electron-is-dev": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz", - "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw==", - "dev": true - }, "node_modules/electron-notarize": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.2.1.tgz", @@ -20127,92 +20108,6 @@ "node": ">=8" } }, - "node_modules/electron-reloader": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/electron-reloader/-/electron-reloader-1.2.3.tgz", - "integrity": "sha512-aDnACAzNg0QvQhzw7LYOx/nVS10mEtbuG6M0QQvNQcLnJEwFs6is+EGRCnM+KQlQ4KcTbdwnt07nd7ZjHpY4iw==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "chokidar": "^3.5.0", - "date-time": "^3.1.0", - "electron-is-dev": "^1.2.0", - "find-up": "^5.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/electron-reloader/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/electron-reloader/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/electron-reloader/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/electron-reloader/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/electron-reloader/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/electron-reloader/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/electron-to-chromium": { "version": "1.4.223", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.223.tgz", @@ -39130,15 +39025,6 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "dev": true }, - "node_modules/time-zone": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", - "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/timers-browserify": { "version": "2.0.12", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.12.tgz", @@ -56505,15 +56391,6 @@ "integrity": "sha512-dlLD5rKaKxpFdnjrs+5azHDFOPEu4ANy/LTh04A1DTzMM7qoajmKCBc8pkKRFT41CNzw+4gQh79X5C+Jq27HAw==", "dev": true }, - "date-time": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/date-time/-/date-time-3.1.0.tgz", - "integrity": "sha512-uqCUKXE5q1PNBXjPqvwhwJf9SwMoAHBgWJ6DcrnS5o+W2JOiIILl0JEdVD8SGujrNS02GGxgwAg2PN2zONgtjg==", - "dev": true, - "requires": { - "time-zone": "^1.0.0" - } - }, "dayjs": { "version": "1.11.5", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.5.tgz", @@ -57293,12 +57170,6 @@ } } }, - "electron-is-dev": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz", - "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw==", - "dev": true - }, "electron-notarize": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/electron-notarize/-/electron-notarize-1.2.1.tgz", @@ -57426,70 +57297,6 @@ } } }, - "electron-reloader": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/electron-reloader/-/electron-reloader-1.2.3.tgz", - "integrity": "sha512-aDnACAzNg0QvQhzw7LYOx/nVS10mEtbuG6M0QQvNQcLnJEwFs6is+EGRCnM+KQlQ4KcTbdwnt07nd7ZjHpY4iw==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "chokidar": "^3.5.0", - "date-time": "^3.1.0", - "electron-is-dev": "^1.2.0", - "find-up": "^5.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "electron-to-chromium": { "version": "1.4.223", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.223.tgz", @@ -72058,12 +71865,6 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "dev": true }, - "time-zone": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/time-zone/-/time-zone-1.0.0.tgz", - "integrity": "sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA==", - "dev": true - }, "timers-browserify": { "version": "2.0.12", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.12.tgz", diff --git a/package.json b/package.json index fb1a983ae489..1a43a78e122f 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,6 @@ "electron": "^17.4.11", "electron-builder": "23.3.1", "electron-notarize": "^1.2.1", - "electron-reloader": "^1.2.1", "eslint": "^7.6.0", "eslint-config-expensify": "2.0.30", "eslint-loader": "^4.0.2", From d1c41546cc1759a03f6da39008bd5f543b5a6cfd Mon Sep 17 00:00:00 2001 From: Mohammad Luthfi Fathur Rahman Date: Fri, 16 Sep 2022 22:34:52 +0700 Subject: [PATCH 038/144] fix emoji picker hover out set highlighted index --- src/components/EmojiPicker/EmojiPickerMenu/index.js | 1 + src/components/EmojiPicker/EmojiPickerMenuItem.js | 8 ++++++-- src/components/EmojiPicker/EmojiSkinToneList.js | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/EmojiPicker/EmojiPickerMenu/index.js b/src/components/EmojiPicker/EmojiPickerMenu/index.js index 470f570603f3..0a4cb5c97765 100755 --- a/src/components/EmojiPicker/EmojiPickerMenu/index.js +++ b/src/components/EmojiPicker/EmojiPickerMenu/index.js @@ -440,6 +440,7 @@ class EmojiPickerMenu extends Component { this.addToFrequentAndSelectEmoji(emoji, item)} onHover={() => this.setState({highlightedIndex: index})} + onHoverOut={() => this.setState({highlightedIndex: -1})} emoji={emojiCode} isHighlighted={index === this.state.highlightedIndex} /> diff --git a/src/components/EmojiPicker/EmojiPickerMenuItem.js b/src/components/EmojiPicker/EmojiPickerMenuItem.js index ee24d689f87d..f52bdc8f3a1a 100644 --- a/src/components/EmojiPicker/EmojiPickerMenuItem.js +++ b/src/components/EmojiPicker/EmojiPickerMenuItem.js @@ -17,6 +17,9 @@ const propTypes = { /** Handles what to do when we hover over this item with our cursor */ onHover: PropTypes.func, + /** Handles what to do when the hover is out */ + onHoverOut: PropTypes.func, + /** Whether this menu item is currently highlighted or not */ isHighlighted: PropTypes.bool, }; @@ -27,13 +30,13 @@ const EmojiPickerMenuItem = props => ( style={({ pressed, }) => ([ - styles.pv1, + styles.p1, StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), props.isHighlighted ? styles.emojiItemHighlighted : {}, styles.emojiItem, ])} > - + {props.emoji} @@ -46,6 +49,7 @@ EmojiPickerMenuItem.displayName = 'EmojiPickerMenuItem'; EmojiPickerMenuItem.defaultProps = { isHighlighted: false, onHover: () => {}, + onHoverOut: () => {}, }; // Significantly speeds up re-renders of the EmojiPickerMenu's FlatList diff --git a/src/components/EmojiPicker/EmojiSkinToneList.js b/src/components/EmojiPicker/EmojiSkinToneList.js index 45dc28755592..0b9389a47fc9 100644 --- a/src/components/EmojiPicker/EmojiSkinToneList.js +++ b/src/components/EmojiPicker/EmojiSkinToneList.js @@ -85,6 +85,7 @@ class EmojiSkinToneList extends Component { this.updateSelectedSkinTone(skinToneEmoji)} onHover={() => this.setState({highlightedIndex: skinToneEmoji.skinTone})} + onHoverOut={() => this.setState({highlightedIndex: -1})} key={skinToneEmoji.code} emoji={skinToneEmoji.code} isHighlighted={skinToneEmoji.skinTone === this.state.highlightedIndex} From 8ad8e921e25e4b0598b2621b8e2f1f1ee8c7d683 Mon Sep 17 00:00:00 2001 From: Mohammad Luthfi Fathur Rahman Date: Fri, 16 Sep 2022 22:36:23 +0700 Subject: [PATCH 039/144] rename onHover to onHoverIn --- src/components/EmojiPicker/EmojiPickerMenu/index.js | 2 +- src/components/EmojiPicker/EmojiPickerMenuItem.js | 6 +++--- src/components/EmojiPicker/EmojiSkinToneList.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/EmojiPicker/EmojiPickerMenu/index.js b/src/components/EmojiPicker/EmojiPickerMenu/index.js index 0a4cb5c97765..a6d011af2e91 100755 --- a/src/components/EmojiPicker/EmojiPickerMenu/index.js +++ b/src/components/EmojiPicker/EmojiPickerMenu/index.js @@ -439,7 +439,7 @@ class EmojiPickerMenu extends Component { return ( this.addToFrequentAndSelectEmoji(emoji, item)} - onHover={() => this.setState({highlightedIndex: index})} + onHoverIn={() => this.setState({highlightedIndex: index})} onHoverOut={() => this.setState({highlightedIndex: -1})} emoji={emojiCode} isHighlighted={index === this.state.highlightedIndex} diff --git a/src/components/EmojiPicker/EmojiPickerMenuItem.js b/src/components/EmojiPicker/EmojiPickerMenuItem.js index f52bdc8f3a1a..baa9d9fdf2f5 100644 --- a/src/components/EmojiPicker/EmojiPickerMenuItem.js +++ b/src/components/EmojiPicker/EmojiPickerMenuItem.js @@ -15,7 +15,7 @@ const propTypes = { onPress: PropTypes.func.isRequired, /** Handles what to do when we hover over this item with our cursor */ - onHover: PropTypes.func, + onHoverIn: PropTypes.func, /** Handles what to do when the hover is out */ onHoverOut: PropTypes.func, @@ -36,7 +36,7 @@ const EmojiPickerMenuItem = props => ( styles.emojiItem, ])} > - + {props.emoji} @@ -48,7 +48,7 @@ EmojiPickerMenuItem.propTypes = propTypes; EmojiPickerMenuItem.displayName = 'EmojiPickerMenuItem'; EmojiPickerMenuItem.defaultProps = { isHighlighted: false, - onHover: () => {}, + onHoverIn: () => {}, onHoverOut: () => {}, }; diff --git a/src/components/EmojiPicker/EmojiSkinToneList.js b/src/components/EmojiPicker/EmojiSkinToneList.js index 0b9389a47fc9..d8efbcc0ec21 100644 --- a/src/components/EmojiPicker/EmojiSkinToneList.js +++ b/src/components/EmojiPicker/EmojiSkinToneList.js @@ -84,7 +84,7 @@ class EmojiSkinToneList extends Component { _.map(Emojis.skinTones, skinToneEmoji => ( this.updateSelectedSkinTone(skinToneEmoji)} - onHover={() => this.setState({highlightedIndex: skinToneEmoji.skinTone})} + onHoverIn={() => this.setState({highlightedIndex: skinToneEmoji.skinTone})} onHoverOut={() => this.setState({highlightedIndex: -1})} key={skinToneEmoji.code} emoji={skinToneEmoji.code} From 3dfe15421773e30429c2353289d7ef5fddb29fee Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 16 Sep 2022 13:47:45 -0600 Subject: [PATCH 040/144] rm const --- src/libs/actions/BankAccounts.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 356cbfc69443..faaa2c08ae72 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -247,8 +247,11 @@ function mergeWithLocalACHData(data) { * @param {Boolean} [params.hasNoConnectionToCannabis] */ function updateCompanyInformationForBankAccount(params) { - const achData = mergeWithLocalACHData(params); - API.write('UpdateCompanyInformationForBankAccount', achData, getVBBADataForOnyx()); + API.write( + 'UpdateCompanyInformationForBankAccount', + mergeWithLocalACHData(params), + getVBBADataForOnyx(), + ); } export { From 116ce8369f4a17955320ac74e144f271efd6c5b9 Mon Sep 17 00:00:00 2001 From: madmax330 Date: Tue, 20 Sep 2022 11:30:00 +0100 Subject: [PATCH 041/144] Remove extra files --- src/libs/BankAccountUtils.js | 64 ------------------- ...updatePersonalInformationForBankAccount.js | 30 --------- .../ReimbursementAccountForm.js | 7 +- 3 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 src/libs/BankAccountUtils.js delete mode 100644 src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js diff --git a/src/libs/BankAccountUtils.js b/src/libs/BankAccountUtils.js deleted file mode 100644 index 3c13ec476ec2..000000000000 --- a/src/libs/BankAccountUtils.js +++ /dev/null @@ -1,64 +0,0 @@ -import _ from 'underscore'; -import CONST from '../CONST'; -import ONYXKEYS from '../ONYXKEYS'; -import DateUtils from './DateUtils'; -import * as Localize from './Localize'; - -/** - * Helper method to build the Onyx data required during setup of a Verified Business Bank Account - * - * @returns {Object} - */ -// We'll remove the below once this function is used by the VBBA commands that are yet to be implemented -function getVBBADataForOnyx() { - return { - optimisticData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: { - isLoading: true, - errors: null, - }, - }, - ], - successData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: { - isLoading: false, - errors: null, - }, - }, - ], - failureData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: { - isLoading: false, - errors: { - [DateUtils.getMicroseconds()]: Localize.translateLocal('paymentsPage.addBankAccountFailure'), - }, - }, - }, - ], - }; -} - -/** - * Helper method to get the onfido sdk token from the bank account's achdata - * - * @param {Object} achData - * @returns {string} - */ -function getOnfidoSDKTokenFromACHData(achData) { - const sdkToken = _.get(achData, ['verifications', 'externalApiResponses', 'requestorIdentityOnfido', 'apiResult', 'sdkToken'], ''); - return sdkToken || _.get(achData, ['sdkToken'], ''); -} - -export default { - getVBBADataForOnyx, - getOnfidoSDKTokenFromACHData, -}; diff --git a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js b/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js deleted file mode 100644 index 60eab4808a2b..000000000000 --- a/src/libs/actions/ReimbursementAccount/updatePersonalInformationForBankAccount.js +++ /dev/null @@ -1,30 +0,0 @@ -import * as API from '../../API'; -import BankAccountUtils from '../../BankAccountUtils'; -import * as store from './store'; - -/** -* Update the user's personal information on the bank account in database. -* -* This action is called by the requestor step in the Verified Bank Account flow -* -* @param {Object} params -* -* // RequestorStep -* @param {String} [params.dob] -* @param {String} [params.firstName] -* @param {String} [params.lastName] -* @param {String} [params.requestorAddressStreet] -* @param {String} [params.requestorAddressCity] -* @param {String} [params.requestorAddressState] -* @param {String} [params.requestorAddressZipCode] -* @param {String} [params.ssnLast4] -* @param {String} [params.isControllingOfficer] -* @param {Object} [params.onfidoData] -* @param {Boolean} [params.isOnfidoSetupComplete] -*/ -function updatePersonalInformationForBankAccount(params) { - const bankAccount = store.getReimbursementAccountInSetup(); - API.write('UpdatePersonalInformationForBankAccount', {bankAccountID: bankAccount.bankAccountID, additionalData: JSON.stringify(params)}, BankAccountUtils.getVBBADataForOnyx()); -} - -export default updatePersonalInformationForBankAccount; diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountForm.js b/src/pages/ReimbursementAccount/ReimbursementAccountForm.js index 4969ccd77c45..93eb0e53485d 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountForm.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountForm.js @@ -34,8 +34,9 @@ class ReimbursementAccountForm extends React.Component { } render() { - const isErrorVisible = _.size(lodashGet(this.props, 'reimbursementAccount.errors', {})) > 0 - || lodashGet(this.props, 'reimbursementAccount.error', '').length > 0; + const hasErrorFields = _.size(this.props.reimbursementAccount.errorFields) > 0; + const error = _.last(_.values(this.props.reimbursementAccount.errors)); + const isErrorVisible = hasErrorFields || Boolean(error); const currentStep = lodashGet( this.props, @@ -58,7 +59,7 @@ class ReimbursementAccountForm extends React.Component { onFixTheErrorsLinkPressed={() => { this.form.scrollTo({y: 0, animated: true}); }} - message={this.props.reimbursementAccount.error} + message={error} isMessageHtml={this.props.reimbursementAccount.isErrorHtml} isLoading={this.props.reimbursementAccount.loading} /> From a3f67bba0877fd04bdf834ceab8e2b4b0b7f2148 Mon Sep 17 00:00:00 2001 From: madmax330 Date: Tue, 20 Sep 2022 11:32:07 +0100 Subject: [PATCH 042/144] other cleanup --- src/libs/ReimbursementAccountUtils.js | 13 ++++ src/libs/actions/BankAccounts.js | 72 ++++++++++++++++++- .../ReimbursementAccount/RequestorStep.js | 5 +- 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/src/libs/ReimbursementAccountUtils.js b/src/libs/ReimbursementAccountUtils.js index 67bdae4b6f92..16106254aa44 100644 --- a/src/libs/ReimbursementAccountUtils.js +++ b/src/libs/ReimbursementAccountUtils.js @@ -1,3 +1,4 @@ +import _ from 'underscore'; import lodashGet from 'lodash/get'; import * as BankAccounts from './actions/BankAccounts'; import FormHelper from './FormHelper'; @@ -36,10 +37,22 @@ function getErrorText(props, errorTranslationKeys, inputKey) { return errors[inputKey] ? props.translate(errorTranslationKeys[inputKey]) : ''; } +/** + * Helper method to get the onfido sdk token from the bank account's achdata + * + * @param {Object} achData + * @returns {string} + */ +function getOnfidoSDKTokenFromACHData(achData) { + const sdkToken = _.get(achData, ['verifications', 'externalApiResponses', 'requestorIdentityOnfido', 'apiResult', 'sdkToken'], ''); + return sdkToken || _.get(achData, ['sdkToken'], ''); +} + export { getDefaultStateForField, getErrors, clearError, clearErrors, getErrorText, + getOnfidoSDKTokenFromACHData, }; diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index e6de6402c1e8..d7bdcc5ba910 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -3,10 +3,11 @@ import CONST from '../../CONST'; import * as API from '../API'; import ONYXKEYS from '../../ONYXKEYS'; import * as Localize from '../Localize'; +import DateUtils from '../DateUtils'; +import * as store from './ReimbursementAccount/store'; export { setupWithdrawalAccount, - updatePersonalInformationForBankAccount, fetchFreePlanVerifiedBankAccount, goToWithdrawalAccountSetupStep, showBankAccountErrorModal, @@ -42,6 +43,49 @@ function clearPlaid() { Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, ''); } +/** + * Helper method to build the Onyx data required during setup of a Verified Business Bank Account + * + * @returns {Object} + */ +// We'll remove the below once this function is used by the VBBA commands that are yet to be implemented +function getVBBADataForOnyx() { + return { + optimisticData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: true, + errors: null, + }, + }, + ], + successData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + errors: null, + }, + }, + ], + failureData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + errors: { + [DateUtils.getMicroseconds()]: Localize.translateLocal('paymentsPage.addBankAccountFailure'), + }, + }, + }, + ], + }; +} + /** * Adds a bank account via Plaid * @@ -115,9 +159,35 @@ function deletePaymentBankAccount(bankAccountID) { }); } +/** +* Update the user's personal information on the bank account in database. +* +* This action is called by the requestor step in the Verified Bank Account flow +* +* @param {Object} params +* +* // RequestorStep +* @param {String} [params.dob] +* @param {String} [params.firstName] +* @param {String} [params.lastName] +* @param {String} [params.requestorAddressStreet] +* @param {String} [params.requestorAddressCity] +* @param {String} [params.requestorAddressState] +* @param {String} [params.requestorAddressZipCode] +* @param {String} [params.ssnLast4] +* @param {String} [params.isControllingOfficer] +* @param {Object} [params.onfidoData] +* @param {Boolean} [params.isOnfidoSetupComplete] +*/ +function updatePersonalInformationForBankAccount(params) { + const bankAccount = store.getReimbursementAccountInSetup(); + API.write('UpdatePersonalInformationForBankAccount', {bankAccountID: bankAccount.bankAccountID, ...params}, getVBBADataForOnyx()); +} + export { addPersonalBankAccount, deletePaymentBankAccount, clearPersonalBankAccount, clearPlaid, + updatePersonalInformationForBankAccount, }; diff --git a/src/pages/ReimbursementAccount/RequestorStep.js b/src/pages/ReimbursementAccount/RequestorStep.js index f7baed373267..ef3db97fb394 100644 --- a/src/pages/ReimbursementAccount/RequestorStep.js +++ b/src/pages/ReimbursementAccount/RequestorStep.js @@ -23,7 +23,6 @@ import Growl from '../../libs/Growl'; import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; import ReimbursementAccountForm from './ReimbursementAccountForm'; import * as Link from '../../libs/actions/Link'; -import BankAccountUtils from '../../libs/BankAccountUtils'; const propTypes = { /** Bank account currently in setup */ @@ -155,10 +154,10 @@ class RequestorStep extends React.Component { onBackButtonPress={() => BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY)} onCloseButtonPress={Navigation.dismissModal} /> - {this.props.achData.useOnfido && BankAccountUtils.getOnfidoSDKTokenFromACHData(this.props.achData) && !this.state.isOnfidoSetupComplete ? ( + {this.props.achData.useOnfido && ReimbursementAccountUtils.getOnfidoSDKTokenFromACHData(this.props.achData) && !this.state.isOnfidoSetupComplete ? ( { // We're taking the user back to the company step. They will need to come back to the requestor step to make the Onfido flow appear again. BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); From 41e6911eaa060197a77d7e4e63af09bef1bb70d6 Mon Sep 17 00:00:00 2001 From: madmax330 Date: Tue, 20 Sep 2022 11:48:48 +0100 Subject: [PATCH 043/144] Style --- src/libs/actions/ReimbursementAccount/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/actions/ReimbursementAccount/index.js b/src/libs/actions/ReimbursementAccount/index.js index 39c0256b0470..40481a15a06a 100644 --- a/src/libs/actions/ReimbursementAccount/index.js +++ b/src/libs/actions/ReimbursementAccount/index.js @@ -5,7 +5,6 @@ import setupWithdrawalAccount from './setupWithdrawalAccount'; import fetchFreePlanVerifiedBankAccount from './fetchFreePlanVerifiedBankAccount'; import resetFreePlanBankAccount from './resetFreePlanBankAccount'; import deleteFromBankAccountList from './deleteFromBankAccountList'; -import updatePersonalInformationForBankAccount from './updatePersonalInformationForBankAccount'; export {goToWithdrawalAccountSetupStep, navigateToBankAccountRoute} from './navigation'; export { @@ -66,5 +65,4 @@ export { requestResetFreePlanBankAccount, cancelResetFreePlanBankAccount, deleteFromBankAccountList, - updatePersonalInformationForBankAccount, }; From f8fadfcda92a3b8478f432ed497052b598f1ffa4 Mon Sep 17 00:00:00 2001 From: chiragsalian Date: Tue, 20 Sep 2022 11:49:35 -0700 Subject: [PATCH 044/144] enabledWhenOffline prop --- src/components/FormAlertWithSubmitButton.js | 12 +++++++++--- src/pages/workspace/WorkspaceInvitePage.js | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/FormAlertWithSubmitButton.js b/src/components/FormAlertWithSubmitButton.js index ca1e86d817ea..5aff947889ea 100644 --- a/src/components/FormAlertWithSubmitButton.js +++ b/src/components/FormAlertWithSubmitButton.js @@ -32,6 +32,9 @@ const propTypes = { /** Submit function */ onSubmit: PropTypes.func.isRequired, + + /** Should the button be enabled when offline */ + enabledWhenOffline: PropTypes.bool, }; const defaultProps = { @@ -41,6 +44,7 @@ const defaultProps = { containerStyles: [], isLoading: false, onFixTheErrorsPressed: () => {}, + enabledWhenOffline: false, }; const FormAlertWithSubmitButton = props => ( @@ -51,12 +55,14 @@ const FormAlertWithSubmitButton = props => ( message={props.message} onFixTheErrorsPressed={props.onFixTheErrorsPressed} > - {isOffline => (isOffline ? ( + {isOffline => ((isOffline && !props.enabledWhenOffline) ? (