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

Update the Assigned Cards Section of the Wallet Page #38998

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0515ffb
make wallet page cards grouped by domain
SzymczakJ Mar 26, 2024
ecdcf48
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ Mar 26, 2024
804005a
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ Mar 28, 2024
71c86a2
fix navigation on lost/fraud/actvate card flows
SzymczakJ Mar 28, 2024
13674cd
fix navigation on get physical card flow
SzymczakJ Mar 28, 2024
e5d8cc5
fix PR comments
SzymczakJ Apr 2, 2024
a26532f
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ Apr 5, 2024
ecd7c73
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ Apr 5, 2024
6bf60e9
make card row title depend on cardTitle when card is admin assigned
SzymczakJ Apr 5, 2024
a10788e
adjust expensifyCardPage title
SzymczakJ Apr 5, 2024
bc9ce69
fix PR comments
SzymczakJ Apr 12, 2024
c19eb59
fix PR comments
SzymczakJ Apr 16, 2024
ae6f359
fix types
SzymczakJ Apr 16, 2024
24321a9
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ Apr 19, 2024
70d02e4
fix nameValuePairs bugs
SzymczakJ Apr 19, 2024
55bed2d
fix PR comments
SzymczakJ Apr 22, 2024
5b9ad8c
Merge branch 'main' into @szymczak/update-cards-section
SzymczakJ Apr 22, 2024
a8454dc
fix button margins
SzymczakJ Apr 22, 2024
4f6ee19
add spanish translations
SzymczakJ Apr 22, 2024
0486463
merge main
SzymczakJ Apr 24, 2024
f989cea
fix PR comments
SzymczakJ Apr 24, 2024
f114894
fix navigation bugs
SzymczakJ Apr 24, 2024
d542600
remove redundant types
SzymczakJ Apr 24, 2024
c7a0f12
fix ExpensifyCardPage bug
SzymczakJ Apr 25, 2024
0458752
fix pr comments
SzymczakJ Apr 26, 2024
f915905
fix lint errors
SzymczakJ Apr 26, 2024
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
16 changes: 8 additions & 8 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ const ROUTES = {
SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links',
SETTINGS_WALLET: 'settings/wallet',
SETTINGS_WALLET_DOMAINCARD: {
route: 'settings/wallet/card/:domain/:cardId',
getRoute: (domain: string, cardId: string) => `settings/wallet/card/${domain}/${cardId}` as const,
route: 'settings/wallet/card/:domain/:cardID',
getRoute: (domain: string, cardID: string) => `settings/wallet/card/${domain}/${cardID}` as const,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious to know why we include cardID also in the route when a domain can have multiple cards (and hence multiple cardIDs). Shouldn’t it be without the cardID just like how it was before i.e. settings/wallet/card/:domain or am I missing something here? This also seems to introduce an issue where reporting of Virtual card fraud or loss of physical card would show up the route with incorrect cardID. Here is a test video to demonstrate this:

38468-reporting-issue.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, dunno why I didn't think of that before

},
SETTINGS_REPORT_FRAUD: {
route: 'settings/wallet/card/:domain/:cardId/report-virtual-fraud',
getRoute: (domain: string, cardId: string) => `settings/wallet/card/${domain}/${cardId}/report-virtual-fraud` as const,
route: 'settings/wallet/card/:domain/:cardID/report-virtual-fraud',
getRoute: (domain: string, cardID: string) => `settings/wallet/card/${domain}/${cardID}/report-virtual-fraud` as const,
},
SETTINGS_WALLET_CARD_GET_PHYSICAL_NAME: {
route: 'settings/wallet/card/:domain/get-physical/name',
Expand Down Expand Up @@ -118,12 +118,12 @@ const ROUTES = {
SETTINGS_WALLET_TRANSFER_BALANCE: 'settings/wallet/transfer-balance',
SETTINGS_WALLET_CHOOSE_TRANSFER_ACCOUNT: 'settings/wallet/choose-transfer-account',
SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED: {
route: 'settings/wallet/card/:domain/:cardId/report-card-lost-or-damaged',
getRoute: (domain: string, cardId: string) => `settings/wallet/card/${domain}/${cardId}/report-card-lost-or-damaged` as const,
route: 'settings/wallet/card/:domain/:cardID/report-card-lost-or-damaged',
getRoute: (domain: string, cardID: string) => `settings/wallet/card/${domain}/${cardID}/report-card-lost-or-damaged` as const,
},
SETTINGS_WALLET_CARD_ACTIVATE: {
route: 'settings/wallet/card/:domain/:cardId/activate',
getRoute: (domain: string, cardId: string) => `settings/wallet/card/${domain}/${cardId}/activate` as const,
route: 'settings/wallet/card/:domain/:cardID/activate',
getRoute: (domain: string, cardID: string) => `settings/wallet/card/${domain}/${cardID}/activate` as const,
},
SETTINGS_LEGAL_NAME: 'settings/profile/legal-name',
SETTINGS_DATE_OF_BIRTH: 'settings/profile/date-of-birth',
Expand Down
16 changes: 8 additions & 8 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.WALLET.DOMAIN_CARD]: {
/** domain of selected card */
domain: string;
/** cardId of selected card */
cardId: string;
/** cardID of selected card */
cardID: string;
};
[SCREENS.SETTINGS.WALLET.REPORT_VIRTUAL_CARD_FRAUD]: {
/** domain of selected card */
domain: string;
/** cardId of selected card */
cardId: string;
/** cardID of selected card */
cardID: string;
};
[SCREENS.SETTINGS.WALLET.CARD_ACTIVATE]: {
/** domain of selected card */
domain: string;
/** cardId of selected card */
cardId: string;
/** cardID of selected card */
cardID: string;
};
[SCREENS.SETTINGS.WALLET.CARD_GET_PHYSICAL.NAME]: {
/** domain of selected card */
Expand Down Expand Up @@ -268,8 +268,8 @@ type SettingsNavigatorParamList = {
[SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: {
/** domain of selected card */
domain: string;
/** cardId of selected card */
cardId: string;
/** cardID of selected card */
cardID: string;
};
[SCREENS.KEYBOARD_SHORTCUTS]: undefined;
[SCREENS.SETTINGS.EXIT_SURVEY.REASON]: undefined;
Expand Down
17 changes: 10 additions & 7 deletions src/pages/settings/Wallet/ActivatePhysicalCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const MAGIC_INPUT_MIN_HEIGHT = 86;
function ActivatePhysicalCardPage({
cardList,
route: {
params: {domain = '', cardId = ''},
params: {domain = '', cardID = ''},
},
}: ActivatePhysicalCardPageProps) {
const theme = useTheme();
Expand All @@ -69,12 +69,15 @@ function ActivatePhysicalCardPage({
return;
}

Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardId));
}, [cardId, cardList, domain, physicalCard?.isLoading, physicalCard?.state]);
Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardID));
}, [cardID, cardList, domain, physicalCard?.isLoading, physicalCard?.state]);

useEffect(
() => () => {
CardSettings.clearCardListErrors(physicalCard?.cardID ?? 0);
if (!physicalCard?.cardID) {
return;
}
CardSettings.clearCardListErrors(physicalCard?.cardID);
},
[physicalCard?.cardID],
);
Expand All @@ -93,8 +96,8 @@ function ActivatePhysicalCardPage({
const onCodeInput = (text: string) => {
setFormError('');

if (cardError) {
CardSettings.clearCardListErrors(physicalCard?.cardID ?? 0);
if (cardError && physicalCard?.cardID) {
CardSettings.clearCardListErrors(physicalCard?.cardID);
}

setLastFourDigits(text);
Expand All @@ -118,7 +121,7 @@ function ActivatePhysicalCardPage({
return (
<IllustratedHeaderPageLayout
title={translate('activateCardPage.activateCard')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardId))}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardID))}
backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.PREFERENCES.ROOT].backgroundColor}
illustration={LottieAnimations.Magician}
scrollViewContainerStyles={[styles.mnh100]}
Expand Down
30 changes: 15 additions & 15 deletions src/pages/settings/Wallet/ExpensifyCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ function ExpensifyCardPage({
privatePersonalDetails,
loginList,
route: {
params: {domain = '', cardId = ''},
params: {domain = '', cardID = ''},
},
}: ExpensifyCardPageProps) {
const styles = useThemeStyles();
const {isOffline} = useNetwork();
const {translate} = useLocalize();
const shouldDisplayCardDomain = !cardList?.[cardId].nameValuePairs?.issuedBy;
const pageTitle = shouldDisplayCardDomain ? translate('cardPage.expensifyCard') : cardList?.[cardId].nameValuePairs?.cardTitle ?? translate('cardPage.expensifyCard');
const shouldDisplayCardDomain = !cardList?.[cardID].nameValuePairs?.issuedBy;
const pageTitle = shouldDisplayCardDomain ? translate('cardPage.expensifyCard') : cardList?.[cardID].nameValuePairs?.cardTitle ?? translate('cardPage.expensifyCard');

const [isNotFound, setIsNotFound] = useState(false);
const cardsToShow = useMemo(() => {
if (shouldDisplayCardDomain) {
return CardUtils.getDomainCards(cardList)[domain].filter((card) => !card.nameValuePairs?.issuedBy);
}
return [cardList?.[cardId]];
}, [shouldDisplayCardDomain, cardList, cardId, domain]);
return [cardList?.[cardID]];
}, [shouldDisplayCardDomain, cardList, cardID, domain]);
useEffect(() => {
setIsNotFound(!cardsToShow);
}, [cardList, cardsToShow]);
Expand All @@ -104,30 +104,30 @@ function ExpensifyCardPage({
const [isCardDetailsLoading, setIsCardDetailsLoading] = useState<Record<number, boolean>>({});
const [cardsDetailsErrors, setCardsDetailsErrors] = useState<Record<number, string>>({});

const handleRevealDetails = (revealedCardId: number) => {
const handleRevealDetails = (revealedcardID: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

revealedCardID

Copy link
Contributor

Choose a reason for hiding this comment

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

(camel case)

setIsCardDetailsLoading((prevState: Record<number, boolean>) => ({
...prevState,
[revealedCardId]: true,
[revealedcardID]: true,
}));
// We can't store the response in Onyx for security reasons.
// That is why this action is handled manually and the response is stored in a local state
// Hence eslint disable here.
// eslint-disable-next-line rulesdir/no-thenable-actions-in-views
Card.revealVirtualCardDetails(revealedCardId)
Card.revealVirtualCardDetails(revealedcardID)
.then((value) => {
setCardsDetails((prevState: Record<number, TCardDetails | null>) => ({...prevState, [revealedCardId]: value as TCardDetails}));
setCardsDetails((prevState: Record<number, TCardDetails | null>) => ({...prevState, [revealedcardID]: value as TCardDetails}));
setCardsDetailsErrors((prevState) => ({
...prevState,
[revealedCardId]: '',
[revealedcardID]: '',
}));
})
.catch((error) => {
setCardsDetailsErrors((prevState) => ({
...prevState,
[revealedCardId]: error,
[revealedcardID]: error,
}));
})
.finally(() => setIsCardDetailsLoading((prevState: Record<number, boolean>) => ({...prevState, [revealedCardId]: false})));
.finally(() => setIsCardDetailsLoading((prevState: Record<number, boolean>) => ({...prevState, [revealedcardID]: false})));
};

const hasDetectedDomainFraud = cardsToShow?.some((card) => card?.fraud === CONST.EXPENSIFY_CARD.FRAUD_TYPES.DOMAIN);
Expand Down Expand Up @@ -249,7 +249,7 @@ function ExpensifyCardPage({
titleStyle={styles.walletCardMenuItem}
icon={Expensicons.Flag}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_REPORT_FRAUD.getRoute(domain, cardId))}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_REPORT_FRAUD.getRoute(domain, cardID))}
/>
</>
))}
Expand All @@ -269,7 +269,7 @@ function ExpensifyCardPage({
title={translate('reportCardLostOrDamaged.report')}
icon={Expensicons.Flag}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.getRoute(domain, cardId))}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.getRoute(domain, cardID))}
/>
</>
);
Expand All @@ -282,7 +282,7 @@ function ExpensifyCardPage({
success
large
style={[styles.w100, styles.p5]}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.getRoute(domain, cardId))}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.getRoute(domain, cardID))}
text={translate('activateCardPage.activatePhysicalCard')}
/>
)}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/settings/Wallet/ReportCardLostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ function ReportCardLostPage({
},
cardList = {},
route: {
params: {domain = '', cardId = ''},
params: {domain = '', cardID = ''},
},
formData,
}: ReportCardLostPageProps) {
const styles = useThemeStyles();
usePrivatePersonalDetails();

const physicalCard = cardList?.[cardId];
const physicalCard = cardList?.[cardID];

const {translate} = useLocalize();

Expand All @@ -101,8 +101,8 @@ function ReportCardLostPage({
return;
}

Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardId));
}, [domain, formData?.isLoading, prevIsLoading, physicalCard?.errors, cardId]);
Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardID));
}, [domain, formData?.isLoading, prevIsLoading, physicalCard?.errors, cardID]);

useEffect(() => {
if (formData?.isLoading && isEmptyObject(physicalCard?.errors)) {
Expand Down
10 changes: 5 additions & 5 deletions src/pages/settings/Wallet/ReportVirtualCardFraudPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ type ReportVirtualCardFraudPageProps = ReportVirtualCardFraudPageOnyxProps & Sta

function ReportVirtualCardFraudPage({
route: {
params: {domain = '', cardId = ''},
params: {domain = '', cardID = ''},
},
cardList,
formData,
}: ReportVirtualCardFraudPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

const virtualCard = cardList?.[cardId];
const virtualCard = cardList?.[cardID];
const virtualCardError = ErrorUtils.getLatestErrorMessage(virtualCard?.errors ?? {});

const prevIsLoading = usePrevious(formData?.isLoading);
Expand All @@ -55,8 +55,8 @@ function ReportVirtualCardFraudPage({
return;
}

Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardId));
}, [cardId, domain, formData?.isLoading, prevIsLoading, virtualCard?.errors]);
Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardID));
}, [cardID, domain, formData?.isLoading, prevIsLoading, virtualCard?.errors]);

if (isEmptyObject(virtualCard)) {
return <NotFoundPage />;
Expand All @@ -66,7 +66,7 @@ function ReportVirtualCardFraudPage({
<ScreenWrapper testID={ReportVirtualCardFraudPage.displayName}>
<HeaderWithBackButton
title={translate('reportFraudPage.title')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardId))}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(domain, cardID))}
/>
<View style={[styles.flex1, styles.justifyContentBetween]}>
<Text style={[styles.webViewStyles.baseFontStyle, styles.mh5]}>{translate('reportFraudPage.description')}</Text>
Expand Down
Loading