@os1-platform/dispatch-mobile 3.0.4 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +38 -9
- package/android/gradle.properties +17 -2
- package/lib/commonjs/components/dispatch/DispatchExecNavigator.js.map +1 -1
- package/lib/commonjs/components/executiontasks/forms/widgets/DateTimeWidget.js.map +1 -1
- package/lib/commonjs/components/executiontasks/imageCapture/CaptureUtils.js +1 -1
- package/lib/commonjs/components/executiontasks/imageCapture/CaptureUtils.js.map +1 -1
- package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPET.js +467 -287
- package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPET.js.map +1 -1
- package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPSchema.js +14 -1
- package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPSchema.js.map +1 -1
- package/lib/commonjs/components/executiontasks/validateOTP/ValidateOtpStyles.js +270 -0
- package/lib/commonjs/components/executiontasks/validateOTP/ValidateOtpStyles.js.map +1 -0
- package/lib/commonjs/components/executiontasks/validateOTP/components/ContactListView.js +99 -0
- package/lib/commonjs/components/executiontasks/validateOTP/components/ContactListView.js.map +1 -0
- package/lib/commonjs/components/executiontasks/validateOTP/components/OTPView.js +195 -0
- package/lib/commonjs/components/executiontasks/validateOTP/components/OTPView.js.map +1 -0
- package/lib/commonjs/components/executiontasks/validateOTP/components/VerificationComplete.js +106 -0
- package/lib/commonjs/components/executiontasks/validateOTP/components/VerificationComplete.js.map +1 -0
- package/lib/commonjs/components/executiontasks/validateOTP/constants.js +12 -5
- package/lib/commonjs/components/executiontasks/validateOTP/constants.js.map +1 -1
- package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ContactCard.js +68 -0
- package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ContactCard.js.map +1 -0
- package/lib/commonjs/components/executiontasks/validateOTP/sub-components/OTPInput.js +12 -5
- package/lib/commonjs/components/executiontasks/validateOTP/sub-components/OTPInput.js.map +1 -1
- package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js +61 -0
- package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js.map +1 -0
- package/lib/commonjs/components/executiontasks/validateOTP/utils.js +235 -114
- package/lib/commonjs/components/executiontasks/validateOTP/utils.js.map +1 -1
- package/lib/commonjs/components/utils/Scale.js +22 -0
- package/lib/commonjs/components/utils/Scale.js.map +1 -0
- package/lib/commonjs/components/widgets/ConfirmCancelModal.js +47 -0
- package/lib/commonjs/components/widgets/ConfirmCancelModal.js.map +1 -0
- package/lib/commonjs/components/widgets/SnackBarCustom.js +36 -4
- package/lib/commonjs/components/widgets/SnackBarCustom.js.map +1 -1
- package/lib/commonjs/components/widgets/SplitTextInput.js +48 -18
- package/lib/commonjs/components/widgets/SplitTextInput.js.map +1 -1
- package/lib/commonjs/constants/apiConstants.js +4 -1
- package/lib/commonjs/constants/apiConstants.js.map +1 -1
- package/lib/commonjs/constants/constants.js +2 -1
- package/lib/commonjs/constants/constants.js.map +1 -1
- package/lib/commonjs/icons/icExclamationcircleo_dark.svg +3 -0
- package/lib/commonjs/icons/icFailed.gif +0 -0
- package/lib/commonjs/icons/icRadioChecked.svg +4 -0
- package/lib/commonjs/icons/icRadioUnchecked.svg +4 -0
- package/lib/commonjs/icons/icSuccess.gif +0 -0
- package/lib/commonjs/icons/index.js +28 -0
- package/lib/commonjs/icons/index.js.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/manager/sdk/DispatchSDKManager.js +5 -4
- package/lib/commonjs/manager/sdk/DispatchSDKManager.js.map +1 -1
- package/lib/commonjs/manager/sdk/callbacksHandler.js +9 -2
- package/lib/commonjs/manager/sdk/callbacksHandler.js.map +1 -1
- package/lib/commonjs/manager/syncmanager/constants.js +3 -1
- package/lib/commonjs/manager/syncmanager/constants.js.map +1 -1
- package/lib/commonjs/manager/syncmanager/document/DocumentHttpClient.js +3 -2
- package/lib/commonjs/manager/syncmanager/document/DocumentHttpClient.js.map +1 -1
- package/lib/commonjs/manager/syncmanager/document/DocumentSyncManager.js +70 -80
- package/lib/commonjs/manager/syncmanager/document/DocumentSyncManager.js.map +1 -1
- package/lib/commonjs/models/sdk.js +1 -0
- package/lib/commonjs/models/sdk.js.map +1 -1
- package/lib/commonjs/ui/screens/ValidateOTPScreen.js +132 -12
- package/lib/commonjs/ui/screens/ValidateOTPScreen.js.map +1 -1
- package/lib/commonjs/utils/ApiUtils.js +122 -3
- package/lib/commonjs/utils/ApiUtils.js.map +1 -1
- package/lib/commonjs/utils/ExecTaskUtils.js +67 -7
- package/lib/commonjs/utils/ExecTaskUtils.js.map +1 -1
- package/lib/commonjs/utils/context/valdiateOTPContext.js +11 -0
- package/lib/commonjs/utils/context/valdiateOTPContext.js.map +1 -0
- package/lib/commonjs/utils/helper.js.map +1 -1
- package/lib/commonjs/utils/hooks/useTimer.js +68 -30
- package/lib/commonjs/utils/hooks/useTimer.js.map +1 -1
- package/lib/module/components/dispatch/DispatchExecNavigator.js.map +1 -1
- package/lib/module/components/executiontasks/forms/widgets/DateTimeWidget.js.map +1 -1
- package/lib/module/components/executiontasks/imageCapture/CaptureUtils.js +1 -1
- package/lib/module/components/executiontasks/imageCapture/CaptureUtils.js.map +1 -1
- package/lib/module/components/executiontasks/validateOTP/ValidateOTPET.js +480 -290
- package/lib/module/components/executiontasks/validateOTP/ValidateOTPET.js.map +1 -1
- package/lib/module/components/executiontasks/validateOTP/ValidateOTPSchema.js +14 -0
- package/lib/module/components/executiontasks/validateOTP/ValidateOTPSchema.js.map +1 -1
- package/lib/module/components/executiontasks/validateOTP/ValidateOtpStyles.js +264 -0
- package/lib/module/components/executiontasks/validateOTP/ValidateOtpStyles.js.map +1 -0
- package/lib/module/components/executiontasks/validateOTP/components/ContactListView.js +88 -0
- package/lib/module/components/executiontasks/validateOTP/components/ContactListView.js.map +1 -0
- package/lib/module/components/executiontasks/validateOTP/components/OTPView.js +194 -0
- package/lib/module/components/executiontasks/validateOTP/components/OTPView.js.map +1 -0
- package/lib/module/components/executiontasks/validateOTP/components/VerificationComplete.js +96 -0
- package/lib/module/components/executiontasks/validateOTP/components/VerificationComplete.js.map +1 -0
- package/lib/module/components/executiontasks/validateOTP/constants.js +11 -4
- package/lib/module/components/executiontasks/validateOTP/constants.js.map +1 -1
- package/lib/module/components/executiontasks/validateOTP/sub-components/ContactCard.js +59 -0
- package/lib/module/components/executiontasks/validateOTP/sub-components/ContactCard.js.map +1 -0
- package/lib/module/components/executiontasks/validateOTP/sub-components/OTPInput.js +11 -5
- package/lib/module/components/executiontasks/validateOTP/sub-components/OTPInput.js.map +1 -1
- package/lib/module/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js +52 -0
- package/lib/module/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js.map +1 -0
- package/lib/module/components/executiontasks/validateOTP/utils.js +219 -108
- package/lib/module/components/executiontasks/validateOTP/utils.js.map +1 -1
- package/lib/module/components/utils/Scale.js +14 -0
- package/lib/module/components/utils/Scale.js.map +1 -0
- package/lib/module/components/widgets/ConfirmCancelModal.js +40 -0
- package/lib/module/components/widgets/ConfirmCancelModal.js.map +1 -0
- package/lib/module/components/widgets/SnackBarCustom.js +36 -4
- package/lib/module/components/widgets/SnackBarCustom.js.map +1 -1
- package/lib/module/components/widgets/SplitTextInput.js +48 -19
- package/lib/module/components/widgets/SplitTextInput.js.map +1 -1
- package/lib/module/constants/apiConstants.js +4 -1
- package/lib/module/constants/apiConstants.js.map +1 -1
- package/lib/module/constants/constants.js +1 -0
- package/lib/module/constants/constants.js.map +1 -1
- package/lib/module/icons/icExclamationcircleo_dark.svg +3 -0
- package/lib/module/icons/icFailed.gif +0 -0
- package/lib/module/icons/icRadioChecked.svg +4 -0
- package/lib/module/icons/icRadioUnchecked.svg +4 -0
- package/lib/module/icons/icSuccess.gif +0 -0
- package/lib/module/icons/index.js +5 -0
- package/lib/module/icons/index.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/manager/sdk/DispatchSDKManager.js +5 -3
- package/lib/module/manager/sdk/DispatchSDKManager.js.map +1 -1
- package/lib/module/manager/sdk/callbacksHandler.js +12 -3
- package/lib/module/manager/sdk/callbacksHandler.js.map +1 -1
- package/lib/module/manager/syncmanager/constants.js +2 -0
- package/lib/module/manager/syncmanager/constants.js.map +1 -1
- package/lib/module/manager/syncmanager/document/DocumentHttpClient.js +3 -2
- package/lib/module/manager/syncmanager/document/DocumentHttpClient.js.map +1 -1
- package/lib/module/manager/syncmanager/document/DocumentSyncManager.js +70 -80
- package/lib/module/manager/syncmanager/document/DocumentSyncManager.js.map +1 -1
- package/lib/module/models/sdk.js +2 -0
- package/lib/module/models/sdk.js.map +1 -1
- package/lib/module/ui/screens/ValidateOTPScreen.js +139 -11
- package/lib/module/ui/screens/ValidateOTPScreen.js.map +1 -1
- package/lib/module/utils/ApiUtils.js +118 -2
- package/lib/module/utils/ApiUtils.js.map +1 -1
- package/lib/module/utils/ExecTaskUtils.js +66 -7
- package/lib/module/utils/ExecTaskUtils.js.map +1 -1
- package/lib/module/utils/context/valdiateOTPContext.js +4 -0
- package/lib/module/utils/context/valdiateOTPContext.js.map +1 -0
- package/lib/module/utils/helper.js +1 -0
- package/lib/module/utils/helper.js.map +1 -1
- package/lib/module/utils/hooks/useTimer.js +67 -30
- package/lib/module/utils/hooks/useTimer.js.map +1 -1
- package/lib/typescript/components/executiontasks/collectPayment/PaymentStyles.d.ts +3 -3
- package/lib/typescript/components/executiontasks/deliver/DeliverETInput.d.ts +0 -1
- package/lib/typescript/components/executiontasks/scan/modalConstant.d.ts +0 -1
- package/lib/typescript/components/executiontasks/validateOTP/ValidateOTPET.d.ts +3 -3
- package/lib/typescript/components/executiontasks/validateOTP/ValidateOTPSchema.d.ts +169 -5
- package/lib/typescript/components/executiontasks/validateOTP/ValidateOtpStyles.d.ts +255 -0
- package/lib/typescript/components/executiontasks/validateOTP/components/ContactListView.d.ts +3 -0
- package/lib/typescript/components/executiontasks/validateOTP/components/OTPView.d.ts +3 -0
- package/lib/typescript/components/executiontasks/validateOTP/components/VerificationComplete.d.ts +3 -0
- package/lib/typescript/components/executiontasks/validateOTP/constants.d.ts +11 -4
- package/lib/typescript/components/executiontasks/validateOTP/sub-components/ContactCard.d.ts +8 -0
- package/lib/typescript/components/executiontasks/validateOTP/sub-components/ResendOTPButton.d.ts +12 -0
- package/lib/typescript/components/executiontasks/validateOTP/utils.d.ts +31 -7
- package/lib/typescript/components/utils/Scale.d.ts +4 -0
- package/lib/typescript/components/widgets/ConfirmCancelModal.d.ts +9 -0
- package/lib/typescript/components/widgets/SnackBarCustom.d.ts +4 -8
- package/lib/typescript/components/widgets/SplitTextInput.d.ts +1 -1
- package/lib/typescript/components/widgets/Timer.d.ts +3 -3
- package/lib/typescript/constants/apiConstants.d.ts +3 -0
- package/lib/typescript/constants/constants.d.ts +1 -0
- package/lib/typescript/icons/index.d.ts +4 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/manager/sdk/callbacksHandler.d.ts +4 -1
- package/lib/typescript/manager/syncmanager/constants.d.ts +2 -0
- package/lib/typescript/models/execTasks/ETConfig.d.ts +1 -1
- package/lib/typescript/models/sdk.d.ts +3 -0
- package/lib/typescript/network/GraphQLClient.d.ts +4 -4
- package/lib/typescript/styles/executionTasks/CommonStyles.d.ts +2 -2
- package/lib/typescript/ui/screens/HttpRequestScreen.d.ts +0 -1
- package/lib/typescript/utils/ApiUtils.d.ts +6 -2
- package/lib/typescript/utils/ExecTaskUtils.d.ts +1 -0
- package/lib/typescript/utils/context/paymentContext.d.ts +0 -1
- package/lib/typescript/utils/context/valdiateOTPContext.d.ts +6 -0
- package/lib/typescript/utils/hooks/useModal.d.ts +0 -2
- package/lib/typescript/utils/hooks/useTimer.d.ts +7 -5
- package/package.json +46 -44
- package/src/components/dispatch/DispatchExecNavigator.tsx +1 -1
- package/src/components/executiontasks/forms/widgets/DateTimeWidget.tsx +2 -2
- package/src/components/executiontasks/imageCapture/CaptureUtils.ts +1 -1
- package/src/components/executiontasks/validateOTP/ValidateOTPET.tsx +654 -381
- package/src/components/executiontasks/validateOTP/ValidateOTPSchema.ts +193 -8
- package/src/components/executiontasks/validateOTP/ValidateOtpStyles.ts +296 -0
- package/src/components/executiontasks/validateOTP/components/ContactListView.tsx +109 -0
- package/src/components/executiontasks/validateOTP/components/OTPView.tsx +216 -0
- package/src/components/executiontasks/validateOTP/components/VerificationComplete.tsx +124 -0
- package/src/components/executiontasks/validateOTP/constants.ts +11 -4
- package/src/components/executiontasks/validateOTP/sub-components/ContactCard.tsx +72 -0
- package/src/components/executiontasks/validateOTP/sub-components/OTPInput.tsx +13 -7
- package/src/components/executiontasks/validateOTP/sub-components/ResendOTPButton.tsx +86 -0
- package/src/components/executiontasks/validateOTP/utils.ts +313 -143
- package/src/components/utils/Scale.ts +13 -0
- package/src/components/widgets/ConfirmCancelModal.tsx +49 -0
- package/src/components/widgets/SnackBarCustom.tsx +37 -13
- package/src/components/widgets/SplitTextInput.tsx +58 -21
- package/src/constants/apiConstants.ts +3 -0
- package/src/constants/constants.ts +2 -2
- package/src/icons/icExclamationcircleo_dark.svg +3 -0
- package/src/icons/icFailed.gif +0 -0
- package/src/icons/icRadioChecked.svg +4 -0
- package/src/icons/icRadioUnchecked.svg +4 -0
- package/src/icons/icSuccess.gif +0 -0
- package/src/icons/index.ts +5 -0
- package/src/index.tsx +2 -0
- package/src/manager/sdk/DispatchSDKManager.ts +6 -5
- package/src/manager/sdk/callbacksHandler.ts +29 -12
- package/src/manager/syncmanager/constants.ts +2 -0
- package/src/manager/syncmanager/document/DocumentHttpClient.ts +29 -29
- package/src/manager/syncmanager/document/DocumentSyncManager.ts +75 -84
- package/src/models/sdk.ts +6 -0
- package/src/ui/screens/ValidateOTPScreen.tsx +194 -32
- package/src/utils/ApiUtils.ts +131 -3
- package/src/utils/ExecTaskUtils.ts +77 -15
- package/src/utils/context/valdiateOTPContext.ts +9 -0
- package/src/utils/helper.ts +0 -1
- package/src/utils/hooks/useTimer.ts +94 -36
|
@@ -1,354 +1,544 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
4
|
+
// External Libraries
|
|
5
|
+
import React, { useState, useLayoutEffect, useEffect, useContext } from 'react';
|
|
6
|
+
import { View, Text, Platform } from 'react-native';
|
|
7
|
+
|
|
8
|
+
// UI Libraries and Icons
|
|
9
|
+
import { ActivityIndicator, Button, Portal, Provider } from 'react-native-paper';
|
|
10
|
+
|
|
11
|
+
// Utility Functions and Hooks
|
|
12
12
|
import { getBaseETResponse } from '../../../utils/ExecTaskUtils';
|
|
13
|
+
import { hasGoBackConnector } from '../../../components/utils';
|
|
14
|
+
import { countType, generateOTP, getCount, parseResendConfig, updateResendCount, updateRetryCount, VALIDATE_OTP_SCREENS, verifyOTP } from './utils';
|
|
15
|
+
|
|
16
|
+
// Dispatch Codes and Models
|
|
13
17
|
import { getEventCodeByET } from '../../../manager/dispatchCodes/EventCodeContainer';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
18
|
+
import { EntityCode, ExecutionTaskID } from '../../../models/execTasks/ETConfig';
|
|
19
|
+
import { ValidateOTPContext } from '../../../utils/context/valdiateOTPContext';
|
|
20
|
+
|
|
21
|
+
// Schema and Types
|
|
22
|
+
import { InputType, OtpDeliveryMethodTypes, ValidationType } from './ValidateOTPSchema';
|
|
23
|
+
|
|
24
|
+
// Constants
|
|
16
25
|
import { GO_BACK_EVENT_CODE } from '../../../constants/constants';
|
|
17
|
-
import {
|
|
26
|
+
import { ERROR_GENERATING_OTP, ERROR_VALIDATE_OTP, INVALID_OTP, INVALID_OTP_LENGTH, INVALID_OTP_ONE_ATTEMPT_LEFT, OTP_SENT_SUCCESSFULLY, UNABLE_TO_SEND_OTP } from './constants';
|
|
27
|
+
|
|
28
|
+
// Components
|
|
29
|
+
import SnackBarCustom, { SnackBarType } from '../../../components/widgets/SnackBarCustom';
|
|
18
30
|
import GoBackModal from '../../../components/widgets/GoBackModal';
|
|
19
|
-
import
|
|
31
|
+
import ConfirmCancelModal from '../../../components/widgets/ConfirmCancelModal';
|
|
32
|
+
import { OTPView } from './components/OTPView';
|
|
33
|
+
import { ContactListView } from './components/ContactListView';
|
|
34
|
+
import VerificationComplete from './components/VerificationComplete';
|
|
35
|
+
import ProgressDialog from '../../widgets/ProgressDialog';
|
|
36
|
+
|
|
37
|
+
// Styles
|
|
38
|
+
import styles from './ValidateOtpStyles';
|
|
39
|
+
import { CommonStyles, Fonts } from '../../../styles/executionTasks/CommonStyles';
|
|
40
|
+
|
|
41
|
+
// Analytics
|
|
20
42
|
import { ScreenNameSdkConstants, SentryEventNameSdkConstants, SeverityLevelValue } from '../../../analytics/sentry/SentrySdkConstants';
|
|
21
43
|
import { fireEventWithScreenName } from '../../../analytics/sentry/SentryAnalyticsUtils';
|
|
22
44
|
const ValidateOTPET = props => {
|
|
23
|
-
var
|
|
24
|
-
const
|
|
45
|
+
var _validateConfigContex;
|
|
46
|
+
const {
|
|
47
|
+
contacts,
|
|
48
|
+
navigation
|
|
49
|
+
} = props;
|
|
50
|
+
// Context
|
|
51
|
+
const validateConfigContext = useContext(ValidateOTPContext);
|
|
52
|
+
const domain = (validateConfigContext === null || validateConfigContext === void 0 || (_validateConfigContex = validateConfigContext.sdkConfig) === null || _validateConfigContex === void 0 ? void 0 : _validateConfigContex.validateOtpDomain) ?? '';
|
|
25
53
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, []));
|
|
41
|
-
useLayoutEffect(() => {
|
|
42
|
-
props.navigation.setOptions({
|
|
43
|
-
title: props.title,
|
|
44
|
-
headerLeft: () => {
|
|
45
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
46
|
-
onPress: () => {
|
|
47
|
-
var _props$taskMeta2;
|
|
48
|
-
if ((_props$taskMeta2 = props.taskMeta) !== null && _props$taskMeta2 !== void 0 && _props$taskMeta2.enableGoBack && hasGoBackConnector(props.applicableReasons)) setShowBackModal(true);else props.navigation.goBack();
|
|
49
|
-
const cta = 'Arrow Back';
|
|
50
|
-
fireEventWithScreenName({
|
|
51
|
-
severityLevel: SeverityLevelValue.LOG,
|
|
52
|
-
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
53
|
-
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
54
|
-
cta: cta
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
name: "arrow-back",
|
|
58
|
-
color: 'black',
|
|
59
|
-
size: 25,
|
|
60
|
-
style: {
|
|
61
|
-
paddingRight: 15,
|
|
62
|
-
paddingTop: 5
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}, [props.navigation, props.title]);
|
|
68
|
-
const retryConfig = parseRetryConfig((_props$generationLogi = props.generationLogic) === null || _props$generationLogi === void 0 ? void 0 : _props$generationLogi.retryConfig);
|
|
69
|
-
const initialMinute = Math.floor(retryConfig.delay / 60);
|
|
70
|
-
const initialSeconds = parseInt((retryConfig.delay % 60).toFixed(0));
|
|
71
|
-
const [timer, resetTimer] = useTimer({
|
|
72
|
-
initialMinute,
|
|
73
|
-
initialSeconds
|
|
74
|
-
});
|
|
75
|
-
const [sendOTP, setSendOTP] = useState(Boolean((_props$generationLogi2 = props.generationLogic) === null || _props$generationLogi2 === void 0 ? void 0 : _props$generationLogi2.generateOnLoad));
|
|
76
|
-
const [retryCount, setRetryCount] = useState(0);
|
|
54
|
+
// Configurations
|
|
55
|
+
const resendConfig = parseResendConfig(props.resendOTP);
|
|
56
|
+
const otpInputConfig = {
|
|
57
|
+
inputType: props.inputType || InputType.NUMBER,
|
|
58
|
+
length: props.otpLength || 6,
|
|
59
|
+
validationRegex: `^[0-9]+$`
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// State: Contact Management
|
|
63
|
+
const [contactList, setContactList] = useState(contacts);
|
|
64
|
+
const [selectedContact, setSelectedContact] = useState(contactList[0] || null);
|
|
65
|
+
const [isContactVisited, setIsContactVisited] = useState(props.doorstepOTP);
|
|
66
|
+
|
|
67
|
+
// State: OTP Handling
|
|
77
68
|
const [userInput, setUserInput] = useState({
|
|
78
69
|
captureInput: ''
|
|
79
70
|
});
|
|
80
71
|
const {
|
|
81
72
|
captureInput: otpCode
|
|
82
73
|
} = userInput;
|
|
83
|
-
const setOTPCode =
|
|
74
|
+
const setOTPCode = code => {
|
|
84
75
|
setUserInput({
|
|
85
76
|
...userInput,
|
|
86
|
-
captureInput:
|
|
77
|
+
captureInput: code
|
|
87
78
|
});
|
|
88
79
|
};
|
|
80
|
+
const [retryCount, setRetryCount] = useState(0);
|
|
81
|
+
const [resendCount, setResendCount] = useState(0);
|
|
82
|
+
const [disableProceedBtn, setDisableProceedBtn] = useState(false);
|
|
83
|
+
|
|
84
|
+
// State: UI and Navigation
|
|
85
|
+
const [showBackModal, setShowBackModal] = useState(false);
|
|
86
|
+
const [showCancelModal, setShowCancelModal] = useState(false);
|
|
87
|
+
const [loading, setLoading] = useState(false);
|
|
89
88
|
const [hasError, setHasError] = useState(false);
|
|
90
89
|
const [errorMessage, setErrorMessage] = useState('');
|
|
90
|
+
const [success, setSuccess] = useState(false);
|
|
91
|
+
const [shouldNavigateBack, setShouldNavigateBack] = useState(false);
|
|
92
|
+
const [currentScreen, setCurrentScreen] = useState(props.doorstepOTP ? VALIDATE_OTP_SCREENS.CONTACT_LIST : VALIDATE_OTP_SCREENS.OTP_VIEW);
|
|
93
|
+
|
|
94
|
+
// State: SnackBar
|
|
91
95
|
const [snackBar, setSnackBar] = useState({
|
|
92
96
|
show: false,
|
|
93
|
-
type: SnackBarType.
|
|
97
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
94
98
|
message: ''
|
|
95
99
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const fetchCounts = async () => {
|
|
102
|
+
// eslint-disable-next-line no-shadow
|
|
103
|
+
const retryCount = await getCount(countType.RETRY);
|
|
104
|
+
// eslint-disable-next-line no-shadow
|
|
105
|
+
const resendCount = await getCount(countType.RESEND);
|
|
106
|
+
setRetryCount(retryCount);
|
|
107
|
+
setResendCount(resendCount);
|
|
108
|
+
};
|
|
109
|
+
fetchCounts();
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
// TO hide header for modal screen
|
|
113
|
+
useLayoutEffect(() => {
|
|
114
|
+
navigation.setOptions({
|
|
115
|
+
// headerShown: loading ? false : true,
|
|
116
|
+
headerStyle: {
|
|
117
|
+
display: loading ? 'none' : 'flex' // Hide the header by setting its display to 'none'
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
}, [loading]);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW) {
|
|
124
|
+
setDisableProceedBtn((otpCode === null || otpCode === void 0 ? void 0 : otpCode.length) !== otpInputConfig.length || !selectedContact || hasError);
|
|
125
|
+
} else {
|
|
126
|
+
setDisableProceedBtn(!selectedContact);
|
|
127
|
+
}
|
|
128
|
+
}, [currentScreen, hasError, otpCode === null || otpCode === void 0 ? void 0 : otpCode.length, otpInputConfig.length, selectedContact]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (!contacts) return;
|
|
131
|
+
|
|
132
|
+
// Filter contacts based on the delivery method, or use all contacts if BOTH
|
|
133
|
+
const filteredContacts = contacts.filter(contact => {
|
|
134
|
+
var _contact$mode, _props$otpDeliveryMet;
|
|
135
|
+
return props.otpDeliveryMethod === OtpDeliveryMethodTypes.BOTH ? true : ((_contact$mode = contact.mode) === null || _contact$mode === void 0 ? void 0 : _contact$mode.toLowerCase()) === ((_props$otpDeliveryMet = props.otpDeliveryMethod) === null || _props$otpDeliveryMet === void 0 ? void 0 : _props$otpDeliveryMet.toLowerCase());
|
|
136
|
+
}).map((contact, index) => ({
|
|
137
|
+
...contact,
|
|
138
|
+
isSelected: index === 0 // Select the first contact by default
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
// Update the state with the filtered contacts
|
|
142
|
+
setContactList(filteredContacts);
|
|
143
|
+
if (props.doorstepOTP) {
|
|
144
|
+
setSelectedContact(filteredContacts[0]);
|
|
145
|
+
}
|
|
146
|
+
}, [contacts, props.doorstepOTP, props.otpDeliveryMethod]);
|
|
147
|
+
|
|
148
|
+
// Monitor shouldNavigateBack to trigger navigation if set
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
if (shouldNavigateBack) {
|
|
151
|
+
navigation.goBack();
|
|
152
|
+
setOTPCode('');
|
|
153
|
+
}
|
|
154
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
155
|
+
}, [navigation, shouldNavigateBack]);
|
|
156
|
+
const handleBackNavigation = () => {
|
|
157
|
+
var _props$taskMeta;
|
|
158
|
+
if ((_props$taskMeta = props.taskMeta) !== null && _props$taskMeta !== void 0 && _props$taskMeta.enableGoBack && hasGoBackConnector(props.applicableReasons)) {
|
|
159
|
+
setShowBackModal(true);
|
|
160
|
+
} else {
|
|
161
|
+
setShouldNavigateBack(true);
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
};
|
|
165
|
+
const onProceedCancel = async () => {
|
|
166
|
+
var _props$applicableReas;
|
|
167
|
+
// Cancel the ET
|
|
168
|
+
props.onSubmitET({
|
|
169
|
+
...(await getBaseETResponse(EntityCode.VALIDATE_OTP_ET, false, getEventCodeByET(ExecutionTaskID.VALIDATE_OTP_ET, false, (_props$applicableReas = props.applicableReasons) === null || _props$applicableReas === void 0 ? void 0 : _props$applicableReas.failure), '', props.mergedObjectiveId, ExecutionTaskID.VALIDATE_OTP_ET)),
|
|
170
|
+
retryCount: retryCount
|
|
171
|
+
});
|
|
172
|
+
const cta = 'Cancel';
|
|
173
|
+
fireEventWithScreenName({
|
|
174
|
+
severityLevel: SeverityLevelValue.LOG,
|
|
175
|
+
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
176
|
+
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
177
|
+
cta: cta
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
const handleContactListProceed = async () => {
|
|
181
|
+
try {
|
|
182
|
+
var _props$orderData$, _props$orderData, _response$data3, _response$additionalI;
|
|
183
|
+
setSnackBar({
|
|
184
|
+
show: false,
|
|
185
|
+
message: '',
|
|
186
|
+
type: SnackBarType.OTP_SUCCESS
|
|
187
|
+
});
|
|
188
|
+
setLoading(true);
|
|
189
|
+
const payload = {
|
|
190
|
+
jobId: (_props$orderData$ = props.orderData[0]) === null || _props$orderData$ === void 0 ? void 0 : _props$orderData$.jobId,
|
|
191
|
+
refId: props.refId,
|
|
192
|
+
objectiveId: props.workflowId,
|
|
193
|
+
contactInfo: {
|
|
194
|
+
id: selectedContact.id,
|
|
195
|
+
mode: selectedContact.mode,
|
|
196
|
+
type: selectedContact.type,
|
|
197
|
+
index: selectedContact.index
|
|
198
|
+
},
|
|
199
|
+
meta: {
|
|
200
|
+
orderIds: (_props$orderData = props.orderData) === null || _props$orderData === void 0 ? void 0 : _props$orderData.map(order => {
|
|
201
|
+
var _order$displayInfo;
|
|
202
|
+
return order === null || order === void 0 || (_order$displayInfo = order.displayInfo) === null || _order$displayInfo === void 0 ? void 0 : _order$displayInfo.orderId;
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const response = await generateOTP(payload, {
|
|
207
|
+
...props,
|
|
208
|
+
domain
|
|
209
|
+
});
|
|
210
|
+
if (!(response !== null && response !== void 0 && response.status)) {
|
|
211
|
+
if (!response.status && (response === null || response === void 0 ? void 0 : response.code) === '101080001017') {
|
|
212
|
+
var _response$data;
|
|
213
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.OTP_VIEW);
|
|
214
|
+
setLoading(false);
|
|
215
|
+
setSnackBar({
|
|
114
216
|
show: true,
|
|
115
|
-
message:
|
|
116
|
-
type: SnackBarType.
|
|
217
|
+
message: (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.result) === null || _response$data === void 0 ? void 0 : _response$data.message) || UNABLE_TO_SEND_OTP,
|
|
218
|
+
type: SnackBarType.OTP_FAILED
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
var _response$data2;
|
|
222
|
+
setLoading(false);
|
|
223
|
+
setSnackBar({
|
|
224
|
+
show: true,
|
|
225
|
+
message: (response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 || (_response$data2 = _response$data2.result) === null || _response$data2 === void 0 ? void 0 : _response$data2.message) || ERROR_GENERATING_OTP,
|
|
226
|
+
type: SnackBarType.OTP_FAILED
|
|
117
227
|
});
|
|
118
228
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const resendCountValue = Number((response === null || response === void 0 || (_response$data3 = response.data) === null || _response$data3 === void 0 || (_response$data3 = _response$data3.result) === null || _response$data3 === void 0 ? void 0 : _response$data3.resendCount) || (response === null || response === void 0 || (_response$additionalI = response.additionalInfo) === null || _response$additionalI === void 0 ? void 0 : _response$additionalI.resendOTP)) || 0;
|
|
232
|
+
setResendCount(resendCountValue);
|
|
233
|
+
await updateResendCount(resendCountValue);
|
|
234
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.OTP_VIEW);
|
|
235
|
+
setLoading(false);
|
|
236
|
+
setSnackBar({
|
|
237
|
+
show: true,
|
|
238
|
+
message: OTP_SENT_SUCCESSFULLY,
|
|
239
|
+
type: SnackBarType.OTP_SUCCESS
|
|
240
|
+
});
|
|
241
|
+
} catch (error) {
|
|
242
|
+
setLoading(false);
|
|
243
|
+
console.error('Error in handleContactListProceed:', error);
|
|
244
|
+
setSnackBar({
|
|
245
|
+
show: true,
|
|
246
|
+
message: ERROR_GENERATING_OTP,
|
|
247
|
+
type: SnackBarType.OTP_FAILED
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const handleOTPViewProceed = async () => {
|
|
252
|
+
var _props$otpValidation, _ValidationType$ONLIN, _response$result, _response$additionalI2;
|
|
253
|
+
if (otpCode.length < props.otpLength) {
|
|
254
|
+
// Show error if OTP length is invalid
|
|
255
|
+
setSnackBar({
|
|
256
|
+
show: true,
|
|
257
|
+
message: INVALID_OTP_LENGTH.replace('<length>', `${props.otpLength}`),
|
|
258
|
+
type: SnackBarType.OTP_FAILED
|
|
259
|
+
});
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const payload = {
|
|
263
|
+
refId: props.refId,
|
|
264
|
+
otp: otpCode
|
|
265
|
+
};
|
|
266
|
+
const isOnlineValidation = props !== null && props !== void 0 && props.otpValidation ? (props === null || props === void 0 || (_props$otpValidation = props.otpValidation) === null || _props$otpValidation === void 0 || (_props$otpValidation = _props$otpValidation.toString()) === null || _props$otpValidation === void 0 ? void 0 : _props$otpValidation.toLowerCase()) === ((_ValidationType$ONLIN = ValidationType.ONLINE) === null || _ValidationType$ONLIN === void 0 || (_ValidationType$ONLIN = _ValidationType$ONLIN.toString()) === null || _ValidationType$ONLIN === void 0 ? void 0 : _ValidationType$ONLIN.toLowerCase()) : true;
|
|
267
|
+
const response = isOnlineValidation ? await verifyOTP(payload, {
|
|
268
|
+
...props,
|
|
269
|
+
domain
|
|
270
|
+
}) : otpCode === props.offlineOtpValue;
|
|
271
|
+
const retryCountValue = Number((response === null || response === void 0 || (_response$result = response.result) === null || _response$result === void 0 ? void 0 : _response$result.retryCount) || (response === null || response === void 0 || (_response$additionalI2 = response.additionalInfo) === null || _response$additionalI2 === void 0 ? void 0 : _response$additionalI2.retryCount)) || retryCount + 1;
|
|
272
|
+
if (response === false || (response === null || response === void 0 ? void 0 : response.status) === false || !response) {
|
|
273
|
+
setOTPCode('');
|
|
274
|
+
setRetryCount(retryCountValue);
|
|
275
|
+
await updateRetryCount(retryCountValue);
|
|
276
|
+
if (props.maxRetries - retryCountValue === 1) {
|
|
277
|
+
setSnackBar({
|
|
278
|
+
show: true,
|
|
279
|
+
message: INVALID_OTP_ONE_ATTEMPT_LEFT,
|
|
280
|
+
type: SnackBarType.OTP_FAILED
|
|
281
|
+
});
|
|
282
|
+
} else if (retryCountValue >= props.maxRetries) {
|
|
283
|
+
setSuccess(false);
|
|
284
|
+
setSnackBar({
|
|
285
|
+
show: false,
|
|
286
|
+
message: '',
|
|
287
|
+
type: SnackBarType.OTP_SUCCESS
|
|
288
|
+
});
|
|
289
|
+
setLoading(true);
|
|
290
|
+
setTimeout(() => {
|
|
291
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE);
|
|
292
|
+
setLoading(false);
|
|
293
|
+
}, 1000);
|
|
294
|
+
} else {
|
|
295
|
+
setSnackBar({
|
|
296
|
+
show: true,
|
|
297
|
+
message: INVALID_OTP.replace('<length>', `${props.maxRetries - retryCountValue}`),
|
|
298
|
+
type: SnackBarType.OTP_FAILED
|
|
148
299
|
});
|
|
149
300
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
301
|
+
} else {
|
|
302
|
+
setSuccess(true);
|
|
303
|
+
setSnackBar({
|
|
304
|
+
show: false,
|
|
305
|
+
message: '',
|
|
306
|
+
type: SnackBarType.OTP_SUCCESS
|
|
307
|
+
});
|
|
308
|
+
setLoading(true);
|
|
309
|
+
setTimeout(() => {
|
|
310
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE);
|
|
311
|
+
setLoading(false);
|
|
312
|
+
}, 1000);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const onProceed = async () => {
|
|
316
|
+
try {
|
|
317
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST) {
|
|
318
|
+
handleContactListProceed();
|
|
319
|
+
} else {
|
|
320
|
+
handleOTPViewProceed();
|
|
321
|
+
}
|
|
322
|
+
const cta = 'Proceed';
|
|
323
|
+
fireEventWithScreenName({
|
|
324
|
+
severityLevel: SeverityLevelValue.LOG,
|
|
325
|
+
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
326
|
+
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
327
|
+
cta: cta
|
|
328
|
+
});
|
|
329
|
+
} catch (error) {
|
|
330
|
+
setLoading(false);
|
|
331
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST) {
|
|
332
|
+
setSnackBar({
|
|
333
|
+
show: true,
|
|
334
|
+
message: ERROR_GENERATING_OTP,
|
|
335
|
+
type: SnackBarType.OTP_FAILED
|
|
163
336
|
});
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
337
|
+
}
|
|
338
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW) {
|
|
339
|
+
setSnackBar({
|
|
340
|
+
show: true,
|
|
341
|
+
message: ERROR_VALIDATE_OTP,
|
|
342
|
+
type: SnackBarType.OTP_FAILED
|
|
170
343
|
});
|
|
171
344
|
}
|
|
172
|
-
}
|
|
345
|
+
}
|
|
346
|
+
return;
|
|
173
347
|
};
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
const generationLogic = props.generationLogic;
|
|
177
|
-
const enableRetry = (_props$generationLogi4 = props.generationLogic) === null || _props$generationLogi4 === void 0 ? void 0 : _props$generationLogi4.enableRetry;
|
|
178
|
-
if (generationLogic && enableRetry) {
|
|
179
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
180
|
-
style: styles.retryButton
|
|
181
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
182
|
-
disabled: Boolean(timer) || retryCount === retryConfig.maxAttempt,
|
|
183
|
-
uppercase: false,
|
|
184
|
-
onPress: async () => {
|
|
185
|
-
setOTPCode('');
|
|
186
|
-
setRetryCount(retryCount => retryCount + 1);
|
|
187
|
-
await generateOTP(generationLogic.api);
|
|
188
|
-
resetTimer();
|
|
189
|
-
const cta = retryConfig.buttonTitle;
|
|
190
|
-
fireEventWithScreenName({
|
|
191
|
-
severityLevel: SeverityLevelValue.LOG,
|
|
192
|
-
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
193
|
-
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
194
|
-
cta: cta
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}, `${retryConfig.buttonTitle} ${timer ? `in ${timer}` : ''}`));
|
|
198
|
-
} else return null;
|
|
348
|
+
const onCancelET = () => {
|
|
349
|
+
setShowCancelModal(true);
|
|
199
350
|
};
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
351
|
+
const handleSelectContact = contactDetails => {
|
|
352
|
+
setSelectedContact(contactDetails);
|
|
353
|
+
setContactList(prevContactList => prevContactList.map(contact => ({
|
|
354
|
+
...contact,
|
|
355
|
+
isSelected: (contact === null || contact === void 0 ? void 0 : contact.value) === contactDetails.value
|
|
356
|
+
})));
|
|
204
357
|
};
|
|
205
|
-
|
|
358
|
+
|
|
359
|
+
// *Rendering components*
|
|
360
|
+
const renderGoBackModal = () => {
|
|
206
361
|
return /*#__PURE__*/React.createElement(GoBackModal, {
|
|
207
362
|
showModal: showBackModal,
|
|
208
363
|
setShowModal: setShowBackModal,
|
|
209
364
|
onSuccess: async () => {
|
|
210
365
|
props.onSubmitET({
|
|
211
|
-
...(await getBaseETResponse(EntityCode.VALIDATE_OTP_ET, false, GO_BACK_EVENT_CODE, '', props.mergedObjectiveId, ExecutionTaskID.VALIDATE_OTP_ET))
|
|
366
|
+
...(await getBaseETResponse(EntityCode.VALIDATE_OTP_ET, false, GO_BACK_EVENT_CODE, '', props.mergedObjectiveId, ExecutionTaskID.VALIDATE_OTP_ET)),
|
|
367
|
+
retryCount: retryCount
|
|
212
368
|
});
|
|
213
369
|
setShowBackModal(false);
|
|
214
370
|
},
|
|
215
371
|
onFailure: () => setShowBackModal(false)
|
|
216
372
|
});
|
|
217
373
|
};
|
|
218
|
-
|
|
219
|
-
return /*#__PURE__*/React.createElement(
|
|
220
|
-
|
|
221
|
-
|
|
374
|
+
const renderCancelModal = () => {
|
|
375
|
+
return /*#__PURE__*/React.createElement(ConfirmCancelModal, {
|
|
376
|
+
showModal: showCancelModal,
|
|
377
|
+
setShowModal: setShowCancelModal,
|
|
378
|
+
onSuccess: () => {
|
|
379
|
+
onProceedCancel();
|
|
380
|
+
setShowCancelModal(false);
|
|
381
|
+
},
|
|
382
|
+
onFailure: () => setShowCancelModal(false)
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
const renderButtons = () => {
|
|
386
|
+
if (loading || currentScreen === VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE) return null;
|
|
387
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
388
|
+
style: styles.bottomView
|
|
389
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
390
|
+
style: [styles.mainBtnStyles, CommonStyles.nextButton, {
|
|
391
|
+
borderRadius: 6
|
|
392
|
+
}, disableProceedBtn && {
|
|
393
|
+
backgroundColor: '#E0E3EB'
|
|
394
|
+
}],
|
|
395
|
+
labelStyle: [CommonStyles.nextButtonLabel, styles.activeBtnText, disableProceedBtn && disableProceedBtn && {
|
|
396
|
+
color: '#A3AAC2'
|
|
397
|
+
}],
|
|
398
|
+
mode: 'contained',
|
|
399
|
+
uppercase: false,
|
|
400
|
+
disabled: disableProceedBtn,
|
|
401
|
+
onPress: onProceed
|
|
402
|
+
}, "Proceed"), props.restrictCancel === true || props.allowCancel === false ? null : props.isSelfLoop == false && /*#__PURE__*/React.createElement(Button, {
|
|
403
|
+
style: [styles.mainBtnStyles, CommonStyles.cancelButton, {
|
|
404
|
+
borderRadius: 4
|
|
405
|
+
}],
|
|
406
|
+
labelStyle: [CommonStyles.cancelButtonLabel, styles.cancelBtnText],
|
|
407
|
+
mode: 'outlined',
|
|
408
|
+
uppercase: false,
|
|
409
|
+
onPress: onCancelET
|
|
410
|
+
}, "Cancel"));
|
|
411
|
+
};
|
|
412
|
+
const renderLoadingCard = () => {
|
|
413
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
222
414
|
style: {
|
|
223
415
|
flex: 1,
|
|
224
|
-
justifyContent: 'center'
|
|
225
|
-
alignItems: 'center',
|
|
226
|
-
marginHorizontal: 18
|
|
416
|
+
justifyContent: 'center'
|
|
227
417
|
}
|
|
228
418
|
}, /*#__PURE__*/React.createElement(View, {
|
|
419
|
+
style: styles.loadingCard
|
|
420
|
+
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
421
|
+
size: "small",
|
|
422
|
+
color: "rgba(107, 142, 255, 1)"
|
|
423
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
424
|
+
style: styles.loadingText
|
|
425
|
+
}, "Loading")));
|
|
426
|
+
};
|
|
427
|
+
const renderSnackBar = () => {
|
|
428
|
+
if (!snackBar.show) return null; // Show snackbar only when `snackBar.show` is true
|
|
429
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
229
430
|
style: {
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
}, Platform.OS === 'android' && /*#__PURE__*/React.createElement(SvgXml, {
|
|
233
|
-
xml: mobileSVG
|
|
234
|
-
})), /*#__PURE__*/React.createElement(View, {
|
|
235
|
-
style: {
|
|
236
|
-
marginTop: 16
|
|
237
|
-
}
|
|
238
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
239
|
-
style: styles.titleText
|
|
240
|
-
}, "Do you want to proceed to OTP verification? This will send a verification code to your consignee."))), renderButtons(), /*#__PURE__*/React.createElement(SnackBarCustom, {
|
|
241
|
-
type: snackBar.type,
|
|
242
|
-
message: `${snackBar.message}`,
|
|
243
|
-
visible: snackBar.show,
|
|
244
|
-
onDismiss: () => {
|
|
245
|
-
setSnackBar({
|
|
246
|
-
show: false,
|
|
247
|
-
message: '',
|
|
248
|
-
type: SnackBarType.SUCCESS
|
|
249
|
-
});
|
|
431
|
+
marginHorizontal: 6
|
|
250
432
|
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (!sendOTP) {
|
|
254
|
-
var _props$captureInput;
|
|
255
|
-
return /*#__PURE__*/React.createElement(Provider, null, /*#__PURE__*/React.createElement(View, {
|
|
256
|
-
style: CommonStyles.mainContainer
|
|
257
|
-
}, renderModal(), /*#__PURE__*/React.createElement(View, {
|
|
258
|
-
style: styles.otpContainer
|
|
259
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
260
|
-
style: styles.otpTitle
|
|
261
|
-
}, /*#__PURE__*/React.createElement(Text, null, "Enter the ", (_props$captureInput = props.captureInput) === null || _props$captureInput === void 0 ? void 0 : _props$captureInput.length, " digit OTP sent to the consignee to confirm order completion")), /*#__PURE__*/React.createElement(OTPInput, {
|
|
262
|
-
input: props.captureInput,
|
|
263
|
-
otpCode: otpCode,
|
|
264
|
-
setOTPCode: setOTPCode,
|
|
265
|
-
hasError: hasError,
|
|
266
|
-
setHasError: setHasError,
|
|
267
|
-
setErrorMessage: setErrorMessage
|
|
268
|
-
}), renderErrorMessage(), renderRetryButton()), renderButtons(), /*#__PURE__*/React.createElement(SnackBarCustom, {
|
|
433
|
+
}, /*#__PURE__*/React.createElement(SnackBarCustom, {
|
|
434
|
+
duration: 2000,
|
|
269
435
|
type: snackBar.type,
|
|
436
|
+
customBottom: 80,
|
|
270
437
|
message: `${snackBar.message}`,
|
|
271
438
|
visible: snackBar.show,
|
|
272
439
|
onDismiss: () => {
|
|
273
440
|
setSnackBar({
|
|
274
441
|
show: false,
|
|
275
442
|
message: '',
|
|
276
|
-
type: SnackBarType.
|
|
443
|
+
type: SnackBarType.OTP_SUCCESS
|
|
277
444
|
});
|
|
278
445
|
}
|
|
279
|
-
}))
|
|
280
|
-
}
|
|
281
|
-
|
|
446
|
+
}));
|
|
447
|
+
};
|
|
448
|
+
const renderContent = () => {
|
|
449
|
+
// if (loading) {
|
|
450
|
+
// return renderLoadingCard;
|
|
451
|
+
// }
|
|
452
|
+
|
|
453
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE) {
|
|
454
|
+
return /*#__PURE__*/React.createElement(VerificationComplete, _extends({}, props, {
|
|
455
|
+
setLoading: setLoading,
|
|
456
|
+
success: success,
|
|
457
|
+
retryCount: retryCount
|
|
458
|
+
}));
|
|
459
|
+
}
|
|
460
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST) {
|
|
461
|
+
return /*#__PURE__*/React.createElement(ContactListView, _extends({}, props, {
|
|
462
|
+
setIsContactVisited: setIsContactVisited,
|
|
463
|
+
handleSelectContact: handleSelectContact,
|
|
464
|
+
handleBackNavigation: handleBackNavigation,
|
|
465
|
+
contactList: contactList,
|
|
466
|
+
domain: domain
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW) {
|
|
470
|
+
return /*#__PURE__*/React.createElement(OTPView, _extends({}, props, {
|
|
471
|
+
isContactVisited: isContactVisited,
|
|
472
|
+
otpCode: otpCode,
|
|
473
|
+
otpInputConfig: otpInputConfig,
|
|
474
|
+
selectedContact: selectedContact,
|
|
475
|
+
setCurrentScreen: setCurrentScreen,
|
|
476
|
+
setErrorMessage: setErrorMessage,
|
|
477
|
+
setSnackBar: setSnackBar,
|
|
478
|
+
errorMessage: errorMessage,
|
|
479
|
+
setHasError: setHasError,
|
|
480
|
+
setOTPCode: setOTPCode,
|
|
481
|
+
setLoading: setLoading,
|
|
482
|
+
handleBackNavigation: handleBackNavigation,
|
|
483
|
+
hasError: hasError,
|
|
484
|
+
doorstepOTP: props.doorstepOTP,
|
|
485
|
+
setResendCount: setResendCount,
|
|
486
|
+
resendCount: resendCount,
|
|
487
|
+
resendConfig: resendConfig,
|
|
488
|
+
domain: domain
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
return null;
|
|
492
|
+
};
|
|
493
|
+
return /*#__PURE__*/React.createElement(Provider, null, /*#__PURE__*/React.createElement(Portal, null, loading ? /*#__PURE__*/React.createElement(ProgressDialog, {
|
|
494
|
+
customModalContentStyle: {
|
|
495
|
+
paddingVertical: 32
|
|
496
|
+
},
|
|
497
|
+
visible: loading,
|
|
498
|
+
label: "Loading",
|
|
499
|
+
labelStyle: {
|
|
500
|
+
fontWeight: '400',
|
|
501
|
+
marginTop: 16,
|
|
502
|
+
fontFamily: Platform.OS === 'android' ? Fonts.IBMPlexSans_400Regular : 'IBMPlexSans-Regular',
|
|
503
|
+
color: '#525B7A',
|
|
504
|
+
letterSpacing: 0.25
|
|
505
|
+
}
|
|
506
|
+
}) : currentScreen === VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE ? /*#__PURE__*/React.createElement(View, {
|
|
507
|
+
style: [CommonStyles.mainContainer]
|
|
508
|
+
}, /*#__PURE__*/React.createElement(VerificationComplete, _extends({}, props, {
|
|
509
|
+
setLoading: setLoading,
|
|
510
|
+
success: success,
|
|
511
|
+
retryCount: retryCount
|
|
512
|
+
}))) : currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST ? /*#__PURE__*/React.createElement(View, {
|
|
513
|
+
style: [CommonStyles.mainContainer]
|
|
514
|
+
}, renderGoBackModal(), renderCancelModal(), /*#__PURE__*/React.createElement(ContactListView, _extends({}, props, {
|
|
515
|
+
setIsContactVisited: setIsContactVisited,
|
|
516
|
+
handleSelectContact: handleSelectContact,
|
|
517
|
+
handleBackNavigation: handleBackNavigation,
|
|
518
|
+
contactList: contactList,
|
|
519
|
+
domain: domain
|
|
520
|
+
})), renderButtons(), renderSnackBar()) : currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW ? /*#__PURE__*/React.createElement(View, {
|
|
521
|
+
style: [CommonStyles.mainContainer]
|
|
522
|
+
}, renderGoBackModal(), renderCancelModal(), /*#__PURE__*/React.createElement(OTPView, _extends({}, props, {
|
|
523
|
+
isContactVisited: isContactVisited,
|
|
524
|
+
otpCode: otpCode,
|
|
525
|
+
otpInputConfig: otpInputConfig,
|
|
526
|
+
selectedContact: selectedContact,
|
|
527
|
+
setCurrentScreen: setCurrentScreen,
|
|
528
|
+
setErrorMessage: setErrorMessage,
|
|
529
|
+
setSnackBar: setSnackBar,
|
|
530
|
+
errorMessage: errorMessage,
|
|
531
|
+
setHasError: setHasError,
|
|
532
|
+
setOTPCode: setOTPCode,
|
|
533
|
+
setLoading: setLoading,
|
|
534
|
+
handleBackNavigation: handleBackNavigation,
|
|
535
|
+
hasError: hasError,
|
|
536
|
+
doorstepOTP: props.doorstepOTP,
|
|
537
|
+
setResendCount: setResendCount,
|
|
538
|
+
resendCount: resendCount,
|
|
539
|
+
resendConfig: resendConfig,
|
|
540
|
+
domain: domain
|
|
541
|
+
})), renderButtons(), renderSnackBar()) : null));
|
|
282
542
|
};
|
|
283
543
|
export default ValidateOTPET;
|
|
284
|
-
const styles = StyleSheet.create({
|
|
285
|
-
bottomView: {
|
|
286
|
-
flexDirection: 'row-reverse',
|
|
287
|
-
justifyContent: 'space-evenly',
|
|
288
|
-
padding: 16,
|
|
289
|
-
backgroundColor: 'white'
|
|
290
|
-
},
|
|
291
|
-
titleText: {
|
|
292
|
-
justifyContent: 'center',
|
|
293
|
-
fontFamily: Platform.OS === 'android' ? Fonts.IBMPlexSans_400Regular : 'IBMPlexSans-Regular',
|
|
294
|
-
fontStyle: 'normal',
|
|
295
|
-
fontSize: 16,
|
|
296
|
-
lineHeight: 20,
|
|
297
|
-
letterSpacing: 0.25,
|
|
298
|
-
textAlign: 'center',
|
|
299
|
-
color: '#3D445C',
|
|
300
|
-
marginBottom: 10
|
|
301
|
-
},
|
|
302
|
-
otpTitle: {
|
|
303
|
-
marginTop: 10,
|
|
304
|
-
marginBottom: 20,
|
|
305
|
-
fontFamily: Platform.OS === 'android' ? Fonts.IBMPlexSans_400Regular : 'IBMPlexSans-Regular',
|
|
306
|
-
fontStyle: 'normal',
|
|
307
|
-
fontSize: 16,
|
|
308
|
-
lineHeight: 20,
|
|
309
|
-
letterSpacing: 0.25,
|
|
310
|
-
color: '#3D445C',
|
|
311
|
-
alignItems: 'center'
|
|
312
|
-
},
|
|
313
|
-
otpContainer: {
|
|
314
|
-
marginTop: 20,
|
|
315
|
-
marginBottom: 40,
|
|
316
|
-
marginHorizontal: 10,
|
|
317
|
-
flex: 1
|
|
318
|
-
},
|
|
319
|
-
retryButton: {
|
|
320
|
-
alignItems: 'flex-start',
|
|
321
|
-
marginVertical: 10
|
|
322
|
-
},
|
|
323
|
-
errorMessage: {
|
|
324
|
-
marginTop: 16,
|
|
325
|
-
marginHorizontal: 10,
|
|
326
|
-
color: '#DC2626',
|
|
327
|
-
fontFamily: Platform.OS === 'android' ? Fonts.IBMPlexSans_400Regular : 'IBMPlexSans-Regular',
|
|
328
|
-
fontSize: 12,
|
|
329
|
-
lineHeight: 16
|
|
330
|
-
},
|
|
331
|
-
subText: {
|
|
332
|
-
justifyContent: 'center',
|
|
333
|
-
fontFamily: Platform.OS === 'android' ? Fonts.IBMPlexSans_400Regular : 'IBMPlexSans-Regular',
|
|
334
|
-
fontStyle: 'normal',
|
|
335
|
-
fontSize: 14,
|
|
336
|
-
letterSpacing: 0.25,
|
|
337
|
-
lineHeight: 20,
|
|
338
|
-
textAlign: 'center',
|
|
339
|
-
color: '#000000',
|
|
340
|
-
marginBottom: 10
|
|
341
|
-
},
|
|
342
|
-
modalContent: {
|
|
343
|
-
marginStart: 60,
|
|
344
|
-
marginEnd: 60,
|
|
345
|
-
flex: 1,
|
|
346
|
-
marginBottom: 60
|
|
347
|
-
},
|
|
348
|
-
modalView: {
|
|
349
|
-
backgroundColor: 'white',
|
|
350
|
-
padding: 15,
|
|
351
|
-
borderRadius: 9
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
544
|
//# sourceMappingURL=ValidateOTPET.js.map
|