From bf7f200f77300d6b2dc1251f253d3016e4d8bec7 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Fri, 20 Oct 2023 23:35:09 +0500 Subject: [PATCH 1/9] feat: show better title when onfido is pending on wallet page --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/Permissions.ts | 2 +- src/libs/actions/Wallet.js | 4 +- .../EnablePayments/EnablePaymentsPage.js | 14 +++--- .../EnablePayments/userWalletPropTypes.js | 4 +- .../settings/Wallet/WalletPage/WalletPage.js | 50 +++++++++++++------ src/types/onyx/UserWallet.ts | 4 +- 8 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 11637846130a..015f280a5fa4 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -868,6 +868,7 @@ export default { assignedCards: 'Assigned cards', assignedCardsDescription: 'These are cards assigned by a Workspace admin to manage company spend.', expensifyCard: 'Expensify Card', + walletActivationPending: "We're reviewing your information and we'll be in touch shortly.", }, cardPage: { expensifyCard: 'Expensify Card', diff --git a/src/languages/es.ts b/src/languages/es.ts index e4a5c37241f2..ec8ac464b5b2 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -864,6 +864,7 @@ export default { assignedCards: 'Tarjetas asignadas', assignedCardsDescription: 'Son tarjetas asignadas por un administrador del Espacio de Trabajo para gestionar los gastos de la empresa.', expensifyCard: 'Tarjeta Expensify', + walletActivationPending: 'Estamos revisando la informaciĆ³n y nos pondremos en contacto contigo en breve.', }, cardPage: { expensifyCard: 'Tarjeta Expensify', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 13489c396c3c..1b3c782c0e12 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -2,7 +2,7 @@ import CONST from '../CONST'; import Beta from '../types/onyx/Beta'; function canUseAllBetas(betas: Beta[]): boolean { - return betas?.includes(CONST.BETAS.ALL); + return true; // betas?.includes(CONST.BETAS.ALL); } function canUseChronos(betas: Beta[]): boolean { diff --git a/src/libs/actions/Wallet.js b/src/libs/actions/Wallet.js index 183920eccf21..caeb100851a9 100644 --- a/src/libs/actions/Wallet.js +++ b/src/libs/actions/Wallet.js @@ -216,7 +216,7 @@ function acceptWalletTerms(parameters) { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.USER_WALLET, value: { - shouldShowWalletActivationSuccess: true, + isPendingOnfidoResult: true, }, }, ]; @@ -236,7 +236,7 @@ function acceptWalletTerms(parameters) { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.USER_WALLET, value: { - shouldShowWalletActivationSuccess: null, + isPendingOnfidoResult: null, shouldShowFailedKYC: true, }, }, diff --git a/src/pages/EnablePayments/EnablePaymentsPage.js b/src/pages/EnablePayments/EnablePaymentsPage.js index 3f179e309a98..14fe968324fd 100644 --- a/src/pages/EnablePayments/EnablePaymentsPage.js +++ b/src/pages/EnablePayments/EnablePaymentsPage.js @@ -33,13 +33,19 @@ function EnablePaymentsPage({userWallet}) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); + const {isPendingOnfidoResult} = userWallet; + useEffect(() => { if (isOffline) { return; } - Wallet.openEnablePaymentsPage(); - }, [isOffline]); + if (!isPendingOnfidoResult) { + Wallet.openEnablePaymentsPage(); + } else { + Navigation.navigate(ROUTES.SETTINGS_WALLET); + } + }, [isOffline, isPendingOnfidoResult]); if (_.isEmpty(userWallet)) { return ; @@ -64,10 +70,6 @@ function EnablePaymentsPage({userWallet}) { ); } - if (userWallet.shouldShowWalletActivationSuccess) { - return ; - } - const currentStep = userWallet.currentStep || CONST.WALLET.STEP.ADDITIONAL_DETAILS; switch (currentStep) { diff --git a/src/pages/EnablePayments/userWalletPropTypes.js b/src/pages/EnablePayments/userWalletPropTypes.js index e6b4206be751..ef40c5a13b81 100644 --- a/src/pages/EnablePayments/userWalletPropTypes.js +++ b/src/pages/EnablePayments/userWalletPropTypes.js @@ -20,8 +20,8 @@ export default PropTypes.shape({ /** Status of wallet - e.g. SILVER or GOLD */ tierName: PropTypes.string, - /** Whether we should show the ActivateStep success view after the user finished the KYC flow */ - shouldShowWalletActivationSuccess: PropTypes.bool, + /** Whether the kyc is pending and is yet to be confirmed */ + isPendingOnfidoResult: PropTypes.bool, /** The wallet's programID, used to show the correct terms. */ walletProgramID: PropTypes.string, diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.js b/src/pages/settings/Wallet/WalletPage/WalletPage.js index 37bb49952984..deee74cbeefa 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.js +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.js @@ -8,10 +8,13 @@ import HeaderWithBackButton from '../../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../../components/ScreenWrapper'; import Navigation, {navigationRef} from '../../../../libs/Navigation/Navigation'; import styles from '../../../../styles/styles'; +import theme from '../../../../styles/themes/default'; import compose from '../../../../libs/compose'; import * as BankAccounts from '../../../../libs/actions/BankAccounts'; import Popover from '../../../../components/Popover'; import MenuItem from '../../../../components/MenuItem'; +import Text from '../../../../components/Text'; +import Icon from '../../../../components/Icon'; import * as PaymentMethods from '../../../../libs/actions/PaymentMethods'; import getClickedTargetLocation from '../../../../libs/getClickedTargetLocation'; import CurrentWalletBalance from '../../../../components/CurrentWalletBalance'; @@ -66,6 +69,8 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen const hasAssignedCard = !_.isEmpty(cardList); const shouldShowEmptyState = !hasBankAccount && !hasWallet && !hasAssignedCard; + const {isPendingOnfidoResult} = userWallet; + const updateShouldShowLoadingSpinner = useCallback(() => { // In order to prevent a loop, only update state of the spinner if there is a change const showLoadingSpinner = isLoadingPaymentMethods || false; @@ -357,6 +362,7 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen )} + navigateToWalletOrTransferBalancePage(source)} onSelectPaymentMethod={(selectedPaymentMethod) => { @@ -373,18 +379,34 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen source={hasActivatedWallet ? CONST.KYC_WALL_SOURCE.TRANSFER_BALANCE : CONST.KYC_WALL_SOURCE.ENABLE_WALLET} shouldIncludeDebitCard={hasActivatedWallet} > - {(triggerKYCFlow, buttonRef) => - hasActivatedWallet ? ( - - ) : ( + {(triggerKYCFlow, buttonRef) => { + if (hasActivatedWallet) { + return ( + + ); + } + + if (isPendingOnfidoResult && !shouldShowLoadingSpinner) { + return ( + + + {translate('walletPage.walletActivationPending')} + + ); + } + + return (