-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
EnablePayments.tsx
70 lines (61 loc) · 2.42 KB
/
EnablePayments.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, {useEffect} from 'react';
import {useOnyx} from 'react-native-onyx';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import Navigation from '@libs/Navigation/Navigation';
import * as Wallet from '@userActions/Wallet';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import AddBankAccount from './AddBankAccount/AddBankAccount';
import FailedKYC from './FailedKYC';
import FeesAndTerms from './FeesAndTerms/FeesAndTerms';
import PersonalInfo from './PersonalInfo/PersonalInfo';
import VerifyIdentity from './VerifyIdentity/VerifyIdentity';
function EnablePaymentsPage() {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET);
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
useEffect(() => {
if (isOffline) {
return;
}
if (isEmptyObject(userWallet)) {
Wallet.openEnablePaymentsPage();
}
}, [isOffline, userWallet]);
if (isEmptyObject(userWallet)) {
return <FullScreenLoadingIndicator />;
}
if (userWallet?.errorCode === CONST.WALLET.ERROR.KYC) {
return (
<>
<HeaderWithBackButton
title={translate('personalInfoStep.personalInfo')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WALLET)}
/>
<FailedKYC />
</>
);
}
const currentStep = isEmptyObject(bankAccountList) ? CONST.WALLET.STEP.ADD_BANK_ACCOUNT : userWallet?.currentStep || CONST.WALLET.STEP.ADDITIONAL_DETAILS;
switch (currentStep) {
case CONST.WALLET.STEP.ADD_BANK_ACCOUNT:
return <AddBankAccount />;
case CONST.WALLET.STEP.ADDITIONAL_DETAILS:
case CONST.WALLET.STEP.ADDITIONAL_DETAILS_KBA:
return <PersonalInfo />;
case CONST.WALLET.STEP.ONFIDO:
return <VerifyIdentity />;
case CONST.WALLET.STEP.TERMS:
return <FeesAndTerms />;
default:
return null;
}
}
EnablePaymentsPage.displayName = 'EnablePaymentsPage';
export default EnablePaymentsPage;