-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Feature/add assigned card tile and display expensify cards #26862
Merged
grgia
merged 2 commits into
Expensify:main
from
pac-guerreiro:feature/add-assigned-card-tile-and-display-expensify-cards
Oct 13, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; | |
import * as PaymentMethods from '../../../libs/actions/PaymentMethods'; | ||
import Log from '../../../libs/Log'; | ||
import stylePropTypes from '../../../styles/stylePropTypes'; | ||
import Navigation from '../../../libs/Navigation/Navigation'; | ||
import ROUTES from '../../../ROUTES'; | ||
import getBankIcon from '../../../components/Icon/BankIcons'; | ||
import assignedCardPropTypes from './assignedCardPropTypes'; | ||
|
||
const propTypes = { | ||
/** What to do when a menu item is pressed */ | ||
|
@@ -31,12 +35,21 @@ const propTypes = { | |
/** List of bank accounts */ | ||
bankAccountList: PropTypes.objectOf(bankAccountPropTypes), | ||
|
||
/** List of assigned cards */ | ||
cardList: PropTypes.objectOf(assignedCardPropTypes), | ||
|
||
/** List of user's cards */ | ||
fundList: PropTypes.objectOf(cardPropTypes), | ||
|
||
/** Whether the add bank account button should be shown on the list */ | ||
shouldShowAddBankAccount: PropTypes.bool, | ||
|
||
/** Whether the add Payment button be shown on the list */ | ||
shouldShowAddPaymentMethodButton: PropTypes.bool, | ||
|
||
/** Whether the assigned cards should be shown on the list */ | ||
shouldShowAssignedCards: PropTypes.bool, | ||
|
||
/** Whether the empty list message should be shown when the list is empty */ | ||
shouldShowEmptyListMessage: PropTypes.bool, | ||
|
||
|
@@ -84,13 +97,16 @@ const propTypes = { | |
|
||
const defaultProps = { | ||
bankAccountList: {}, | ||
cardList: {}, | ||
fundList: null, | ||
userWallet: { | ||
walletLinkedAccountID: 0, | ||
walletLinkedAccountType: '', | ||
}, | ||
isLoadingPaymentMethods: true, | ||
shouldShowAddBankAccount: true, | ||
shouldShowAddPaymentMethodButton: true, | ||
shouldShowAssignedCards: false, | ||
shouldShowEmptyListMessage: true, | ||
filterType: '', | ||
actionPaymentMethodType: '', | ||
|
@@ -161,6 +177,7 @@ function PaymentMethodList({ | |
activePaymentMethodID, | ||
bankAccountList, | ||
buttonRef, | ||
cardList, | ||
fundList, | ||
filterType, | ||
isLoadingPaymentMethods, | ||
|
@@ -171,13 +188,30 @@ function PaymentMethodList({ | |
shouldEnableScroll, | ||
shouldShowSelectedState, | ||
shouldShowAddPaymentMethodButton, | ||
shouldShowAddBankAccount, | ||
shouldShowEmptyListMessage, | ||
shouldShowAssignedCards, | ||
selectedMethodID, | ||
style, | ||
translate, | ||
}) { | ||
const filteredPaymentMethods = useMemo(() => { | ||
const paymentCardList = fundList || {}; | ||
|
||
if (shouldShowAssignedCards) { | ||
const assignedCards = _.filter(cardList, (card) => CONST.EXPENSIFY_CARD.ACTIVE_STATES.includes(card.state)); | ||
return _.map(assignedCards, (card) => { | ||
const icon = getBankIcon(card.bank); | ||
return { | ||
key: card.key, | ||
title: translate('walletPage.expensifyCard'), | ||
description: card.domainName, | ||
onPress: () => Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(card.domainName)), | ||
...icon, | ||
}; | ||
}); | ||
} | ||
|
||
// Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them | ||
const filteredCardList = _.filter(paymentCardList, (card) => card.accountData.additionalData.isP2PDebitCard); | ||
let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList, filteredCardList); | ||
|
@@ -204,14 +238,14 @@ function PaymentMethodList({ | |
})); | ||
|
||
return combinedPaymentMethods; | ||
}, [actionPaymentMethodType, activePaymentMethodID, bankAccountList, filterType, network, onPress, fundList]); | ||
}, [fundList, shouldShowAssignedCards, bankAccountList, filterType, network.isOffline, cardList, translate, actionPaymentMethodType, activePaymentMethodID, onPress]); | ||
|
||
/** | ||
* Render placeholder when there are no payments methods | ||
* | ||
* @return {React.Component} | ||
*/ | ||
const renderListEmptyComponent = useCallback(() => <Text style={[styles.popoverMenuItem]}>{translate('paymentMethodList.addFirstPaymentMethod')}</Text>, [translate]); | ||
const renderListEmptyComponent = () => <Text style={[styles.popoverMenuItem]}>{translate('paymentMethodList.addFirstPaymentMethod')}</Text>; | ||
|
||
const renderListFooterComponent = useCallback( | ||
() => ( | ||
|
@@ -252,12 +286,13 @@ function PaymentMethodList({ | |
iconWidth={item.iconSize} | ||
badgeText={shouldShowDefaultBadge(filteredPaymentMethods, item.isDefault) ? translate('paymentMethodList.defaultPaymentMethod') : null} | ||
wrapperStyle={styles.paymentMethod} | ||
shouldShowRightIcon={shouldShowAssignedCards} | ||
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. Coming from #38643, this |
||
shouldShowSelectedState={shouldShowSelectedState} | ||
isSelected={selectedMethodID === item.methodID} | ||
/> | ||
</OfflineWithFeedback> | ||
), | ||
[filteredPaymentMethods, translate, shouldShowSelectedState, selectedMethodID], | ||
[filteredPaymentMethods, translate, shouldShowAssignedCards, shouldShowSelectedState, selectedMethodID], | ||
); | ||
|
||
return ( | ||
|
@@ -266,9 +301,9 @@ function PaymentMethodList({ | |
data={filteredPaymentMethods} | ||
renderItem={renderItem} | ||
keyExtractor={(item) => item.key} | ||
ListEmptyComponent={shouldShowEmptyListMessage ? renderListEmptyComponent(translate) : null} | ||
ListEmptyComponent={shouldShowEmptyListMessage ? renderListEmptyComponent : null} | ||
ListHeaderComponent={listHeaderComponent} | ||
ListFooterComponent={renderListFooterComponent} | ||
ListFooterComponent={shouldShowAddBankAccount ? renderListFooterComponent : null} | ||
onContentSizeChange={onListContentSizeChange} | ||
scrollEnabled={shouldEnableScroll} | ||
style={style} | ||
|
@@ -307,6 +342,9 @@ export default compose( | |
bankAccountList: { | ||
key: ONYXKEYS.BANK_ACCOUNT_LIST, | ||
}, | ||
cardList: { | ||
key: ONYXKEYS.CARD_LIST, | ||
}, | ||
fundList: { | ||
key: ONYXKEYS.FUND_LIST, | ||
}, | ||
|
grgia marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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.
What is state
2
in Active_States? it's not in theState
object.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.
Ah it's the
Card Not Issued
state. I think this is a typo from the design doc. Let's Remove 2 @pac-guerreiro.But also I'd consider this as NAB for now considering the priority of this PR