-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[No QA] Create new Card Details page #45155
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 5 commits into
Expensify:main
from
VickyStash:feature/44325-card-details-page
Jul 15, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fae3285
Implement Card Details page
VickyStash c0b3fd9
Minor improvements
VickyStash 2e2e731
Add additional Menu Items for Card limit and name
VickyStash 674c2f0
Minor code improvements
VickyStash 22f6876
Merge branch 'refs/heads/main' into feature/44325-card-details-page
VickyStash 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
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
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
149 changes: 149 additions & 0 deletions
149
src/pages/workspace/expensifyCard/WorkspaceExpensifyCardDetailsPage.tsx
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 |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| import type {StackScreenProps} from '@react-navigation/stack'; | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import ExpensifyCardImage from '@assets/images/expensify-card.svg'; | ||
| import Badge from '@components/Badge'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import {FallbackAvatar} from '@components/Icon/Expensicons'; | ||
| import * as Expensicons from '@components/Icon/Expensicons'; | ||
| import ImageSVG from '@components/ImageSVG'; | ||
| import MenuItem from '@components/MenuItem'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import ScrollView from '@components/ScrollView'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import * as CardUtils from '@libs/CardUtils'; | ||
| import * as CurrencyUtils from '@libs/CurrencyUtils'; | ||
| import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||
| import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; | ||
| import Navigation from '@navigation/Navigation'; | ||
| import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
|
|
||
| // TODO: remove when Onyx data is available | ||
| const mockedCard = { | ||
| accountID: 885646, | ||
| availableSpend: 1000, | ||
| nameValuePairs: { | ||
| cardTitle: 'Test 1', | ||
| isVirtual: true, | ||
| limit: 2000, | ||
| limitType: CONST.EXPENSIFY_CARD.LIMIT_TYPES.SMART, | ||
| }, | ||
| lastFourPAN: '1234', | ||
| }; | ||
|
|
||
| type WorkspaceExpensifyCardDetailsPageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.EXPENSIFY_CARD_DETAILS>; | ||
|
|
||
| function WorkspaceExpensifyCardDetailsPage({route}: WorkspaceExpensifyCardDetailsPageProps) { | ||
| const {policyID, cardID, backTo} = route.params; | ||
|
|
||
| const {translate} = useLocalize(); | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
|
|
||
| const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); | ||
| const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${policyID}_${CONST.EXPENSIFY_CARD.BANK}`); | ||
|
|
||
| const card = cardsList?.[cardID] ?? mockedCard; | ||
| const cardholder = personalDetails?.[card.accountID ?? -1]; | ||
| const isVirtual = !!card.nameValuePairs?.isVirtual; | ||
| const formattedAvailableSpendAmount = CurrencyUtils.convertToDisplayString(card.availableSpend); | ||
| const formattedLimit = CurrencyUtils.convertToDisplayString(card.nameValuePairs?.limit); | ||
| const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(cardholder); | ||
| const translationForLimitType = CardUtils.getTranslationKeyForLimitType(card.nameValuePairs?.limitType); | ||
|
|
||
| return ( | ||
| <AccessOrNotFoundWrapper | ||
| accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} | ||
| policyID={policyID} | ||
| featureName={CONST.POLICY.MORE_FEATURES.ARE_EXPENSIFY_CARDS_ENABLED} | ||
| > | ||
| <ScreenWrapper | ||
| includeSafeAreaPaddingBottom={false} | ||
| testID={WorkspaceExpensifyCardDetailsPage.displayName} | ||
| > | ||
| {({safeAreaPaddingBottomStyle}) => ( | ||
| <> | ||
| <HeaderWithBackButton | ||
| title={translate('workspace.expensifyCard.cardDetails')} | ||
| onBackButtonPress={() => Navigation.goBack(backTo)} | ||
| /> | ||
| <ScrollView contentContainerStyle={safeAreaPaddingBottomStyle}> | ||
| <View style={[styles.walletCard, styles.mb3]}> | ||
| <ImageSVG | ||
| contentFit="contain" | ||
| src={ExpensifyCardImage} | ||
| pointerEvents="none" | ||
| height={variables.cardPreviewHeight} | ||
| width={variables.cardPreviewWidth} | ||
| /> | ||
| <Badge | ||
| badgeStyles={styles.cardBadge} | ||
| textStyles={styles.cardBadgeText} | ||
| text={translate(isVirtual ? 'workspace.expensifyCard.virtual' : 'workspace.expensifyCard.physical')} | ||
| /> | ||
| </View> | ||
|
|
||
| <MenuItem | ||
| label={translate('workspace.card.issueNewCard.cardholder')} | ||
| title={displayName} | ||
| icon={cardholder?.avatar ?? FallbackAvatar} | ||
| iconType={CONST.ICON_TYPE_AVATAR} | ||
| description={cardholder?.login} | ||
| interactive={false} | ||
| /> | ||
| <MenuItemWithTopDescription | ||
| description={translate(isVirtual ? 'cardPage.virtualCardNumber' : 'cardPage.physicalCardNumber')} | ||
| title={CardUtils.maskCard(card.lastFourPAN)} | ||
| interactive={false} | ||
| titleStyle={styles.walletCardNumber} | ||
| /> | ||
| <MenuItemWithTopDescription | ||
| description={translate('cardPage.availableSpend')} | ||
| title={formattedAvailableSpendAmount} | ||
| interactive={false} | ||
| titleStyle={styles.newKansasLarge} | ||
| /> | ||
| <MenuItemWithTopDescription | ||
| description={translate('workspace.expensifyCard.cardLimit')} | ||
| title={formattedLimit} | ||
| shouldShowRightIcon | ||
| onPress={() => {}} // TODO: navigate to Edit card limit page https://github.com/Expensify/App/issues/44326 | ||
| /> | ||
| <MenuItemWithTopDescription | ||
| description={translate('workspace.card.issueNewCard.limitType')} | ||
| title={translationForLimitType ? translate(translationForLimitType) : ''} | ||
| shouldShowRightIcon | ||
| onPress={() => {}} // TODO: navigate to Edit limit type page https://github.com/Expensify/App/issues/44328 | ||
| /> | ||
| <MenuItemWithTopDescription | ||
| description={translate('workspace.card.issueNewCard.cardName')} | ||
| title={card.nameValuePairs?.cardTitle} | ||
| shouldShowRightIcon | ||
| onPress={() => {}} // TODO: navigate to Edit card name page https://github.com/Expensify/App/issues/44327 | ||
| /> | ||
| <MenuItem | ||
| icon={Expensicons.Trashcan} | ||
| iconFill={theme.icon} | ||
| title={translate('workspace.expensifyCard.deactivate')} | ||
| style={styles.mv1} | ||
| onPress={() => {}} // TODO: create Deactivate card logic https://github.com/Expensify/App/issues/44320 | ||
| /> | ||
| </ScrollView> | ||
| </> | ||
| )} | ||
| </ScreenWrapper> | ||
| </AccessOrNotFoundWrapper> | ||
| ); | ||
| } | ||
|
|
||
| WorkspaceExpensifyCardDetailsPage.displayName = 'WorkspaceExpensifyCardDetailsPage'; | ||
|
|
||
| export default WorkspaceExpensifyCardDetailsPage; |
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
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.