From 0274f11dfd55bdf48b18f21fccbf58ff432ba130 Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 27 Sep 2023 13:28:22 +0200 Subject: [PATCH 01/12] =?UTF-8?q?add=20=E2=80=9CReport=20virtual=20card=20?= =?UTF-8?q?fraud=E2=80=9D=20page=20and=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ONYXKEYS.ts | 1 + src/ROUTES.ts | 4 + src/languages/en.ts | 7 ++ src/languages/es.ts | 8 ++ .../AppNavigator/ModalStackNavigators.js | 1 + src/libs/Navigation/linkingConfig.js | 4 + src/libs/actions/Card.js | 49 ++++++++ .../settings/Wallet/ExpensifyCardPage.js | 26 +++-- src/pages/settings/Wallet/ReportFraudPage.js | 110 ++++++++++++++++++ src/styles/styles.js | 2 +- 10 files changed, 203 insertions(+), 9 deletions(-) create mode 100644 src/libs/actions/Card.js create mode 100644 src/pages/settings/Wallet/ReportFraudPage.js diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 6649a33fe15e..c3fbcd457555 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -291,6 +291,7 @@ const ONYXKEYS = { PRIVATE_NOTES_FORM: 'privateNotesForm', I_KNOW_A_TEACHER_FORM: 'iKnowTeacherForm', INTRO_SCHOOL_PRINCIPAL_FORM: 'introSchoolPrincipalForm', + REPORT_FRAUD_FORM: 'reportFraudForm', }, } as const; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 1b2e9330869f..9d8792802954 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -76,6 +76,10 @@ export default { route: '/settings/wallet/card/:domain', getRoute: (domain: string) => `/settings/wallet/card/${domain}`, }, + SETTINGS_REPORT_FRAUD: { + route: '/settings/wallet/cards/:domain/report-digital-fraud', + getRoute: (domain: string) => `/settings/wallet/cards/${domain}/report-digital-fraud`, + }, SETTINGS_ADD_DEBIT_CARD: 'settings/wallet/add-debit-card', SETTINGS_ADD_BANK_ACCOUNT: 'settings/wallet/add-bank-account', SETTINGS_ENABLE_PAYMENTS: 'settings/wallet/enable-payments', diff --git a/src/languages/en.ts b/src/languages/en.ts index 403931d542f3..0736f6ec6f07 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -814,6 +814,13 @@ export default { availableSpend: 'Remaining spending power', virtualCardNumber: 'Virtual card number', physicalCardNumber: 'Physical card number', + reportFraud: 'Report virtual card fraud', + }, + reportFraudPage: { + title: 'Report virtual card fraud', + description: 'If your virtual card details have been stolen or compromised, we’ll permanently deactivate your existing card and provide you with a new virtual card and number.', + deactivateCard: 'Deactivate card', + reportVirtualCardFraud: 'Report virtual card fraud', }, transferAmountPage: { transfer: ({amount}: TransferParams) => `Transfer${amount ? ` ${amount}` : ''}`, diff --git a/src/languages/es.ts b/src/languages/es.ts index ffe334f4a807..60bd0dcc5653 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -809,6 +809,14 @@ export default { availableSpend: 'Capacidad de gasto restante', virtualCardNumber: 'Número de la tarjeta virtual', physicalCardNumber: 'Número de la tarjeta física', + reportFraud: 'Reportar fraude con la tarjeta virtual', + }, + reportFraudPage: { + title: 'Reportar fraude con la tarjeta virtual', + description: + 'Si los datos de tu tarjeta virtual han sido robados o se han visto comprometidos, desactivaremos permanentemente la tarjeta actual y le proporcionaremos una tarjeta virtual y un número nuevo.', + deactivateCard: 'Desactivar tarjeta', + reportVirtualCardFraud: 'Reportar fraude con la tarjeta virtual', }, transferAmountPage: { transfer: ({amount}: TransferParams) => `Transferir${amount ? ` ${amount}` : ''}`, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js index fc284f566c80..98ec7d4a14b3 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js @@ -141,6 +141,7 @@ const SettingsModalStackNavigator = createModalStackNavigator({ Settings_Lounge_Access: () => require('../../../pages/settings/Profile/LoungeAccessPage').default, Settings_Wallet: () => require('../../../pages/settings/Wallet/WalletPage').default, Settings_Wallet_DomainCards: () => require('../../../pages/settings/Wallet/ExpensifyCardPage').default, + Settings_Report_Fraud: () => require('../../../pages/settings/Wallet/ReportFraudPage').default, Settings_Wallet_Transfer_Balance: () => require('../../../pages/settings/Wallet/TransferBalancePage').default, Settings_Wallet_Choose_Transfer_Account: () => require('../../../pages/settings/Wallet/ChooseTransferAccountPage').default, Settings_Wallet_EnablePayments: () => require('../../../pages/EnablePayments/EnablePaymentsPage').default, diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index d13f30822bb9..430bbb1fc362 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -73,6 +73,10 @@ export default { path: ROUTES.SETTINGS_WALLET_DOMAINCARDS.route, exact: true, }, + Settings_Report_Fraud: { + path: ROUTES.SETTINGS_REPORT_FRAUD.route, + exact: true, + }, Settings_Wallet_EnablePayments: { path: ROUTES.SETTINGS_ENABLE_PAYMENTS, exact: true, diff --git a/src/libs/actions/Card.js b/src/libs/actions/Card.js new file mode 100644 index 000000000000..cc3021d4260d --- /dev/null +++ b/src/libs/actions/Card.js @@ -0,0 +1,49 @@ +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '../../ONYXKEYS'; +import * as API from '../API'; + +/** + * @param {Number} cardID + */ +function reportDigitalExpensifyCardFraud(cardID) { + API.write( + 'ReportDigitalExpensifyCardFraud', + { + cardID, + }, + { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + value: { + isLoading: true, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + value: { + isLoading: false, + }, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + value: { + isLoading: false, + }, + }, + ], + }, + ); +} + +export { + // eslint-disable-next-line import/prefer-default-export + reportDigitalExpensifyCardFraud, +}; diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index bc49301e8d80..b57d73cce673 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -15,6 +15,7 @@ import useLocalize from '../../../hooks/useLocalize'; import * as CurrencyUtils from '../../../libs/CurrencyUtils'; import Navigation from '../../../libs/Navigation/Navigation'; import styles from '../../../styles/styles'; +import * as Expensicons from '../../../components/Icon/Expensicons'; import * as CardUtils from '../../../libs/CardUtils'; const propTypes = { @@ -73,20 +74,29 @@ function ExpensifyCardPage({ interactive={false} titleStyle={styles.newKansasLarge} /> - {!_.isEmpty(physicalCard) && ( - + {!_.isEmpty(virtualCard) && ( + <> + + Navigation.navigate(ROUTES.SETTINGS_REPORT_FRAUD.getRoute(domain))} + /> + )} {!_.isEmpty(physicalCard) && ( )} diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js new file mode 100644 index 000000000000..c05b0a6472b4 --- /dev/null +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -0,0 +1,110 @@ +import React, {useEffect} from 'react'; +import _ from 'underscore'; +import PropTypes from 'prop-types'; +import {withOnyx} from 'react-native-onyx'; +import ROUTES from '../../../ROUTES'; +import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; +import ScreenWrapper from '../../../components/ScreenWrapper'; +import Navigation from '../../../libs/Navigation/Navigation'; +import styles from '../../../styles/styles'; +import Text from '../../../components/Text'; +import useLocalize from '../../../hooks/useLocalize'; +import * as Card from '../../../libs/actions/Card'; +import assignedCardPropTypes from './assignedCardPropTypes'; +import * as CardUtils from '../../../libs/CardUtils'; +import ONYXKEYS from '../../../ONYXKEYS'; +import NotFoundPage from '../../ErrorPage/NotFoundPage'; +import Form from '../../../components/Form'; +import usePrevious from '../../../hooks/usePrevious'; +import * as FormActions from '../../../libs/actions/FormActions'; + +const propTypes = { + /* Onyx Props */ + formData: PropTypes.shape({ + isLoading: PropTypes.bool, + }), + cardList: PropTypes.objectOf(assignedCardPropTypes), + /** The parameters needed to authenticate with a short-lived token are in the URL */ + route: PropTypes.shape({ + /** Each parameter passed via the URL */ + params: PropTypes.shape({ + /** Domain string */ + domain: PropTypes.string, + }), + }).isRequired, +}; + +const defaultProps = { + cardList: {}, + formData: {}, +}; + +function ReportFraudPage({ + route: { + params: {domain}, + }, + cardList, + formData, +}) { + const {translate} = useLocalize(); + + const domainCards = CardUtils.getDomainCards(cardList)[domain]; + const virtualCard = _.find(domainCards, (card) => card.isVirtual) || {}; + + const prevIsLoading = usePrevious(formData.isLoading); + + useEffect(() => { + if (prevIsLoading && formData.isLoading === false && _.isEmpty(virtualCard.errors)) { + Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain)); + } + + if (formData.isLoading !== false && _.isEmpty(virtualCard.errors)) { + return; + } + + FormActions.setErrors(ONYXKEYS.FORMS.REPORT_FRAUD_FORM, virtualCard.errors); + }, [domain, formData.isLoading, prevIsLoading, virtualCard.errors]); + + const submitReportFraud = () => { + Card.reportDigitalExpensifyCardFraud(virtualCard.cardID); + }; + + const onBackButtonPress = () => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain)); + + if (_.isEmpty(virtualCard)) { + return ; + } + + return ( + + +
+ {translate('reportFraudPage.description')} +
+
+ ); +} + +ReportFraudPage.propTypes = propTypes; +ReportFraudPage.defaultProps = defaultProps; +ReportFraudPage.displayName = 'ReportFraudPage'; + +export default withOnyx({ + cardList: { + key: ONYXKEYS.CARD_LIST, + }, + formData: { + key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + }, +})(ReportFraudPage); diff --git a/src/styles/styles.js b/src/styles/styles.js index 7bba63c8f09f..5360b97233e3 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3680,7 +3680,7 @@ const styles = (theme) => ({ overflow: 'hidden', }, - walletCardNumber: { + walletCardMenuItem: { color: theme.text, fontSize: variables.fontSizeNormal, }, From 46ecfe13d91815594653f9f8cf0d7c5f03700e76 Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Wed, 4 Oct 2023 14:07:18 +0200 Subject: [PATCH 02/12] inline function --- src/pages/settings/Wallet/ReportFraudPage.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js index c05b0a6472b4..b51ab11f1f51 100644 --- a/src/pages/settings/Wallet/ReportFraudPage.js +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -69,7 +69,9 @@ function ReportFraudPage({ Card.reportDigitalExpensifyCardFraud(virtualCard.cardID); }; - const onBackButtonPress = () => Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain)); + const onBackButtonPress = () => { + Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain)); + }; if (_.isEmpty(virtualCard)) { return ; From c6f67913b3060f6997dc6ab79591088498ce78fc Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Wed, 4 Oct 2023 14:16:04 +0200 Subject: [PATCH 03/12] inline function correctly --- src/pages/settings/Wallet/ReportFraudPage.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js index b51ab11f1f51..6430e7c735c2 100644 --- a/src/pages/settings/Wallet/ReportFraudPage.js +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -65,14 +65,6 @@ function ReportFraudPage({ FormActions.setErrors(ONYXKEYS.FORMS.REPORT_FRAUD_FORM, virtualCard.errors); }, [domain, formData.isLoading, prevIsLoading, virtualCard.errors]); - const submitReportFraud = () => { - Card.reportDigitalExpensifyCardFraud(virtualCard.cardID); - }; - - const onBackButtonPress = () => { - Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain)); - }; - if (_.isEmpty(virtualCard)) { return ; } @@ -84,12 +76,12 @@ function ReportFraudPage({ > Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain))} />
Card.reportDigitalExpensifyCardFraud(virtualCard.cardID)} submitButtonText={translate('reportFraudPage.deactivateCard')} > {translate('reportFraudPage.description')} From 716775c8f7cf85efdf9b490e71b3ec7bd3df2b3e Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Wed, 4 Oct 2023 15:45:50 +0200 Subject: [PATCH 04/12] replace Form with FormAlertWithSubmitButton --- src/pages/settings/Wallet/ReportFraudPage.js | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js index 6430e7c735c2..db4452f33939 100644 --- a/src/pages/settings/Wallet/ReportFraudPage.js +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -1,5 +1,6 @@ import React, {useEffect} from 'react'; import _ from 'underscore'; +import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; import ROUTES from '../../../ROUTES'; @@ -14,9 +15,10 @@ import assignedCardPropTypes from './assignedCardPropTypes'; import * as CardUtils from '../../../libs/CardUtils'; import ONYXKEYS from '../../../ONYXKEYS'; import NotFoundPage from '../../ErrorPage/NotFoundPage'; -import Form from '../../../components/Form'; import usePrevious from '../../../hooks/usePrevious'; import * as FormActions from '../../../libs/actions/FormActions'; +import FormAlertWithSubmitButton from '../../../components/FormAlertWithSubmitButton'; +import * as ErrorUtils from '../../../libs/ErrorUtils'; const propTypes = { /* Onyx Props */ @@ -50,6 +52,7 @@ function ReportFraudPage({ const domainCards = CardUtils.getDomainCards(cardList)[domain]; const virtualCard = _.find(domainCards, (card) => card.isVirtual) || {}; + const virtualCardError = ErrorUtils.getLatestErrorMessage(virtualCard) || ''; const prevIsLoading = usePrevious(formData.isLoading); @@ -71,21 +74,23 @@ function ReportFraudPage({ return ( Navigation.goBack(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain))} /> - Card.reportDigitalExpensifyCardFraud(virtualCard.cardID)} - submitButtonText={translate('reportFraudPage.deactivateCard')} - > - {translate('reportFraudPage.description')} - + + {translate('reportFraudPage.description')} + Card.reportDigitalExpensifyCardFraud(virtualCard.cardID)} + message={virtualCardError} + isLoading={formData.isLoading} + buttonText={translate('reportFraudPage.deactivateCard')} + /> + ); } From a40ddf622015faa0e01f8eb5ea2e26fee2af7d0b Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Wed, 4 Oct 2023 15:54:49 +0200 Subject: [PATCH 05/12] rename route --- src/libs/Navigation/AppNavigator/ModalStackNavigators.js | 2 +- src/libs/Navigation/linkingConfig.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js index 98ec7d4a14b3..e7a4e0689cf0 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js @@ -141,7 +141,7 @@ const SettingsModalStackNavigator = createModalStackNavigator({ Settings_Lounge_Access: () => require('../../../pages/settings/Profile/LoungeAccessPage').default, Settings_Wallet: () => require('../../../pages/settings/Wallet/WalletPage').default, Settings_Wallet_DomainCards: () => require('../../../pages/settings/Wallet/ExpensifyCardPage').default, - Settings_Report_Fraud: () => require('../../../pages/settings/Wallet/ReportFraudPage').default, + Settings_Wallet_ReportVirtualCardFraud: () => require('../../../pages/settings/Wallet/ReportFraudPage').default, Settings_Wallet_Transfer_Balance: () => require('../../../pages/settings/Wallet/TransferBalancePage').default, Settings_Wallet_Choose_Transfer_Account: () => require('../../../pages/settings/Wallet/ChooseTransferAccountPage').default, Settings_Wallet_EnablePayments: () => require('../../../pages/EnablePayments/EnablePaymentsPage').default, diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 430bbb1fc362..60f48a97de27 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -73,7 +73,7 @@ export default { path: ROUTES.SETTINGS_WALLET_DOMAINCARDS.route, exact: true, }, - Settings_Report_Fraud: { + Settings_Wallet_ReportVirtualCardFraud: { path: ROUTES.SETTINGS_REPORT_FRAUD.route, exact: true, }, From 48528c90409566f0953b9cf467818750a4d920ed Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Wed, 4 Oct 2023 15:58:59 +0200 Subject: [PATCH 06/12] rename digital to virtual --- src/ROUTES.ts | 4 ++-- src/libs/actions/Card.js | 6 +++--- src/pages/settings/Wallet/ReportFraudPage.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 9d8792802954..3aa3cd1d9955 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -77,8 +77,8 @@ export default { getRoute: (domain: string) => `/settings/wallet/card/${domain}`, }, SETTINGS_REPORT_FRAUD: { - route: '/settings/wallet/cards/:domain/report-digital-fraud', - getRoute: (domain: string) => `/settings/wallet/cards/${domain}/report-digital-fraud`, + route: '/settings/wallet/cards/:domain/report-virtual-fraud', + getRoute: (domain: string) => `/settings/wallet/cards/${domain}/report-virtual-fraud`, }, SETTINGS_ADD_DEBIT_CARD: 'settings/wallet/add-debit-card', SETTINGS_ADD_BANK_ACCOUNT: 'settings/wallet/add-bank-account', diff --git a/src/libs/actions/Card.js b/src/libs/actions/Card.js index cc3021d4260d..6796787c38ce 100644 --- a/src/libs/actions/Card.js +++ b/src/libs/actions/Card.js @@ -5,9 +5,9 @@ import * as API from '../API'; /** * @param {Number} cardID */ -function reportDigitalExpensifyCardFraud(cardID) { +function reportVirtualExpensifyCardFraud(cardID) { API.write( - 'ReportDigitalExpensifyCardFraud', + 'ReportVirtualExpensifyCardFraud', { cardID, }, @@ -45,5 +45,5 @@ function reportDigitalExpensifyCardFraud(cardID) { export { // eslint-disable-next-line import/prefer-default-export - reportDigitalExpensifyCardFraud, + reportVirtualExpensifyCardFraud, }; diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js index db4452f33939..2222723f511a 100644 --- a/src/pages/settings/Wallet/ReportFraudPage.js +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -85,7 +85,7 @@ function ReportFraudPage({ {translate('reportFraudPage.description')} Card.reportDigitalExpensifyCardFraud(virtualCard.cardID)} + onSubmit={() => Card.reportVirtualExpensifyCardFraud(virtualCard.cardID)} message={virtualCardError} isLoading={formData.isLoading} buttonText={translate('reportFraudPage.deactivateCard')} From 963509fdf0f677485f925423188ce4482045c741 Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Wed, 4 Oct 2023 16:01:49 +0200 Subject: [PATCH 07/12] rename onyx key --- src/ONYXKEYS.ts | 2 +- src/libs/actions/Card.js | 6 +++--- src/pages/settings/Wallet/ReportFraudPage.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index c3fbcd457555..caf5b87cfb0d 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -291,7 +291,7 @@ const ONYXKEYS = { PRIVATE_NOTES_FORM: 'privateNotesForm', I_KNOW_A_TEACHER_FORM: 'iKnowTeacherForm', INTRO_SCHOOL_PRINCIPAL_FORM: 'introSchoolPrincipalForm', - REPORT_FRAUD_FORM: 'reportFraudForm', + REPORT_VIRTUAL_CARD_FRAUD: 'reportFraudForm', }, } as const; diff --git a/src/libs/actions/Card.js b/src/libs/actions/Card.js index 6796787c38ce..7a19d26ca638 100644 --- a/src/libs/actions/Card.js +++ b/src/libs/actions/Card.js @@ -15,7 +15,7 @@ function reportVirtualExpensifyCardFraud(cardID) { optimisticData: [ { onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, value: { isLoading: true, }, @@ -24,7 +24,7 @@ function reportVirtualExpensifyCardFraud(cardID) { successData: [ { onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, value: { isLoading: false, }, @@ -33,7 +33,7 @@ function reportVirtualExpensifyCardFraud(cardID) { failureData: [ { onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, value: { isLoading: false, }, diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js index 2222723f511a..f7149578678a 100644 --- a/src/pages/settings/Wallet/ReportFraudPage.js +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -65,7 +65,7 @@ function ReportFraudPage({ return; } - FormActions.setErrors(ONYXKEYS.FORMS.REPORT_FRAUD_FORM, virtualCard.errors); + FormActions.setErrors(ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, virtualCard.errors); }, [domain, formData.isLoading, prevIsLoading, virtualCard.errors]); if (_.isEmpty(virtualCard)) { @@ -104,6 +104,6 @@ export default withOnyx({ key: ONYXKEYS.CARD_LIST, }, formData: { - key: ONYXKEYS.FORMS.REPORT_FRAUD_FORM, + key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, }, })(ReportFraudPage); From 4b1e552d48de97963f7ca65cae0cc7dd308439b4 Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Thu, 5 Oct 2023 09:22:39 +0200 Subject: [PATCH 08/12] modify useEffect, remove setErrors --- src/pages/settings/Wallet/ReportFraudPage.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/pages/settings/Wallet/ReportFraudPage.js b/src/pages/settings/Wallet/ReportFraudPage.js index f7149578678a..8da754c13a3c 100644 --- a/src/pages/settings/Wallet/ReportFraudPage.js +++ b/src/pages/settings/Wallet/ReportFraudPage.js @@ -16,7 +16,6 @@ import * as CardUtils from '../../../libs/CardUtils'; import ONYXKEYS from '../../../ONYXKEYS'; import NotFoundPage from '../../ErrorPage/NotFoundPage'; import usePrevious from '../../../hooks/usePrevious'; -import * as FormActions from '../../../libs/actions/FormActions'; import FormAlertWithSubmitButton from '../../../components/FormAlertWithSubmitButton'; import * as ErrorUtils from '../../../libs/ErrorUtils'; @@ -56,17 +55,12 @@ function ReportFraudPage({ const prevIsLoading = usePrevious(formData.isLoading); + // eslint-disable-next-line rulesdir/prefer-early-return useEffect(() => { if (prevIsLoading && formData.isLoading === false && _.isEmpty(virtualCard.errors)) { Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARDS.getRoute(domain)); } - - if (formData.isLoading !== false && _.isEmpty(virtualCard.errors)) { - return; - } - - FormActions.setErrors(ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, virtualCard.errors); - }, [domain, formData.isLoading, prevIsLoading, virtualCard.errors]); + }, [domain, formData, prevIsLoading, virtualCard.errors]); if (_.isEmpty(virtualCard)) { return ; From 852628c8a8aa5670f50625ec6ec88d08a008756c Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Thu, 5 Oct 2023 10:04:07 +0200 Subject: [PATCH 09/12] fix conditional rendering --- src/pages/settings/Wallet/ExpensifyCardPage.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index 6e9fbc47cf12..19ba83a0f8db 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -92,7 +92,6 @@ function ExpensifyCardPage({ cvv="321" /> ) : ( - <> } /> - Navigation.navigate(ROUTES.SETTINGS_REPORT_FRAUD.getRoute(domain))} /> - - )} )} {!_.isEmpty(physicalCard) && ( From f6a4166943f7eeec4e927df8048910a2dbaa1210 Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Fri, 6 Oct 2023 14:07:10 +0200 Subject: [PATCH 10/12] apply minor changes --- src/ONYXKEYS.ts | 2 +- .../Navigation/AppNavigator/ModalStackNavigators.js | 2 +- src/pages/settings/Wallet/ExpensifyCardPage.js | 1 - ...ortFraudPage.js => ReportVirtualCardFraudPage.js} | 12 ++++++------ 4 files changed, 8 insertions(+), 9 deletions(-) rename src/pages/settings/Wallet/{ReportFraudPage.js => ReportVirtualCardFraudPage.js} (91%) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 408385a80957..7b6335ccf984 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -291,7 +291,7 @@ const ONYXKEYS = { PRIVATE_NOTES_FORM: 'privateNotesForm', I_KNOW_A_TEACHER_FORM: 'iKnowTeacherForm', INTRO_SCHOOL_PRINCIPAL_FORM: 'introSchoolPrincipalForm', - REPORT_VIRTUAL_CARD_FRAUD: 'reportFraudForm', + REPORT_VIRTUAL_CARD_FRAUD: 'reportVirtualCardFraudForm', }, } as const; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js index f28725ea2c97..f40e799a576d 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js @@ -142,7 +142,7 @@ const SettingsModalStackNavigator = createModalStackNavigator({ Settings_Lounge_Access: () => require('../../../pages/settings/Profile/LoungeAccessPage').default, Settings_Wallet: () => require('../../../pages/settings/Wallet/WalletPage').default, Settings_Wallet_DomainCards: () => require('../../../pages/settings/Wallet/ExpensifyCardPage').default, - Settings_Wallet_ReportVirtualCardFraud: () => require('../../../pages/settings/Wallet/ReportFraudPage').default, + Settings_Wallet_ReportVirtualCardFraud: () => require('../../../pages/settings/Wallet/ReportVirtualCardFraudPage').default, Settings_Wallet_Transfer_Balance: () => require('../../../pages/settings/Wallet/TransferBalancePage').default, Settings_Wallet_Choose_Transfer_Account: () => require('../../../pages/settings/Wallet/ChooseTransferAccountPage').default, Settings_Wallet_EnablePayments: () => require('../../../pages/EnablePayments/EnablePaymentsPage').default, diff --git a/src/pages/settings/Wallet/ExpensifyCardPage.js b/src/pages/settings/Wallet/ExpensifyCardPage.js index 19ba83a0f8db..4fd60348ba3d 100644 --- a/src/pages/settings/Wallet/ExpensifyCardPage.js +++ b/src/pages/settings/Wallet/ExpensifyCardPage.js @@ -97,7 +97,6 @@ function ExpensifyCardPage({ title={CardUtils.maskCard(virtualCard.lastFourPAN)} interactive={false} titleStyle={styles.walletCardNumber} - // titleStyle={styles.walletCardMenuItem} shouldShowRightComponent rightComponent={