-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Remove Confirmation from plaid bank flow #48767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 16 commits into
Expensify:main
from
parasharrajat:parasharrajat/workspace-feeds
Sep 17, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d773367
Remove Confirmation from Plaidf bank Account flow
parasharrajat b1d7208
Remove the default value from the Card Name step
parasharrajat ecec39d
Remove Manual confirmation step as well
parasharrajat 88cb276
cleanup
parasharrajat f176383
Fix the Account selecton
parasharrajat 42d4142
Remove substeps
parasharrajat b13c6e3
Fixes
parasharrajat 41d83e4
fix types
parasharrajat 02d12b4
Rename the finish data param
parasharrajat 15c2fdc
Merge branch 'main' of github.com:Expensify/App into parasharrajat/wo…
parasharrajat 8fa8e5a
Fix cardname step
parasharrajat a853bd9
remove MoveTo give that there is only one step now.
parasharrajat 487d87e
Remove extra step
parasharrajat 84577fd
Rename variable
parasharrajat 1099cfe
Merge branch 'main' of github.com:Expensify/App into parasharrajat/wo…
parasharrajat e9b2107
with Onyx migration
parasharrajat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import React, {useCallback, useEffect, useMemo} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import {withOnyx} from 'react-native-onyx'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import InteractiveStepSubHeader from '@components/InteractiveStepSubHeader'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
|
|
@@ -17,23 +16,10 @@ import CONST from '@src/CONST'; | |
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {ReimbursementAccountForm} from '@src/types/form'; | ||
| import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; | ||
| import type {ReimbursementAccount} from '@src/types/onyx'; | ||
| import Confirmation from './substeps/Confirmation'; | ||
| import Manual from './substeps/Manual'; | ||
| import Plaid from './substeps/Plaid'; | ||
|
|
||
| type BankInfoOnyxProps = { | ||
| /** Plaid SDK token to use to initialize the widget */ | ||
| plaidLinkToken: OnyxEntry<string>; | ||
|
|
||
| /** Reimbursement account from ONYX */ | ||
| reimbursementAccount: OnyxEntry<ReimbursementAccount>; | ||
|
|
||
| /** The draft values of the bank account being setup */ | ||
| reimbursementAccountDraft: OnyxEntry<ReimbursementAccountForm>; | ||
| }; | ||
|
|
||
| type BankInfoProps = BankInfoOnyxProps & { | ||
| type BankInfoProps = { | ||
| /** Goes to the previous step */ | ||
| onBackButtonPress: () => void; | ||
|
|
||
|
|
@@ -42,11 +28,14 @@ type BankInfoProps = BankInfoOnyxProps & { | |
| }; | ||
|
|
||
| const BANK_INFO_STEP_KEYS = INPUT_IDS.BANK_INFO_STEP; | ||
| const manualSubsteps: Array<React.ComponentType<SubStepProps>> = [Manual, Confirmation]; | ||
| const plaidSubsteps: Array<React.ComponentType<SubStepProps>> = [Plaid, Confirmation]; | ||
| const manualSubsteps: Array<React.ComponentType<SubStepProps>> = [Manual]; | ||
| const plaidSubsteps: Array<React.ComponentType<SubStepProps>> = [Plaid]; | ||
| const receivedRedirectURI = getPlaidOAuthReceivedRedirectURI(); | ||
|
|
||
| function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkToken, onBackButtonPress, policyID}: BankInfoProps) { | ||
| function BankInfo({onBackButtonPress, policyID}: BankInfoProps) { | ||
| const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); | ||
| const [reimbursementAccountDraft] = useOnyx(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT); | ||
| const [plaidLinkToken] = useOnyx(ONYXKEYS.PLAID_LINK_TOKEN); | ||
| const {translate} = useLocalize(); | ||
| const styles = useThemeStyles(); | ||
|
|
||
|
|
@@ -61,37 +50,41 @@ function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkTok | |
| } | ||
|
|
||
| const bankAccountID = Number(reimbursementAccount?.achData?.bankAccountID ?? '-1'); | ||
| const submit = useCallback(() => { | ||
| if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL) { | ||
| BankAccounts.connectBankAccountManually( | ||
| bankAccountID, | ||
| { | ||
| [BANK_INFO_STEP_KEYS.ROUTING_NUMBER]: values[BANK_INFO_STEP_KEYS.ROUTING_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]: values[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.BANK_NAME]: values[BANK_INFO_STEP_KEYS.BANK_NAME] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID]: values[BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN]: values[BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_MASK]: values[BANK_INFO_STEP_KEYS.PLAID_MASK] ?? '', | ||
| [BANK_INFO_STEP_KEYS.IS_SAVINGS]: values[BANK_INFO_STEP_KEYS.IS_SAVINGS] ?? false, | ||
| }, | ||
| policyID, | ||
| ); | ||
| } else if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID) { | ||
| BankAccounts.connectBankAccountWithPlaid( | ||
| bankAccountID, | ||
| { | ||
| [BANK_INFO_STEP_KEYS.ROUTING_NUMBER]: values[BANK_INFO_STEP_KEYS.ROUTING_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]: values[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.BANK_NAME]: values[BANK_INFO_STEP_KEYS.BANK_NAME] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID]: values[BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN]: values[BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_MASK]: values[BANK_INFO_STEP_KEYS.PLAID_MASK] ?? '', | ||
| [BANK_INFO_STEP_KEYS.IS_SAVINGS]: values[BANK_INFO_STEP_KEYS.IS_SAVINGS] ?? false, | ||
| }, | ||
| policyID, | ||
| ); | ||
| } | ||
| }, [setupType, values, bankAccountID, policyID]); | ||
| const submit = useCallback( | ||
| (submitData: unknown) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any way we could improve this type? @koko57 @blazejkustra @fabioh8010 |
||
| const data = submitData as ReimbursementAccountForm; | ||
| if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL) { | ||
| BankAccounts.connectBankAccountManually( | ||
| bankAccountID, | ||
| { | ||
| [BANK_INFO_STEP_KEYS.ROUTING_NUMBER]: data[BANK_INFO_STEP_KEYS.ROUTING_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]: data[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.BANK_NAME]: data[BANK_INFO_STEP_KEYS.BANK_NAME] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID]: data[BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN]: data[BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_MASK]: data[BANK_INFO_STEP_KEYS.PLAID_MASK] ?? '', | ||
| [BANK_INFO_STEP_KEYS.IS_SAVINGS]: data[BANK_INFO_STEP_KEYS.IS_SAVINGS] ?? false, | ||
| }, | ||
| policyID, | ||
| ); | ||
| } else if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID) { | ||
| BankAccounts.connectBankAccountWithPlaid( | ||
| bankAccountID, | ||
| { | ||
| [BANK_INFO_STEP_KEYS.ROUTING_NUMBER]: data[BANK_INFO_STEP_KEYS.ROUTING_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]: data[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER] ?? '', | ||
| [BANK_INFO_STEP_KEYS.BANK_NAME]: data[BANK_INFO_STEP_KEYS.BANK_NAME] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID]: data[BANK_INFO_STEP_KEYS.PLAID_ACCOUNT_ID] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN]: data[BANK_INFO_STEP_KEYS.PLAID_ACCESS_TOKEN] ?? '', | ||
| [BANK_INFO_STEP_KEYS.PLAID_MASK]: data[BANK_INFO_STEP_KEYS.PLAID_MASK] ?? '', | ||
| [BANK_INFO_STEP_KEYS.IS_SAVINGS]: data[BANK_INFO_STEP_KEYS.IS_SAVINGS] ?? false, | ||
| }, | ||
| policyID, | ||
| ); | ||
| } | ||
| }, | ||
| [setupType, bankAccountID, policyID], | ||
| ); | ||
|
|
||
| const bodyContent = setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID ? plaidSubsteps : manualSubsteps; | ||
| const {componentToRender: SubStep, isEditing, screenIndex, nextScreen, prevScreen, moveTo} = useSubStep({bodyContent, startFrom: 0, onFinished: submit}); | ||
|
|
@@ -103,12 +96,10 @@ function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkTok | |
| if (redirectedFromPlaidToManual) { | ||
| return; | ||
| } | ||
|
|
||
| if (setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL && values.bankName !== '' && !redirectedFromPlaidToManual) { | ||
| setRedirectedFromPlaidToManual(true); | ||
| moveTo(0); | ||
| } | ||
| }, [moveTo, redirectedFromPlaidToManual, setupType, values]); | ||
| }, [redirectedFromPlaidToManual, setupType, values]); | ||
|
|
||
| const handleBackButtonPress = () => { | ||
| if (screenIndex === 0) { | ||
|
|
@@ -161,15 +152,4 @@ function BankInfo({reimbursementAccount, reimbursementAccountDraft, plaidLinkTok | |
|
|
||
| BankInfo.displayName = 'BankInfo'; | ||
|
|
||
| export default withOnyx<BankInfoProps, BankInfoOnyxProps>({ | ||
| // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM | ||
| reimbursementAccount: { | ||
| key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, | ||
| }, | ||
| reimbursementAccountDraft: { | ||
| key: ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, | ||
| }, | ||
| plaidLinkToken: { | ||
| key: ONYXKEYS.PLAID_LINK_TOKEN, | ||
| }, | ||
| })(BankInfo); | ||
| export default BankInfo; | ||
119 changes: 0 additions & 119 deletions
119
src/pages/ReimbursementAccount/BankInfo/substeps/Confirmation.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.