Skip to content
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] Fix/52558 fix card name and images #52735

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/Icon/BankIcons/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export default function getBankIcon({styles, bankName, isCard = false}: BankIcon
bankIcon.iconSize = variables.iconSizeExtraLarge;
bankIcon.iconStyles = [styles.bankIconContainer];
} else {
bankIcon.iconHeight = variables.bankCardHeight;
bankIcon.iconWidth = variables.bankCardWidth;
bankIcon.iconStyles = [styles.assignedCardsIconContainer];
bankIcon.iconHeight = variables.cardIconHeight;
bankIcon.iconWidth = variables.cardIconWidth;
bankIcon.iconStyles = [styles.cardIcon];
}

return bankIcon;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Icon/BankIcons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default function getBankIcon({styles, bankName, isCard = false}: BankIcon
bankIcon.iconSize = variables.iconSizeExtraLarge;
bankIcon.iconStyles = [styles.bankIconContainer];
} else {
bankIcon.iconHeight = variables.bankCardHeight;
bankIcon.iconWidth = variables.bankCardWidth;
bankIcon.iconStyles = [styles.assignedCardsIconContainer];
bankIcon.iconHeight = variables.cardIconHeight;
bankIcon.iconWidth = variables.cardIconWidth;
bankIcon.iconStyles = [styles.cardIcon];
}

return bankIcon;
Expand Down
8 changes: 8 additions & 0 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ function hasOnlyOneCardToAssign(list: FilteredCardList) {
return Object.keys(list).length === 1;
}

function getDefaultCardName(cardholder?: string) {
if (!cardholder) {
return '';
}
return `${cardholder}'s card`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noting that we internally agreed to keep the c as small

}

export {
isExpensifyCard,
isCorporateCard,
Expand Down Expand Up @@ -391,4 +398,5 @@ export {
removeExpensifyCardFromCompanyCards,
getFilteredCardList,
hasOnlyOneCardToAssign,
getDefaultCardName,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import getBankIcon from '@components/Icon/BankIcons';
import type {BankName} from '@components/Icon/BankIconsUtils';
import ScreenWrapper from '@components/ScreenWrapper';
import SelectionList from '@components/SelectionList';
import CardListItem from '@components/SelectionList/CardListItem';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CardUtils from '@libs/CardUtils';
import type {CategorySection} from '@libs/OptionsListUtils';
import type {OptionData} from '@libs/ReportUtils';
import Navigation from '@navigation/Navigation';
import variables from '@styles/variables';
import * as SearchActions from '@userActions/Search';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {CompanyCardFeed} from '@src/types/onyx';

function SearchFiltersCardPage() {
const styles = useThemeStyles();
Expand All @@ -32,7 +33,7 @@ function SearchFiltersCardPage() {
const cards = Object.values(cardList ?? {})
.sort((a, b) => a.bank.localeCompare(b.bank))
.map((card) => {
const icon = getBankIcon({bankName: card.bank as BankName, isCard: true, styles});
const icon = CardUtils.getCardFeedIcon(card?.bank as CompanyCardFeed);
const cardName = card?.nameValuePairs?.cardTitle ?? card?.cardName;
const text = card.bank === CONST.EXPENSIFY_CARD.BANK ? card.bank : cardName;

Expand All @@ -42,7 +43,12 @@ function SearchFiltersCardPage() {
text,
keyForList: card.cardID.toString(),
isSelected: newCards.includes(card.cardID.toString()),
bankIcon: icon,
bankIcon: {
icon,
iconWidth: variables.cardIconWidth,
iconHeight: variables.cardIconHeight,
iconStyles: [styles.cardIcon],
},
};
});
newSections.push({
Expand Down
11 changes: 6 additions & 5 deletions src/pages/settings/Wallet/PaymentMethodList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ function PaymentMethodList({
? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR
: undefined,
icon,
iconStyles: [styles.assignedCardsIconContainer],
iconSize: variables.iconSizeExtraLarge,
iconStyles: [styles.cardIcon],
iconWidth: variables.cardIconWidth,
iconHeight: variables.cardIconHeight,
});
return;
}
Expand Down Expand Up @@ -290,9 +291,9 @@ function PaymentMethodList({
? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR
: undefined,
icon,
iconStyles: [styles.assignedCardsIconContainer],
iconWidth: variables.bankCardWidth,
iconHeight: variables.bankCardHeight,
iconStyles: [styles.cardIcon],
iconWidth: variables.cardIconWidth,
iconHeight: variables.cardIconHeight,
});
});
return assignedCardsGrouped;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag
>
<MenuItemWithTopDescription
description={translate('workspace.moreFeatures.companyCards.cardName')}
title={customCardNames?.[cardID] ?? ''}
title={customCardNames?.[cardID] ?? CardUtils.getDefaultCardName(cardholder?.firstName)}
shouldShowRightIcon
brickRoadIndicator={card?.nameValuePairs?.errorFields?.cardTitle ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARD_NAME.getRoute(policyID, cardID, bank))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function WorkspaceCompanyCardFeedSelectorPage({route}: WorkspaceCompanyCardFeedS
leftElement: (
<Icon
src={CardUtils.getCardFeedIcon(feed)}
height={variables.iconSizeExtraLarge}
width={variables.iconSizeExtraLarge}
additionalStyles={styles.mr3}
height={variables.cardIconHeight}
width={variables.cardIconWidth}
additionalStyles={[styles.mr3, styles.cardIcon]}
/>
),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function WorkspaceCompanyCardsList({cardsList, policyID}: WorkspaceCompanyCardsL
<WorkspaceCompanyCardsListRow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Expensify/design @mountiny

When there is no display name present, we default the card name to users email, on small screen the card number is kicked out of the view:

Screenshot 2024-11-22 at 6 04 51 PM

What should we do in such case ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should truncate for such a long names, not much else to do here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just waiting for this discussion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

cardholder={personalDetails?.[item.accountID ?? '-1']}
cardNumber={CardUtils.maskCardNumber(cardName, item.bank)}
name={customCardNames?.[item.cardID] ?? ''}
name={customCardNames?.[item.cardID] ?? CardUtils.getDefaultCardName(personalDetails?.[item.accountID ?? '-1']?.firstName)}
/>
</PressableWithFeedback>
</OfflineWithFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ function WorkspaceCompanyCardsListHeaderButtons({policyID, selectedFeed}: Worksp
>
<Icon
src={CardUtils.getCardFeedIcon(selectedFeed)}
width={variables.iconSizeExtraLarge}
height={variables.iconSizeExtraLarge}
height={variables.cardIconHeight}
width={variables.cardIconWidth}
additionalStyles={styles.cardIcon}
/>
<View>
<View style={[styles.flexRow, styles.gap1]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function AssigneeStep({policy}: AssigneeStepProps) {
currentStep: isEditing ? CONST.COMPANY_CARD.STEP.CONFIRMATION : nextStep,
data: {
email: selectedMember,
cardName: `${memberName}'s card`,
cardName: CardUtils.getDefaultCardName(memberName),
},
isEditing: false,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ function CardSelectionStep({feed, policyID}: CardSelectionStepProps) {
leftElement: (
<Icon
src={CardUtils.getCardFeedIcon(feed)}
height={variables.iconSizeExtraLarge}
width={variables.iconSizeExtraLarge}
additionalStyles={styles.mr3}
height={variables.cardIconHeight}
width={variables.cardIconWidth}
additionalStyles={[styles.mr3, styles.cardIcon]}
/>
),
}));
Expand Down Expand Up @@ -107,9 +107,9 @@ function CardSelectionStep({feed, policyID}: CardSelectionStepProps) {
leftElement: (
<Icon
src={CardUtils.getCardFeedIcon(feed)}
height={variables.iconSizeExtraLarge}
height={variables.cardIconHeight}
width={variables.iconSizeExtraLarge}
additionalStyles={styles.mr3}
additionalStyles={[styles.mr3, styles.cardIcon]}
/>
),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TextInput from '@components/TextInput';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as CardUtils from '@libs/CardUtils';
import * as ErrorUtils from '@libs/ErrorUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
Expand All @@ -27,7 +28,7 @@ function CardNameStep() {
const data = issueNewCard?.data;

const userName = PersonalDetailsUtils.getUserNameByEmail(data?.assigneeEmail ?? '', 'firstName');
const defaultCardTitle = data?.cardType !== CONST.EXPENSIFY_CARD.CARD_TYPE.VIRTUAL ? `${userName}'s Card` : '';
const defaultCardTitle = data?.cardType !== CONST.EXPENSIFY_CARD.CARD_TYPE.VIRTUAL ? CardUtils.getDefaultCardName(userName) : '';

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.ISSUE_NEW_EXPENSIFY_CARD_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.ISSUE_NEW_EXPENSIFY_CARD_FORM> => {
const errors = ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.CARD_TITLE]);
Expand Down
5 changes: 2 additions & 3 deletions src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM
icon={CardUtils.getCardFeedIcon(memberCard.bank as CompanyCardFeed)}
displayInDefaultIconColor
iconStyles={styles.cardIcon}
contentFit="contain"
iconWidth={variables.iconSizeExtraLarge}
iconHeight={variables.iconSizeExtraLarge}
iconWidth={variables.cardIconWidth}
iconHeight={variables.cardIconHeight}
onPress={() => navigateToDetails(memberCard)}
shouldRemoveHoverBackground={isCardDeleted}
disabled={isCardDeleted}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/workspace/members/WorkspaceMemberNewCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ function WorkspaceMemberNewCardPage({route, personalDetails}: WorkspaceMemberNew
leftElement: (
<Icon
src={CardUtils.getCardFeedIcon(key)}
height={variables.iconSizeExtraLarge}
width={variables.iconSizeExtraLarge}
additionalStyles={styles.mr3}
height={variables.cardIconHeight}
width={variables.cardIconWidth}
additionalStyles={[styles.mr3, styles.cardIcon]}
/>
),
}));
Expand Down
13 changes: 2 additions & 11 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4545,17 +4545,9 @@ const styles = (theme: ThemeColors) =>
position: 'absolute',
},

assignedCardsIconContainer: {
height: variables.bankCardHeight,
width: variables.bankCardWidth,
borderRadius: 4,
overflow: 'hidden',
alignSelf: 'center',
},

bankIconContainer: {
height: variables.bankCardWidth,
width: variables.bankCardWidth,
height: variables.cardIconWidth,
width: variables.cardIconWidth,
borderRadius: 8,
overflow: 'hidden',
alignSelf: 'center',
Expand Down Expand Up @@ -5219,7 +5211,6 @@ const styles = (theme: ThemeColors) =>
cardIcon: {
overflow: 'hidden',
borderRadius: variables.cardBorderRadius,
height: variables.cardIconHeight,
alignSelf: 'center',
},

Expand Down
6 changes: 2 additions & 4 deletions src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ export default {
reportActionImagesDoubleImageHeight: 138,
reportActionImagesMultipleImageHeight: 110,
reportActionItemImagesMoreCornerTriangleWidth: 40,
bankCardWidth: 40,
bankCardHeight: 26,
popoverzIndex: 10000,
workspaceTypeIconWidth: 34,
sectionMargin: 16,
Expand Down Expand Up @@ -238,8 +236,8 @@ export default {
cardPreviewHeight: 148,
cardPreviewWidth: 235,
cardIconWidth: 40,
cardIconHeight: 25.29,
cardBorderRadius: 2.35,
cardIconHeight: 26,
cardBorderRadius: 4,

cardNameWidth: 156,
holdMenuIconSize: 64,
Expand Down
Loading