@@ -16,44 +16,16 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
16
16
import useThemeStyles from '@hooks/useThemeStyles' ;
17
17
import useWindowDimensions from '@hooks/useWindowDimensions' ;
18
18
import getClickedTargetLocation from '@libs/getClickedTargetLocation' ;
19
- < < << << < HEAD
20
19
import * as PaymentUtils from '@libs/PaymentUtils' ;
21
20
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 )
28
21
import variables from '@styles/variables' ;
29
22
import * as BankAccounts from '@userActions/BankAccounts' ;
30
23
import * as PaymentMethods from '@userActions/PaymentMethods' ;
31
24
import CONST from '@src/CONST' ;
32
25
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' ;
38
26
import type { AccountData } from '@src/types/onyx' ;
39
27
import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
40
28
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
-
57
29
type WorkspaceInvoiceVBASectionProps = {
58
30
/** The policy ID currently being configured */
59
31
policyID : string ;
@@ -66,54 +38,24 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
66
38
const { translate} = useLocalize ( ) ;
67
39
const [ policy ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` ) ;
68
40
const [ bankAccountList ] = useOnyx ( ONYXKEYS . BANK_ACCOUNT_LIST ) ;
69
- < < << << < HEAD
70
41
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 )
76
42
const addPaymentMethodAnchorRef = useRef ( null ) ;
77
43
const paymentMethodButtonRef = useRef < HTMLDivElement | null > ( null ) ;
78
44
const [ shouldShowAddPaymentMenu , setShouldShowAddPaymentMenu ] = useState ( false ) ;
79
45
const [ showConfirmDeleteModal , setShowConfirmDeleteModal ] = useState ( false ) ;
80
46
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 )
93
47
const [ anchorPosition , setAnchorPosition ] = useState ( {
94
48
anchorPositionHorizontal : 0 ,
95
49
anchorPositionVertical : 0 ,
96
50
anchorPositionTop : 0 ,
97
51
anchorPositionRight : 0 ,
98
52
} ) ;
99
- < < << << < HEAD
100
53
const hasBankAccount = ! isEmptyObject ( bankAccountList ) ;
101
54
const shouldShowEmptyState = ! hasBankAccount ;
102
55
// 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
103
56
const isPopoverBottomMount = anchorPosition . anchorPositionTop === 0 || shouldUseNarrowLayout ;
104
57
const shouldShowMakeDefaultButton = ! paymentMethod . isSelectedPaymentMethodDefault ;
105
58
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 )
117
59
118
60
/**
119
61
* Set position of the payment menu
@@ -170,11 +112,7 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
170
112
} ;
171
113
}
172
114
setPaymentMethod ( {
173
- < << << << HEAD
174
115
isSelectedPaymentMethodDefault : transferBankAccountID === methodID ,
175
- = === ===
176
- isSelectedPaymentMethodDefault : ! ! isDefault ,
177
- > >>> >>> be90481835 ( integrate bank accounts logic )
178
116
selectedPaymentMethod : account ?? { } ,
179
117
selectedPaymentMethodType : accountType ,
180
118
formattedSelectedPaymentMethod,
@@ -211,7 +149,6 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
211
149
} , [ paymentMethod . selectedPaymentMethod . bankAccountID , paymentMethod . selectedPaymentMethodType ] ) ;
212
150
213
151
const makeDefaultPaymentMethod = useCallback ( ( ) => {
214
- < < << << < HEAD
215
152
// Find the previous default payment method so we can revert if the MakeDefaultPaymentMethod command errors
216
153
const paymentMethods = PaymentUtils . formatPaymentMethods ( bankAccountList ?? { } , { } , styles ) ;
217
154
const previousPaymentMethod = paymentMethods . find ( ( method ) => ! ! method . isDefault ) ;
@@ -220,55 +157,12 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
220
157
PaymentMethods . setInvoicingTransferBankAccount ( currentPaymentMethod ?. methodID ?? - 1 , policyID , previousPaymentMethod ?. methodID ?? - 1 ) ;
221
158
}
222
159
} , [ 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 )
258
160
259
161
/**
260
162
* Navigate to the appropriate payment type addition screen
261
163
*/
262
164
const addPaymentMethodTypePressed = ( paymentType : string ) => {
263
165
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 )
272
166
if ( paymentType === CONST . PAYMENT_METHODS . PERSONAL_BANK_ACCOUNT || paymentType === CONST . PAYMENT_METHODS . BUSINESS_BANK_ACCOUNT ) {
273
167
BankAccounts . openPersonalBankAccountSetupView ( ) ;
274
168
return ;
@@ -289,22 +183,14 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
289
183
shouldShowAddPaymentMethodButton = { false }
290
184
shouldShowEmptyListMessage = { false }
291
185
onPress = { paymentMethodPressed }
292
- < << << << HEAD
293
186
invoiceTransferBankAccountID = { transferBankAccountID }
294
187
activePaymentMethodID = { transferBankAccountID }
295
- = === ===
296
- activePaymentMethodID = { policy ?. invoice ?. bankAccount ?. transferBankAccountID ?? '' }
297
- > >>> >>> be90481835 ( integrate bank accounts logic )
298
188
actionPaymentMethodType = { shouldShowDefaultDeleteMenu ? paymentMethod . selectedPaymentMethodType : '' }
299
189
buttonRef = { addPaymentMethodAnchorRef }
300
190
shouldEnableScroll = { false }
301
191
style = { [ styles . mt5 , hasBankAccount && [ shouldUseNarrowLayout ? styles . mhn5 : styles . mhn8 ] ] }
302
192
listItemStyle = { shouldUseNarrowLayout ? styles . ph5 : styles . ph8 }
303
193
/>
304
- << << << < HEAD
305
- = === ===
306
-
307
- >>> >>> > be90481835 (integrate bank accounts logic)
308
194
< Popover
309
195
isVisible = { shouldShowDefaultDeleteMenu }
310
196
onClose = { hideDefaultDeleteMenu }
@@ -364,10 +250,6 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
364
250
onModalHide = { resetSelectedPaymentMethodData }
365
251
/>
366
252
</ Popover >
367
- < < << << < HEAD
368
- = === ===
369
-
370
- >>> >>> > be90481835 (integrate bank accounts logic)
371
253
< AddPaymentMethodMenu
372
254
isVisible = { shouldShowAddPaymentMenu }
373
255
onClose = { hideAddPaymentMenu }
0 commit comments