Skip to content

Commit bc0548a

Browse files
committed
fix: resolve conflict
1 parent 017d70c commit bc0548a

File tree

1 file changed

+0
-118
lines changed

1 file changed

+0
-118
lines changed

src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

-118
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,16 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
1616
import useThemeStyles from '@hooks/useThemeStyles';
1717
import useWindowDimensions from '@hooks/useWindowDimensions';
1818
import getClickedTargetLocation from '@libs/getClickedTargetLocation';
19-
<<<<<<< HEAD
2019
import * as PaymentUtils from '@libs/PaymentUtils';
2120
import PaymentMethodList from '@pages/settings/Wallet/PaymentMethodList';
22-
=======
23-
import Navigation from '@libs/Navigation/Navigation';
24-
import * as PaymentUtils from '@libs/PaymentUtils';
25-
import PaymentMethodList from '@pages/settings/Wallet/PaymentMethodList';
26-
import type {FormattedSelectedPaymentMethodIcon} from '@pages/settings/Wallet/WalletPage/types';
27-
>>>>>>> be90481835 (integrate bank accounts logic)
2821
import variables from '@styles/variables';
2922
import * as BankAccounts from '@userActions/BankAccounts';
3023
import * as PaymentMethods from '@userActions/PaymentMethods';
3124
import CONST from '@src/CONST';
3225
import ONYXKEYS from '@src/ONYXKEYS';
33-
<<<<<<< HEAD
34-
import type {AccountData} from '@src/types/onyx';
35-
import {isEmptyObject} from '@src/types/utils/EmptyObject';
36-
=======
37-
import ROUTES from '@src/ROUTES';
3826
import type {AccountData} from '@src/types/onyx';
3927
import {isEmptyObject} from '@src/types/utils/EmptyObject';
4028

41-
type FormattedSelectedPaymentMethod = {
42-
title: string;
43-
icon?: FormattedSelectedPaymentMethodIcon;
44-
description?: string;
45-
type?: string;
46-
};
47-
48-
type PaymentMethodState = {
49-
isSelectedPaymentMethodDefault: boolean;
50-
selectedPaymentMethod: AccountData;
51-
formattedSelectedPaymentMethod: FormattedSelectedPaymentMethod;
52-
methodID: string | number;
53-
selectedPaymentMethodType: string;
54-
};
55-
>>>>>>> be90481835 (integrate bank accounts logic)
56-
5729
type WorkspaceInvoiceVBASectionProps = {
5830
/** The policy ID currently being configured */
5931
policyID: string;
@@ -66,54 +38,24 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
6638
const {translate} = useLocalize();
6739
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
6840
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
69-
<<<<<<< HEAD
7041
const {paymentMethod, setPaymentMethod, resetSelectedPaymentMethodData} = usePaymentMethodState();
71-
=======
72-
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
73-
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET);
74-
const [fundList] = useOnyx(ONYXKEYS.FUND_LIST);
75-
>>>>>>> be90481835 (integrate bank accounts logic)
7642
const addPaymentMethodAnchorRef = useRef(null);
7743
const paymentMethodButtonRef = useRef<HTMLDivElement | null>(null);
7844
const [shouldShowAddPaymentMenu, setShouldShowAddPaymentMenu] = useState(false);
7945
const [showConfirmDeleteModal, setShowConfirmDeleteModal] = useState(false);
8046
const [shouldShowDefaultDeleteMenu, setShouldShowDefaultDeleteMenu] = useState(false);
81-
<<<<<<< HEAD
82-
=======
83-
const [paymentMethod, setPaymentMethod] = useState<PaymentMethodState>({
84-
isSelectedPaymentMethodDefault: false,
85-
selectedPaymentMethod: {},
86-
formattedSelectedPaymentMethod: {
87-
title: '',
88-
},
89-
methodID: '',
90-
selectedPaymentMethodType: '',
91-
});
92-
>>>>>>> be90481835 (integrate bank accounts logic)
9347
const [anchorPosition, setAnchorPosition] = useState({
9448
anchorPositionHorizontal: 0,
9549
anchorPositionVertical: 0,
9650
anchorPositionTop: 0,
9751
anchorPositionRight: 0,
9852
});
99-
<<<<<<< HEAD
10053
const hasBankAccount = !isEmptyObject(bankAccountList);
10154
const shouldShowEmptyState = !hasBankAccount;
10255
// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
10356
const isPopoverBottomMount = anchorPosition.anchorPositionTop === 0 || shouldUseNarrowLayout;
10457
const shouldShowMakeDefaultButton = !paymentMethod.isSelectedPaymentMethodDefault;
10558
const transferBankAccountID = policy?.invoice?.bankAccount?.transferBankAccountID;
106-
=======
107-
const hasBankAccount = !isEmptyObject(bankAccountList) || !isEmptyObject(fundList);
108-
const hasWallet = !isEmptyObject(userWallet);
109-
const hasAssignedCard = !isEmptyObject(cardList);
110-
const shouldShowEmptyState = !hasBankAccount && !hasWallet && !hasAssignedCard;
111-
// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
112-
const isPopoverBottomMount = anchorPosition.anchorPositionTop === 0 || shouldUseNarrowLayout;
113-
const shouldShowMakeDefaultButton =
114-
!paymentMethod.isSelectedPaymentMethodDefault &&
115-
!(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && paymentMethod.selectedPaymentMethod.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS);
116-
>>>>>>> be90481835 (integrate bank accounts logic)
11759

11860
/**
11961
* Set position of the payment menu
@@ -170,11 +112,7 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
170112
};
171113
}
172114
setPaymentMethod({
173-
<<<<<<< HEAD
174115
isSelectedPaymentMethodDefault: transferBankAccountID === methodID,
175-
=======
176-
isSelectedPaymentMethodDefault: !!isDefault,
177-
>>>>>>> be90481835 (integrate bank accounts logic)
178116
selectedPaymentMethod: account ?? {},
179117
selectedPaymentMethodType: accountType,
180118
formattedSelectedPaymentMethod,
@@ -211,7 +149,6 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
211149
}, [paymentMethod.selectedPaymentMethod.bankAccountID, paymentMethod.selectedPaymentMethodType]);
212150

213151
const makeDefaultPaymentMethod = useCallback(() => {
214-
<<<<<<< HEAD
215152
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
216153
const paymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, {}, styles);
217154
const previousPaymentMethod = paymentMethods.find((method) => !!method.isDefault);
@@ -220,55 +157,12 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
220157
PaymentMethods.setInvoicingTransferBankAccount(currentPaymentMethod?.methodID ?? -1, policyID, previousPaymentMethod?.methodID ?? -1);
221158
}
222159
}, [bankAccountList, styles, paymentMethod.selectedPaymentMethodType, paymentMethod.methodID, policyID]);
223-
=======
224-
const paymentCardList = fundList ?? {};
225-
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
226-
const paymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, paymentCardList, styles);
227-
228-
const previousPaymentMethod = paymentMethods.find((method) => !!method.isDefault);
229-
const currentPaymentMethod = paymentMethods.find((method) => method.methodID === paymentMethod.methodID);
230-
if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) {
231-
PaymentMethods.makeDefaultPaymentMethod(paymentMethod.selectedPaymentMethod.bankAccountID ?? -1, 0, previousPaymentMethod, currentPaymentMethod);
232-
} else if (paymentMethod.selectedPaymentMethodType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
233-
PaymentMethods.makeDefaultPaymentMethod(0, paymentMethod.selectedPaymentMethod.fundID ?? -1, previousPaymentMethod, currentPaymentMethod);
234-
}
235-
}, [
236-
paymentMethod.methodID,
237-
paymentMethod.selectedPaymentMethod.bankAccountID,
238-
paymentMethod.selectedPaymentMethod.fundID,
239-
paymentMethod.selectedPaymentMethodType,
240-
bankAccountList,
241-
fundList,
242-
styles,
243-
]);
244-
245-
const resetSelectedPaymentMethodData = useCallback(() => {
246-
// Reset to same values as in the constructor
247-
setPaymentMethod({
248-
isSelectedPaymentMethodDefault: false,
249-
selectedPaymentMethod: {},
250-
formattedSelectedPaymentMethod: {
251-
title: '',
252-
},
253-
methodID: '',
254-
selectedPaymentMethodType: '',
255-
});
256-
}, [setPaymentMethod]);
257-
>>>>>>> be90481835 (integrate bank accounts logic)
258160

259161
/**
260162
* Navigate to the appropriate payment type addition screen
261163
*/
262164
const addPaymentMethodTypePressed = (paymentType: string) => {
263165
hideAddPaymentMenu();
264-
<<<<<<< HEAD
265-
=======
266-
267-
if (paymentType === CONST.PAYMENT_METHODS.DEBIT_CARD) {
268-
Navigation.navigate(ROUTES.SETTINGS_ADD_DEBIT_CARD);
269-
return;
270-
}
271-
>>>>>>> be90481835 (integrate bank accounts logic)
272166
if (paymentType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT || paymentType === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
273167
BankAccounts.openPersonalBankAccountSetupView();
274168
return;
@@ -289,22 +183,14 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
289183
shouldShowAddPaymentMethodButton={false}
290184
shouldShowEmptyListMessage={false}
291185
onPress={paymentMethodPressed}
292-
<<<<<<< HEAD
293186
invoiceTransferBankAccountID={transferBankAccountID}
294187
activePaymentMethodID={transferBankAccountID}
295-
=======
296-
activePaymentMethodID={policy?.invoice?.bankAccount?.transferBankAccountID ?? ''}
297-
>>>>>>> be90481835 (integrate bank accounts logic)
298188
actionPaymentMethodType={shouldShowDefaultDeleteMenu ? paymentMethod.selectedPaymentMethodType : ''}
299189
buttonRef={addPaymentMethodAnchorRef}
300190
shouldEnableScroll={false}
301191
style={[styles.mt5, hasBankAccount && [shouldUseNarrowLayout ? styles.mhn5 : styles.mhn8]]}
302192
listItemStyle={shouldUseNarrowLayout ? styles.ph5 : styles.ph8}
303193
/>
304-
<<<<<<< HEAD
305-
=======
306-
307-
>>>>>>> be90481835 (integrate bank accounts logic)
308194
<Popover
309195
isVisible={shouldShowDefaultDeleteMenu}
310196
onClose={hideDefaultDeleteMenu}
@@ -364,10 +250,6 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
364250
onModalHide={resetSelectedPaymentMethodData}
365251
/>
366252
</Popover>
367-
<<<<<<< HEAD
368-
=======
369-
370-
>>>>>>> be90481835 (integrate bank accounts logic)
371253
<AddPaymentMethodMenu
372254
isVisible={shouldShowAddPaymentMenu}
373255
onClose={hideAddPaymentMenu}

0 commit comments

Comments
 (0)