@@ -6,10 +6,10 @@ import useLocalize from '@hooks/useLocalize';
66import useNetwork from '@hooks/useNetwork' ;
77import useTheme from '@hooks/useTheme' ;
88import useThemeStyles from '@hooks/useThemeStyles' ;
9+ import { handlePlaidError , openPlaidBankAccountSelector , openPlaidBankLogin , setPlaidEvent } from '@libs/actions/BankAccounts' ;
910import KeyboardShortcut from '@libs/KeyboardShortcut' ;
1011import Log from '@libs/Log' ;
11- import * as App from '@userActions/App' ;
12- import * as BankAccounts from '@userActions/BankAccounts' ;
12+ import { handleRestrictedEvent } from '@userActions/App' ;
1313import CONST from '@src/CONST' ;
1414import ONYXKEYS from '@src/ONYXKEYS' ;
1515import type { PlaidData } from '@src/types/onyx' ;
@@ -91,7 +91,7 @@ function AddPlaidBankAccount({
9191 const defaultSelectedPlaidAccountID = defaultSelectedPlaidAccount ?. plaidAccountID ?? '-1' ;
9292 const defaultSelectedPlaidAccountMask = plaidBankAccounts . find ( ( account ) => account . plaidAccountID === selectedPlaidAccountID ) ?. mask ?? '' ;
9393 const subscribedKeyboardShortcuts = useRef < Array < ( ) => void > > ( [ ] ) ;
94- const previousNetworkState = useRef < boolean | undefined > ( ) ;
94+ const previousNetworkState = useRef < boolean | undefined > ( undefined ) ;
9595 const [ selectedPlaidAccountMask , setSelectedPlaidAccountMask ] = useState ( defaultSelectedPlaidAccountMask ) ;
9696
9797 const { translate} = useLocalize ( ) ;
@@ -149,7 +149,7 @@ function AddPlaidBankAccount({
149149 if ( isAuthenticatedWithPlaid ( ) ) {
150150 return unsubscribeToNavigationShortcuts ;
151151 }
152- BankAccounts . openPlaidBankLogin ( allowDebit , bankAccountID ) ;
152+ openPlaidBankLogin ( allowDebit , bankAccountID ) ;
153153 return unsubscribeToNavigationShortcuts ;
154154
155155 // disabling this rule, as we want this to run only on the first render
@@ -160,7 +160,7 @@ function AddPlaidBankAccount({
160160 // If we are coming back from offline and we haven't authenticated with Plaid yet, we need to re-run our call to kick off Plaid
161161 // previousNetworkState.current also makes sure that this doesn't run on the first render.
162162 if ( previousNetworkState . current && ! isOffline && ! isAuthenticatedWithPlaid ( ) ) {
163- BankAccounts . openPlaidBankLogin ( allowDebit , bankAccountID ) ;
163+ openPlaidBankLogin ( allowDebit , bankAccountID ) ;
164164 }
165165 previousNetworkState . current = isOffline ;
166166 } , [ allowDebit , bankAccountID , isAuthenticatedWithPlaid , isOffline ] ) ;
@@ -187,7 +187,7 @@ function AddPlaidBankAccount({
187187 onInputChange ( plaidAccountID ) ;
188188 } ;
189189
190- const handlePlaidError = useCallback ( ( error : ErrorEvent | null ) => {
190+ const handlePlaidLinkError = useCallback ( ( error : ErrorEvent | null ) => {
191191 Log . hmmm ( '[PlaidLink] Error: ' , error ?. message ) ;
192192 } , [ ] ) ;
193193
@@ -206,22 +206,22 @@ function AddPlaidBankAccount({
206206 token = { token }
207207 onSuccess = { ( { publicToken, metadata} ) => {
208208 Log . info ( '[PlaidLink] Success!' ) ;
209- BankAccounts . openPlaidBankAccountSelector ( publicToken , metadata ?. institution ?. name ?? '' , allowDebit , bankAccountID ) ;
209+ openPlaidBankAccountSelector ( publicToken , metadata ?. institution ?. name ?? '' , allowDebit , bankAccountID ) ;
210210 } }
211- onError = { handlePlaidError }
211+ onError = { handlePlaidLinkError }
212212 onEvent = { ( event , metadata ) => {
213- BankAccounts . setPlaidEvent ( event ) ;
213+ setPlaidEvent ( event ) ;
214214 // Handle Plaid login errors (will potentially reset plaid token and item depending on the error)
215215 if ( event === 'ERROR' ) {
216216 Log . hmmm ( '[PlaidLink] Error: ' , { ...metadata } ) ;
217217 if ( bankAccountID && metadata && 'error_code' in metadata ) {
218- BankAccounts . handlePlaidError ( bankAccountID , metadata . error_code ?? '' , metadata . error_message ?? '' , metadata . request_id ) ;
218+ handlePlaidError ( bankAccountID , metadata . error_code ?? '' , metadata . error_message ?? '' , metadata . request_id ) ;
219219 }
220220 }
221221
222222 // Limit the number of times a user can submit Plaid credentials
223223 if ( event === 'SUBMIT_CREDENTIALS' ) {
224- App . handleRestrictedEvent ( event ) ;
224+ handleRestrictedEvent ( event ) ;
225225 }
226226 } }
227227 // User prematurely exited the Plaid flow
0 commit comments