-
Notifications
You must be signed in to change notification settings - Fork 4k
Update the policy expensify card table to the new style #94860
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
luacmartins
merged 4 commits into
main
from
revert-94807-revert-93861-cmartins-ecardTable
Jun 29, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e51d7e6
Revert "[CP Staging] Revert "Update the policy expensify card table t…
luacmartins 49b3836
Fix frozen card message overlapping table cells
luacmartins 23e1171
Merge branch 'main' into revert-94807-revert-93861-cmartins-ecardTable
luacmartins 2a208d1
Move frozenByAdminPrefix translate call inside frozen guard
luacmartins 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
189 changes: 189 additions & 0 deletions
189
src/components/Tables/WorkspaceExpensifyCardsTable/WorkspaceExpensifyCardsTableRow.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,189 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import Avatar from '@components/Avatar'; | ||
| import Icon from '@components/Icon'; | ||
| import {useSession} from '@components/OnyxListItemProvider'; | ||
| import Table from '@components/Table'; | ||
| import Text from '@components/Text'; | ||
| import TextWithTooltip from '@components/TextWithTooltip'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getTranslationKeyForLimitType} from '@libs/CardUtils'; | ||
| import {convertToShortDisplayString} from '@libs/CurrencyUtils'; | ||
| import DateUtils from '@libs/DateUtils'; | ||
| import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import type {WorkspaceExpensifyCardTableRowData} from '.'; | ||
|
|
||
| type WorkspaceExpensifyCardsTableRowProps = { | ||
| /** Data about the Expensify card */ | ||
| item: WorkspaceExpensifyCardTableRowData; | ||
|
|
||
| /** The index of the row relative to all other rows */ | ||
| rowIndex: number; | ||
|
|
||
| /** Whether to use narrow table row layout */ | ||
| shouldUseNarrowTableLayout: boolean; | ||
| }; | ||
|
|
||
| export default function WorkspaceExpensifyCardsTableRow({item, rowIndex, shouldUseNarrowTableLayout}: WorkspaceExpensifyCardsTableRowProps) { | ||
| const icons = useMemoizedLazyExpensifyIcons(['ArrowRight', 'FallbackAvatar', 'FreezeCard']); | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const theme = useTheme(); | ||
| const session = useSession(); | ||
|
|
||
| const cardholderName = getDisplayNameOrDefault(item.cardholder); | ||
| const cardType = item.isVirtual ? translate('workspace.expensifyCard.virtual') : translate('workspace.expensifyCard.physical'); | ||
| const limitTypeLabel = translate(getTranslationKeyForLimitType(item.limitType)); | ||
| const formattedLimit = convertToShortDisplayString(item.limit, item.currency); | ||
| const formattedFrozenDate = item.frozenDate ? DateUtils.formatWithUTCTimeZone(item.frozenDate, CONST.DATE.MONTH_DAY_YEAR_ABBR_FORMAT) : ''; | ||
| let frozenByText: string | undefined; | ||
| if (formattedFrozenDate) { | ||
| if (item.frozenByAccountID === session?.accountID) { | ||
| frozenByText = translate('cardPage.youFroze', {date: formattedFrozenDate}); | ||
| } else { | ||
| const frozenByAdminPrefix = translate('cardPage.frozenByAdminPrefix', {date: formattedFrozenDate}); | ||
| frozenByText = `${frozenByAdminPrefix}${item.frozenByDisplayName ?? translate('common.someone')}`; | ||
| } | ||
| } | ||
|
|
||
| const accessibilityLabel = [cardholderName, item.name, cardType, limitTypeLabel, item.lastFourPAN, formattedLimit, frozenByText].filter(Boolean).join(', '); | ||
|
|
||
| const frozenByRowFooter = !!frozenByText && ( | ||
| <View style={[styles.flexRow, styles.alignItemsCenter, styles.mt1]}> | ||
| <Icon | ||
| src={icons.FreezeCard} | ||
| fill={theme.icon} | ||
| small | ||
| /> | ||
| <Text | ||
| numberOfLines={1} | ||
| ellipsizeMode="tail" | ||
| style={[styles.textLabelSupporting, styles.colorMuted, styles.ml2, styles.flexShrink1, shouldUseNarrowTableLayout ? styles.lh16 : styles.textMicro]} | ||
| > | ||
| {frozenByText} | ||
| </Text> | ||
| </View> | ||
| ); | ||
|
|
||
| return ( | ||
| <Table.Row | ||
| interactive | ||
| rowIndex={rowIndex} | ||
| accessibilityLabel={accessibilityLabel} | ||
| skeletonReasonAttributes={{context: 'workspaceExpensifyCardsTableRow'}} | ||
| sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.EXPENSIFY_CARD.ROW} | ||
| offlineWithFeedback={{ | ||
| errors: item.errors, | ||
| pendingAction: item.pendingAction, | ||
| shouldHideOnDelete: false, | ||
| onClose: item.onClose, | ||
| }} | ||
| rowFooter={frozenByRowFooter} | ||
| onPress={item.action} | ||
| > | ||
| {({hovered}) => ( | ||
| <> | ||
| <View style={[styles.flex1, styles.flexRow, styles.gap3, styles.alignItemsCenter]}> | ||
| <Avatar | ||
| source={item.cardholder?.avatar ?? icons.FallbackAvatar} | ||
| avatarID={item.cardholder?.accountID} | ||
| type={CONST.ICON_TYPE_AVATAR} | ||
| size={CONST.AVATAR_SIZE.DEFAULT} | ||
| /> | ||
| <View style={[styles.flex1, shouldUseNarrowTableLayout && styles.gap1]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={cardholderName} | ||
| style={[styles.optionDisplayName, styles.textStrong, styles.pre]} | ||
| /> | ||
| {shouldUseNarrowTableLayout ? ( | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={item.lastFourPAN} | ||
| style={[styles.textLabelSupporting, styles.lh16, styles.pre, styles.mr3]} | ||
| /> | ||
| ) : ( | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={item.name} | ||
| style={styles.textLabelSupporting} | ||
| /> | ||
| )} | ||
| </View> | ||
| </View> | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={cardType} | ||
| /> | ||
| </View> | ||
| )} | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={limitTypeLabel} | ||
| /> | ||
| </View> | ||
| )} | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={item.lastFourPAN} | ||
| /> | ||
| </View> | ||
| )} | ||
|
|
||
| <View | ||
| style={[ | ||
| shouldUseNarrowTableLayout ? styles.flexColumn : styles.flexRow, | ||
| shouldUseNarrowTableLayout ? styles.alignItemsEnd : styles.flex1, | ||
| shouldUseNarrowTableLayout ? styles.justifyContentStart : styles.alignItemsCenter, | ||
| shouldUseNarrowTableLayout ? undefined : styles.justifyContentEnd, | ||
| ]} | ||
| > | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={formattedLimit} | ||
| /> | ||
| {shouldUseNarrowTableLayout && ( | ||
| <Text | ||
| numberOfLines={1} | ||
| style={styles.textLabelSupporting} | ||
| > | ||
| {cardType} | ||
| </Text> | ||
| )} | ||
| </View> | ||
|
|
||
| <View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentEnd, styles.gap3]}> | ||
| <Icon | ||
| src={icons.ArrowRight} | ||
| fill={theme.icon} | ||
| additionalStyles={[styles.alignSelfCenter, !hovered && styles.opacitySemiTransparent]} | ||
| width={variables.iconSizeNormal} | ||
| height={variables.iconSizeNormal} | ||
| /> | ||
| </View> | ||
| </> | ||
| )} | ||
| </Table.Row> | ||
| ); | ||
| } |
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.