From 489cddc780c4961d8a446b0a825457beac455b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20M=C3=B3rawski?= Date: Mon, 6 Nov 2023 10:59:37 +0100 Subject: [PATCH 1/8] error handling --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/actions/Card.js | 5 +- .../settings/Wallet/ExpensifyCardPage.js | 90 +++++++++++-------- src/styles/fontFamily/multiFontFamily.ts | 4 +- 5 files changed, 62 insertions(+), 39 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index c186a1fffedf..29f4adfa5006 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -888,6 +888,7 @@ export default { copyCardNumber: 'Copy card number', updateAddress: 'Update address', }, + cardDetailsLoadingFailure: 'An error occurred while loading the card details. Please check your internet connection and try again.', }, reportFraudPage: { title: 'Report virtual card fraud', diff --git a/src/languages/es.ts b/src/languages/es.ts index a0a30bcf4141..99c8b68dc7b1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -883,6 +883,7 @@ export default { copyCardNumber: 'Copiar número de la tarjeta', updateAddress: 'Actualizar dirección', }, + cardDetailsLoadingFailure: 'An error occurred while loading the card details. Please check your internet connection and try again.', }, reportFraudPage: { title: 'Reportar fraude con la tarjeta virtual', diff --git a/src/libs/actions/Card.js b/src/libs/actions/Card.js index 5e94a7ed2b65..9adcd3803766 100644 --- a/src/libs/actions/Card.js +++ b/src/libs/actions/Card.js @@ -1,5 +1,6 @@ import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; +import * as Localize from '@libs/Localize'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -163,12 +164,12 @@ function revealVirtualCardDetails(cardID) { API.makeRequestWithSideEffects('RevealExpensifyCardDetails', {cardID}) .then((response) => { if (response.jsonCode !== CONST.JSON_CODE.SUCCESS) { - reject(); + reject(Localize.translateLocal('cardPage.cardDetailsLoadingFailure')); return; } resolve(response); }) - .catch(reject); + .catch(() => reject(Localize.translateLocal('cardPage.cardDetailsLoadingFailure'))); }); } diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index d6cdbefc471a..fdb4482abe12 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -60,6 +60,7 @@ function ExpensifyCardPage({ const [isLoading, setIsLoading] = useState(false); const [details, setDetails] = useState({}); + const [cardDetailsError, setCardDetailsError] = useState(''); if (_.isEmpty(virtualCard) && _.isEmpty(physicalCard)) { return ; @@ -70,16 +71,21 @@ function ExpensifyCardPage({ const handleRevealDetails = () => { setIsLoading(true); // We can't store the response in Onyx for security reasons. - // That is this action is handled manually and the response is stored in a local state - // Hence the eslint disable here. + // 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(virtualCard.cardID) - .then(setDetails) + .then((val) => { + setDetails(val); + setCardDetailsError(''); + }) + .catch(setCardDetailsError) .finally(() => setIsLoading(false)); }; const hasDetectedDomainFraud = _.some(domainCards, (card) => card.fraud === CONST.EXPENSIFY_CARD.FRAUD_TYPES.DOMAIN); const hasDetectedIndividualFraud = _.some(domainCards, (card) => card.fraud === CONST.EXPENSIFY_CARD.FRAUD_TYPES.INDIVIDUAL); + const cardDetailsErrorObject = cardDetailsError ? {error: cardDetailsError} : {}; return ( ) : ( - - } - /> + <> + + } + /> + + )} ) : ( - - } - /> + <> + + } + /> + + )} Date: Tue, 7 Nov 2023 10:06:39 +0100 Subject: [PATCH 2/8] spanish translation --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 99c8b68dc7b1..00f6c7fe7355 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -883,7 +883,7 @@ export default { copyCardNumber: 'Copiar número de la tarjeta', updateAddress: 'Actualizar dirección', }, - cardDetailsLoadingFailure: 'An error occurred while loading the card details. Please check your internet connection and try again.', + cardDetailsLoadingFailure: 'Se ha producido un error al cargar los datos de la tarjeta. Comprueba tu conexión a Internet e inténtalo de nuevo.', }, reportFraudPage: { title: 'Reportar fraude con la tarjeta virtual', From bf35c29b74e548b9fa7128e51658df039fb6d492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20M=C3=B3rawski?= Date: Tue, 7 Nov 2023 10:06:53 +0100 Subject: [PATCH 3/8] prettier --- src/styles/fontFamily/multiFontFamily.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/fontFamily/multiFontFamily.ts b/src/styles/fontFamily/multiFontFamily.ts index b6b74ad68dfc..5bd89e0d4bcb 100644 --- a/src/styles/fontFamily/multiFontFamily.ts +++ b/src/styles/fontFamily/multiFontFamily.ts @@ -1,5 +1,5 @@ -import CONST from '@src/CONST'; import getOperatingSystem from '@libs/getOperatingSystem'; +import CONST from '@src/CONST'; import {multiBold} from './bold'; import FontFamilyStyles from './types'; From 99a23384b68f79ce5fac3f6a92f21581c98c27c0 Mon Sep 17 00:00:00 2001 From: lukemorawski <134388952+lukemorawski@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:47:48 +0100 Subject: [PATCH 4/8] remove unnecessary brackets Co-authored-by: VickyStash --- src/pages/settings/Wallet/ExpensifyCardPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index fdb4482abe12..0c65a79d6c91 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -143,7 +143,7 @@ function ExpensifyCardPage({ )} From c15318c82246e5a7f37fc7688c17a7bebec267d7 Mon Sep 17 00:00:00 2001 From: lukemorawski <134388952+lukemorawski@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:48:01 +0100 Subject: [PATCH 5/8] remove unnecessary brackets Co-authored-by: VickyStash --- src/pages/settings/Wallet/ExpensifyCardPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index 0c65a79d6c91..a1e1d8873144 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -202,7 +202,7 @@ function ExpensifyCardPage({ )} From cb309071c4ee72a6ecac512807944ed7cd02114e Mon Sep 17 00:00:00 2001 From: lukemorawski <134388952+lukemorawski@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:24:19 +0100 Subject: [PATCH 6/8] param name change Co-authored-by: Michael (Mykhailo) Kravchenko --- src/pages/settings/Wallet/ExpensifyCardPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index a1e1d8873144..3a9c7e0fb453 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -75,8 +75,8 @@ function ExpensifyCardPage({ // Hence eslint disable here. // eslint-disable-next-line rulesdir/no-thenable-actions-in-views Card.revealVirtualCardDetails(virtualCard.cardID) - .then((val) => { - setDetails(val); + .then((value) => { + setDetails(value); setCardDetailsError(''); }) .catch(setCardDetailsError) From 8b3d8751c8f34321a54a2933efd61fbc0ab87ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20M=C3=B3rawski?= Date: Thu, 9 Nov 2023 11:20:56 +0100 Subject: [PATCH 7/8] removed duplicated card details section --- .../settings/Wallet/ExpensifyCardPage.js | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index 3a9c7e0fb453..ba6653b162c8 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -114,39 +114,6 @@ function ExpensifyCardPage({ {hasDetectedIndividualFraud && !hasDetectedDomainFraud ? ( <> - {details.pan ? ( - - ) : ( - <> - - } - /> - - - )} Date: Mon, 13 Nov 2023 11:18:27 +0100 Subject: [PATCH 8/8] bug fix --- src/pages/settings/Wallet/ExpensifyCardPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index ba6653b162c8..d4a104d272dd 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -169,7 +169,7 @@ function ExpensifyCardPage({ )}