-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[No QA] Issue New Card Bank Accounts Logic #45069
Merged
mountiny
merged 10 commits into
Expensify:main
from
koko57:feature/44305-existing-bank-accounts-logic
Jul 12, 2024
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
528646b
feat: setup route for choosing bank account
koko57 1d21217
feat: create page content
koko57 78490f4
feat: render proper bank info
koko57 3e64e94
chore: cleanup
koko57 1d6e3cf
fix: resolve conflicts
koko57 3ba56cb
fix: minor improvements
koko57 8b1f0f0
fix: minor improvements
koko57 77545b7
Merge branch 'main' into feature/44305-existing-bank-accounts-logic
koko57 b7ce53c
fix: apply requested changes
koko57 52faa21
fix: fix condition
koko57 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 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 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 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 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 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 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 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 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 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
95 changes: 95 additions & 0 deletions
95
src/pages/workspace/expensifyCard/WorkspaceExpensifyCardBankAccounts.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import getBankIcon from '@components/Icon/BankIcons'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import MenuItem from '@components/MenuItem'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import Navigation from '@navigation/Navigation'; | ||
import type {SettingsNavigatorParamList} from '@navigation/types'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import type {BankName} from '@src/types/onyx/Bank'; | ||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
|
||
type WorkspaceExpensifyCardBankAccountsProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.EXPENSIFY_CARD_BANK_ACCOUNT>; | ||
|
||
function WorkspaceExpensifyCardBankAccounts({route}: WorkspaceExpensifyCardBankAccountsProps) { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST); | ||
|
||
const policyID = route.params.policyID ?? '-1'; | ||
|
||
const handleAddBankAccount = () => { | ||
// TODO: call to API - UpdateCardSettlementAccount | ||
Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute('new', policyID, ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID))); | ||
}; | ||
|
||
const handleSelectBankAccount = () => { | ||
Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD_ISSUE_NEW.getRoute(policyID)); | ||
}; | ||
|
||
const renderBankOptions = () => { | ||
mountiny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!bankAccountsList || isEmptyObject(bankAccountsList)) { | ||
return null; | ||
} | ||
|
||
// const eligibleBankAccounts = Object.values(bankAccountsList).filter((bankAccount) => bankAccount.accountData.allowDebit || bankAccount.accountData.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS); | ||
const eligibleBankAccounts = Object.values(bankAccountsList); | ||
Comment on lines
+44
to
+45
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. Why did we omit this check, we could have added it to the mock data if needed 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. will be held in #46564 |
||
|
||
return eligibleBankAccounts.map((bankAccount) => { | ||
const bankName = (bankAccount.accountData?.addressName ?? '') as BankName; | ||
const bankAccountNumber = bankAccount.accountData?.accountNumber ?? ''; | ||
|
||
const {icon, iconSize, iconStyles} = getBankIcon({bankName, styles}); | ||
|
||
return ( | ||
<MenuItem | ||
title={bankName} | ||
description={`${translate('workspace.expensifyCard.accountEndingIn')} ${bankAccountNumber.slice(-4)}`} | ||
onPress={handleSelectBankAccount} | ||
icon={icon} | ||
iconHeight={iconSize} | ||
iconWidth={iconSize} | ||
iconStyles={iconStyles} | ||
shouldShowRightIcon | ||
displayInDefaultIconColor | ||
/> | ||
); | ||
}); | ||
}; | ||
|
||
return ( | ||
<ScreenWrapper | ||
testID={WorkspaceExpensifyCardBankAccounts.displayName} | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnablePickerAvoiding={false} | ||
> | ||
<HeaderWithBackButton | ||
shouldShowBackButton | ||
onBackButtonPress={() => Navigation.goBack()} | ||
title={translate('workspace.expensifyCard.chooseBankAccount')} | ||
/> | ||
<View style={styles.flex1}> | ||
<Text style={[styles.mh5, styles.mb3]}>{translate('workspace.expensifyCard.chooseExistingBank')}</Text> | ||
{renderBankOptions()} | ||
<MenuItem | ||
icon={Expensicons.Plus} | ||
title={translate('workspace.expensifyCard.addNewBankAccount')} | ||
onPress={handleAddBankAccount} | ||
/> | ||
</View> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
WorkspaceExpensifyCardBankAccounts.displayName = 'WorkspaceExpensifyCardBankAccounts'; | ||
|
||
export default WorkspaceExpensifyCardBankAccounts; |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.