@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,264 +1,467 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
3
|
+
// External Libraries
|
|
4
|
+
import React, {
|
|
5
|
+
useState,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useEffect,
|
|
8
|
+
FC,
|
|
9
|
+
useContext,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { View, Text, Platform } from 'react-native';
|
|
12
|
+
|
|
13
|
+
// UI Libraries and Icons
|
|
8
14
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
ActivityIndicator,
|
|
16
|
+
Button,
|
|
17
|
+
Portal,
|
|
18
|
+
Provider,
|
|
19
|
+
} from 'react-native-paper';
|
|
20
|
+
|
|
21
|
+
// Utility Functions and Hooks
|
|
22
|
+
import { getBaseETResponse } from '../../../utils/ExecTaskUtils';
|
|
23
|
+
import { hasGoBackConnector } from '../../../components/utils';
|
|
14
24
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
countType,
|
|
26
|
+
generateOTP,
|
|
27
|
+
getCount,
|
|
28
|
+
parseResendConfig,
|
|
29
|
+
updateResendCount,
|
|
30
|
+
updateRetryCount,
|
|
31
|
+
VALIDATE_OTP_SCREENS,
|
|
32
|
+
verifyOTP,
|
|
33
|
+
} from './utils';
|
|
34
|
+
|
|
35
|
+
// Dispatch Codes and Models
|
|
36
|
+
import { getEventCodeByET } from '../../../manager/dispatchCodes/EventCodeContainer';
|
|
20
37
|
import {
|
|
21
38
|
EntityCode,
|
|
22
39
|
ExecutionTaskID,
|
|
23
40
|
} from '../../../models/execTasks/ETConfig';
|
|
24
|
-
import {
|
|
25
|
-
|
|
41
|
+
import { ValidateOTPContext } from '../../../utils/context/valdiateOTPContext';
|
|
42
|
+
|
|
43
|
+
// Schema and Types
|
|
44
|
+
import {
|
|
45
|
+
ContactTypes,
|
|
46
|
+
InputType,
|
|
47
|
+
OtpDeliveryMethodTypes,
|
|
48
|
+
OtpInputConfigType,
|
|
49
|
+
ResendOTPConfigType,
|
|
50
|
+
SetSnackBarType,
|
|
51
|
+
ValidationType,
|
|
52
|
+
type ValidateOTPInput,
|
|
53
|
+
} from './ValidateOTPSchema';
|
|
54
|
+
|
|
55
|
+
// Constants
|
|
56
|
+
import { GO_BACK_EVENT_CODE } from '../../../constants/constants';
|
|
57
|
+
import {
|
|
58
|
+
ERROR_GENERATING_OTP,
|
|
59
|
+
ERROR_VALIDATE_OTP,
|
|
60
|
+
INVALID_OTP,
|
|
61
|
+
INVALID_OTP_LENGTH,
|
|
62
|
+
INVALID_OTP_ONE_ATTEMPT_LEFT,
|
|
63
|
+
OTP_SENT_SUCCESSFULLY,
|
|
64
|
+
UNABLE_TO_SEND_OTP,
|
|
65
|
+
} from './constants';
|
|
66
|
+
|
|
67
|
+
// Components
|
|
26
68
|
import SnackBarCustom, {
|
|
27
69
|
SnackBarType,
|
|
28
70
|
} from '../../../components/widgets/SnackBarCustom';
|
|
29
|
-
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
30
|
-
import { GO_BACK_EVENT_CODE } from '../../../constants/constants';
|
|
31
|
-
import { hasGoBackConnector } from '../../../components/utils';
|
|
32
71
|
import GoBackModal from '../../../components/widgets/GoBackModal';
|
|
33
|
-
import
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
72
|
+
import ConfirmCancelModal from '../../../components/widgets/ConfirmCancelModal';
|
|
73
|
+
import { OTPView } from './components/OTPView';
|
|
74
|
+
import { ContactListView } from './components/ContactListView';
|
|
75
|
+
import VerificationComplete from './components/VerificationComplete';
|
|
76
|
+
import ProgressDialog from '../../widgets/ProgressDialog';
|
|
36
77
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const onBackPress = () => {
|
|
44
|
-
if (
|
|
45
|
-
props.taskMeta?.enableGoBack &&
|
|
46
|
-
hasGoBackConnector(props.applicableReasons)
|
|
47
|
-
) {
|
|
48
|
-
setShowBackModal(true);
|
|
49
|
-
return true;
|
|
50
|
-
} else {
|
|
51
|
-
props.navigation.goBack();
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
BackHandler.addEventListener('hardwareBackPress', onBackPress);
|
|
56
|
-
return () =>
|
|
57
|
-
BackHandler.removeEventListener('hardwareBackPress', onBackPress);
|
|
58
|
-
}, [])
|
|
59
|
-
);
|
|
78
|
+
// Styles
|
|
79
|
+
import styles from './ValidateOtpStyles';
|
|
80
|
+
import {
|
|
81
|
+
CommonStyles,
|
|
82
|
+
Fonts,
|
|
83
|
+
} from '../../../styles/executionTasks/CommonStyles';
|
|
60
84
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
props.taskMeta?.enableGoBack &&
|
|
70
|
-
hasGoBackConnector(props.applicableReasons)
|
|
71
|
-
)
|
|
72
|
-
setShowBackModal(true);
|
|
73
|
-
else props.navigation.goBack();
|
|
74
|
-
const cta = 'Arrow Back';
|
|
75
|
-
fireEventWithScreenName({ severityLevel: SeverityLevelValue.LOG, eventName: SentryEventNameSdkConstants.BUTTON_CLICKED, screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN, cta: cta });
|
|
76
|
-
|
|
77
|
-
}}
|
|
78
|
-
name="arrow-back"
|
|
79
|
-
color={'black'}
|
|
80
|
-
size={25}
|
|
81
|
-
style={{
|
|
82
|
-
paddingRight: 15,
|
|
83
|
-
paddingTop: 5,
|
|
84
|
-
}}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
}, [props.navigation, props.title]);
|
|
85
|
+
// Analytics
|
|
86
|
+
import {
|
|
87
|
+
ScreenNameSdkConstants,
|
|
88
|
+
SentryEventNameSdkConstants,
|
|
89
|
+
SeverityLevelValue,
|
|
90
|
+
} from '../../../analytics/sentry/SentrySdkConstants';
|
|
91
|
+
import { fireEventWithScreenName } from '../../../analytics/sentry/SentryAnalyticsUtils';
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
const ValidateOTPET: FC<ValidateOTPInput> = (props) => {
|
|
94
|
+
const { contacts, navigation } = props;
|
|
95
|
+
// Context
|
|
96
|
+
const validateConfigContext = useContext(ValidateOTPContext);
|
|
97
|
+
const domain = validateConfigContext?.sdkConfig?.validateOtpDomain ?? '';
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
// Configurations
|
|
100
|
+
const resendConfig: ResendOTPConfigType = parseResendConfig(props.resendOTP);
|
|
101
|
+
const otpInputConfig: OtpInputConfigType = {
|
|
102
|
+
inputType: props.inputType || InputType.NUMBER,
|
|
103
|
+
length: props.otpLength || 6,
|
|
104
|
+
validationRegex: `^[0-9]+$`,
|
|
105
|
+
};
|
|
99
106
|
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
// State: Contact Management
|
|
108
|
+
const [contactList, setContactList] = useState<ContactTypes[]>(contacts);
|
|
109
|
+
const [selectedContact, setSelectedContact] = useState<ContactTypes>(
|
|
110
|
+
contactList[0] || null
|
|
111
|
+
);
|
|
112
|
+
const [isContactVisited, setIsContactVisited] = useState<boolean>(
|
|
113
|
+
props.doorstepOTP
|
|
102
114
|
);
|
|
103
|
-
const [retryCount, setRetryCount] = useState(0);
|
|
104
115
|
|
|
116
|
+
// State: OTP Handling
|
|
105
117
|
const [userInput, setUserInput] = useState({
|
|
106
118
|
captureInput: '',
|
|
107
119
|
});
|
|
108
120
|
const { captureInput: otpCode } = userInput;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
setUserInput({ ...userInput, captureInput: otpCode });
|
|
121
|
+
const setOTPCode = (code: string) => {
|
|
122
|
+
setUserInput({ ...userInput, captureInput: code });
|
|
112
123
|
};
|
|
124
|
+
const [retryCount, setRetryCount] = useState<number>(0);
|
|
125
|
+
const [resendCount, setResendCount] = useState<number>(0);
|
|
126
|
+
const [disableProceedBtn, setDisableProceedBtn] = useState(false);
|
|
113
127
|
|
|
114
|
-
|
|
115
|
-
const [
|
|
128
|
+
// State: UI and Navigation
|
|
129
|
+
const [showBackModal, setShowBackModal] = useState<boolean>(false);
|
|
130
|
+
const [showCancelModal, setShowCancelModal] = useState<boolean>(false);
|
|
131
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
132
|
+
const [hasError, setHasError] = useState<boolean>(false);
|
|
133
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
134
|
+
const [success, setSuccess] = useState<boolean>(false);
|
|
135
|
+
const [shouldNavigateBack, setShouldNavigateBack] = useState<boolean>(false);
|
|
136
|
+
const [currentScreen, setCurrentScreen] = useState<string>(
|
|
137
|
+
props.doorstepOTP
|
|
138
|
+
? VALIDATE_OTP_SCREENS.CONTACT_LIST
|
|
139
|
+
: VALIDATE_OTP_SCREENS.OTP_VIEW
|
|
140
|
+
);
|
|
116
141
|
|
|
117
|
-
|
|
142
|
+
// State: SnackBar
|
|
143
|
+
const [snackBar, setSnackBar] = useState<SetSnackBarType>({
|
|
118
144
|
show: false,
|
|
119
|
-
type: SnackBarType.
|
|
145
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
120
146
|
message: '',
|
|
121
147
|
});
|
|
122
148
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
onPress={async () => {
|
|
133
|
-
// send OTP Generation using props
|
|
134
|
-
if (
|
|
135
|
-
sendOTP &&
|
|
136
|
-
props.generationLogic &&
|
|
137
|
-
props.generationLogic?.generateOnLoad
|
|
138
|
-
) {
|
|
139
|
-
const response = await generateOTP(props.generationLogic.api);
|
|
140
|
-
resetTimer();
|
|
141
|
-
if (response) setSendOTP(false);
|
|
142
|
-
else
|
|
143
|
-
setSnackBar({
|
|
144
|
-
show: true,
|
|
145
|
-
message: ERROR_GENERATING_OTP,
|
|
146
|
-
type: SnackBarType.FAILURE,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
// check for Validation
|
|
150
|
-
else if (!sendOTP) {
|
|
151
|
-
if (otpCode.length < props.captureInput.length) {
|
|
152
|
-
setSnackBar({
|
|
153
|
-
show: true,
|
|
154
|
-
message: INVALID_OTP_LENGTH.replace(
|
|
155
|
-
'<length>',
|
|
156
|
-
`${props.captureInput.length}`
|
|
157
|
-
),
|
|
158
|
-
type: SnackBarType.FAILURE,
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
const isValid = await checkForValidation(
|
|
162
|
-
otpCode,
|
|
163
|
-
props.validation,
|
|
164
|
-
{ userInput }
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
if (!isValid) {
|
|
168
|
-
setErrorMessage(INVALID_OTP);
|
|
169
|
-
setHasError(true);
|
|
170
|
-
} else {
|
|
171
|
-
props.onSubmitET({
|
|
172
|
-
...(await getBaseETResponse(
|
|
173
|
-
EntityCode.VALIDATE_OTP_ET,
|
|
174
|
-
true,
|
|
175
|
-
getEventCodeByET(
|
|
176
|
-
ExecutionTaskID.VALIDATE_OTP_ET,
|
|
177
|
-
true,
|
|
178
|
-
props.applicableReasons?.success
|
|
179
|
-
),
|
|
180
|
-
'',
|
|
181
|
-
props.mergedObjectiveId,
|
|
182
|
-
ExecutionTaskID.VALIDATE_OTP_ET
|
|
183
|
-
)),
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const cta = 'Proceed';
|
|
189
|
-
fireEventWithScreenName({ severityLevel: SeverityLevelValue.LOG, eventName: SentryEventNameSdkConstants.BUTTON_CLICKED, screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN, cta: cta });
|
|
190
|
-
|
|
191
|
-
}}
|
|
192
|
-
>
|
|
193
|
-
Proceed
|
|
194
|
-
</Button>
|
|
195
|
-
</View>
|
|
196
|
-
<View>
|
|
197
|
-
<Button
|
|
198
|
-
style={[CommonStyles.cancelButton, { width: 165, marginEnd: 10 }]}
|
|
199
|
-
labelStyle={CommonStyles.cancelButtonLabel}
|
|
200
|
-
mode={'outlined'}
|
|
201
|
-
uppercase={false}
|
|
202
|
-
onPress={async () => {
|
|
203
|
-
// Cancel the ET
|
|
204
|
-
props.onSubmitET({
|
|
205
|
-
...(await getBaseETResponse(
|
|
206
|
-
EntityCode.VALIDATE_OTP_ET,
|
|
207
|
-
false,
|
|
208
|
-
getEventCodeByET(
|
|
209
|
-
ExecutionTaskID.VALIDATE_OTP_ET,
|
|
210
|
-
false,
|
|
211
|
-
props.applicableReasons?.failure
|
|
212
|
-
),
|
|
213
|
-
'',
|
|
214
|
-
props.mergedObjectiveId,
|
|
215
|
-
ExecutionTaskID.VALIDATE_OTP_ET
|
|
216
|
-
)),
|
|
217
|
-
});
|
|
218
|
-
const cta = 'Skip';
|
|
219
|
-
fireEventWithScreenName({ severityLevel: SeverityLevelValue.LOG, eventName: SentryEventNameSdkConstants.BUTTON_CLICKED, screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN, cta: cta });
|
|
220
|
-
|
|
221
|
-
}}
|
|
222
|
-
>
|
|
223
|
-
Skip
|
|
224
|
-
</Button>
|
|
225
|
-
</View>
|
|
226
|
-
</View>
|
|
227
|
-
);
|
|
228
|
-
};
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const fetchCounts = async () => {
|
|
151
|
+
// eslint-disable-next-line no-shadow
|
|
152
|
+
const retryCount = await getCount(countType.RETRY);
|
|
153
|
+
// eslint-disable-next-line no-shadow
|
|
154
|
+
const resendCount = await getCount(countType.RESEND);
|
|
155
|
+
setRetryCount(retryCount);
|
|
156
|
+
setResendCount(resendCount);
|
|
157
|
+
};
|
|
229
158
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const enableRetry = props.generationLogic?.enableRetry;
|
|
159
|
+
fetchCounts();
|
|
160
|
+
}, []);
|
|
233
161
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
162
|
+
// TO hide header for modal screen
|
|
163
|
+
useLayoutEffect(() => {
|
|
164
|
+
navigation.setOptions({
|
|
165
|
+
// headerShown: loading ? false : true,
|
|
166
|
+
headerStyle: {
|
|
167
|
+
display: loading ? 'none' : 'flex', // Hide the header by setting its display to 'none'
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
171
|
+
}, [loading]);
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW) {
|
|
175
|
+
setDisableProceedBtn(
|
|
176
|
+
otpCode?.length !== otpInputConfig.length ||
|
|
177
|
+
!selectedContact ||
|
|
178
|
+
hasError
|
|
251
179
|
);
|
|
252
|
-
} else
|
|
180
|
+
} else {
|
|
181
|
+
setDisableProceedBtn(!selectedContact);
|
|
182
|
+
}
|
|
183
|
+
}, [
|
|
184
|
+
currentScreen,
|
|
185
|
+
hasError,
|
|
186
|
+
otpCode?.length,
|
|
187
|
+
otpInputConfig.length,
|
|
188
|
+
selectedContact,
|
|
189
|
+
]);
|
|
190
|
+
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (!contacts) return;
|
|
193
|
+
|
|
194
|
+
// Filter contacts based on the delivery method, or use all contacts if BOTH
|
|
195
|
+
const filteredContacts = contacts
|
|
196
|
+
.filter((contact) =>
|
|
197
|
+
props.otpDeliveryMethod === OtpDeliveryMethodTypes.BOTH
|
|
198
|
+
? true
|
|
199
|
+
: contact.mode?.toLowerCase() ===
|
|
200
|
+
props.otpDeliveryMethod?.toLowerCase()
|
|
201
|
+
)
|
|
202
|
+
.map((contact, index) => ({
|
|
203
|
+
...contact,
|
|
204
|
+
isSelected: index === 0, // Select the first contact by default
|
|
205
|
+
}));
|
|
206
|
+
|
|
207
|
+
// Update the state with the filtered contacts
|
|
208
|
+
setContactList(filteredContacts);
|
|
209
|
+
if (props.doorstepOTP) {
|
|
210
|
+
setSelectedContact(filteredContacts[0]);
|
|
211
|
+
}
|
|
212
|
+
}, [contacts, props.doorstepOTP, props.otpDeliveryMethod]);
|
|
213
|
+
|
|
214
|
+
// Monitor shouldNavigateBack to trigger navigation if set
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (shouldNavigateBack) {
|
|
217
|
+
navigation.goBack();
|
|
218
|
+
setOTPCode('');
|
|
219
|
+
}
|
|
220
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
221
|
+
}, [navigation, shouldNavigateBack]);
|
|
222
|
+
|
|
223
|
+
const handleBackNavigation = () => {
|
|
224
|
+
if (
|
|
225
|
+
props.taskMeta?.enableGoBack &&
|
|
226
|
+
hasGoBackConnector(props.applicableReasons)
|
|
227
|
+
) {
|
|
228
|
+
setShowBackModal(true);
|
|
229
|
+
} else {
|
|
230
|
+
setShouldNavigateBack(true);
|
|
231
|
+
}
|
|
232
|
+
return true;
|
|
253
233
|
};
|
|
254
234
|
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
235
|
+
const onProceedCancel = async () => {
|
|
236
|
+
// Cancel the ET
|
|
237
|
+
props.onSubmitET({
|
|
238
|
+
...(await getBaseETResponse(
|
|
239
|
+
EntityCode.VALIDATE_OTP_ET,
|
|
240
|
+
false,
|
|
241
|
+
getEventCodeByET(
|
|
242
|
+
ExecutionTaskID.VALIDATE_OTP_ET,
|
|
243
|
+
false,
|
|
244
|
+
props.applicableReasons?.failure
|
|
245
|
+
),
|
|
246
|
+
'',
|
|
247
|
+
props.mergedObjectiveId,
|
|
248
|
+
ExecutionTaskID.VALIDATE_OTP_ET
|
|
249
|
+
)),
|
|
250
|
+
retryCount: retryCount,
|
|
251
|
+
});
|
|
252
|
+
const cta = 'Cancel';
|
|
253
|
+
fireEventWithScreenName({
|
|
254
|
+
severityLevel: SeverityLevelValue.LOG,
|
|
255
|
+
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
256
|
+
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
257
|
+
cta: cta,
|
|
258
|
+
});
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
-
const
|
|
261
|
+
const handleContactListProceed = async () => {
|
|
262
|
+
try {
|
|
263
|
+
setSnackBar({
|
|
264
|
+
show: false,
|
|
265
|
+
message: '',
|
|
266
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
267
|
+
});
|
|
268
|
+
setLoading(true);
|
|
269
|
+
|
|
270
|
+
const payload = {
|
|
271
|
+
jobId: props.orderData[0]?.jobId,
|
|
272
|
+
refId: props.refId,
|
|
273
|
+
objectiveId: props.workflowId,
|
|
274
|
+
contactInfo: {
|
|
275
|
+
id: selectedContact.id,
|
|
276
|
+
mode: selectedContact.mode,
|
|
277
|
+
type: selectedContact.type,
|
|
278
|
+
index: selectedContact.index,
|
|
279
|
+
},
|
|
280
|
+
meta: {
|
|
281
|
+
orderIds: props.orderData?.map(
|
|
282
|
+
(order) => order?.displayInfo?.orderId
|
|
283
|
+
),
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const response = await generateOTP(payload, { ...props, domain });
|
|
288
|
+
|
|
289
|
+
if (!response?.status) {
|
|
290
|
+
if (!response.status && response?.code === '101080001017') {
|
|
291
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.OTP_VIEW);
|
|
292
|
+
setLoading(false);
|
|
293
|
+
setSnackBar({
|
|
294
|
+
show: true,
|
|
295
|
+
message: response?.data?.result?.message || UNABLE_TO_SEND_OTP,
|
|
296
|
+
type: SnackBarType.OTP_FAILED,
|
|
297
|
+
});
|
|
298
|
+
} else {
|
|
299
|
+
setLoading(false);
|
|
300
|
+
setSnackBar({
|
|
301
|
+
show: true,
|
|
302
|
+
message: response?.data?.result?.message || ERROR_GENERATING_OTP,
|
|
303
|
+
type: SnackBarType.OTP_FAILED,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const resendCountValue =
|
|
311
|
+
Number(
|
|
312
|
+
response?.data?.result?.resendCount ||
|
|
313
|
+
response?.additionalInfo?.resendOTP
|
|
314
|
+
) || 0;
|
|
315
|
+
|
|
316
|
+
setResendCount(resendCountValue);
|
|
317
|
+
await updateResendCount(resendCountValue);
|
|
318
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.OTP_VIEW);
|
|
319
|
+
setLoading(false);
|
|
320
|
+
setSnackBar({
|
|
321
|
+
show: true,
|
|
322
|
+
message: OTP_SENT_SUCCESSFULLY,
|
|
323
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
324
|
+
});
|
|
325
|
+
} catch (error) {
|
|
326
|
+
setLoading(false);
|
|
327
|
+
console.error('Error in handleContactListProceed:', error);
|
|
328
|
+
setSnackBar({
|
|
329
|
+
show: true,
|
|
330
|
+
message: ERROR_GENERATING_OTP,
|
|
331
|
+
type: SnackBarType.OTP_FAILED,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const handleOTPViewProceed = async () => {
|
|
337
|
+
if (otpCode.length < props.otpLength) {
|
|
338
|
+
// Show error if OTP length is invalid
|
|
339
|
+
setSnackBar({
|
|
340
|
+
show: true,
|
|
341
|
+
message: INVALID_OTP_LENGTH.replace('<length>', `${props.otpLength}`),
|
|
342
|
+
type: SnackBarType.OTP_FAILED,
|
|
343
|
+
});
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const payload = {
|
|
348
|
+
refId: props.refId,
|
|
349
|
+
otp: otpCode,
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const isOnlineValidation = props?.otpValidation
|
|
353
|
+
? props?.otpValidation?.toString()?.toLowerCase() ===
|
|
354
|
+
ValidationType.ONLINE?.toString()?.toLowerCase()
|
|
355
|
+
: true;
|
|
356
|
+
|
|
357
|
+
const response = isOnlineValidation
|
|
358
|
+
? await verifyOTP(payload, { ...props, domain })
|
|
359
|
+
: otpCode === props.offlineOtpValue;
|
|
360
|
+
|
|
361
|
+
const retryCountValue =
|
|
362
|
+
Number(
|
|
363
|
+
response?.result?.retryCount || response?.additionalInfo?.retryCount
|
|
364
|
+
) || retryCount + 1;
|
|
365
|
+
|
|
366
|
+
if (response === false || response?.status === false || !response) {
|
|
367
|
+
setOTPCode('');
|
|
368
|
+
setRetryCount(retryCountValue);
|
|
369
|
+
await updateRetryCount(retryCountValue);
|
|
370
|
+
|
|
371
|
+
if (props.maxRetries - retryCountValue === 1) {
|
|
372
|
+
setSnackBar({
|
|
373
|
+
show: true,
|
|
374
|
+
message: INVALID_OTP_ONE_ATTEMPT_LEFT,
|
|
375
|
+
type: SnackBarType.OTP_FAILED,
|
|
376
|
+
});
|
|
377
|
+
} else if (retryCountValue >= props.maxRetries) {
|
|
378
|
+
setSuccess(false);
|
|
379
|
+
setSnackBar({
|
|
380
|
+
show: false,
|
|
381
|
+
message: '',
|
|
382
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
383
|
+
});
|
|
384
|
+
setLoading(true);
|
|
385
|
+
setTimeout(() => {
|
|
386
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE);
|
|
387
|
+
setLoading(false);
|
|
388
|
+
}, 1000);
|
|
389
|
+
} else {
|
|
390
|
+
setSnackBar({
|
|
391
|
+
show: true,
|
|
392
|
+
message: INVALID_OTP.replace(
|
|
393
|
+
'<length>',
|
|
394
|
+
`${props.maxRetries - retryCountValue}`
|
|
395
|
+
),
|
|
396
|
+
type: SnackBarType.OTP_FAILED,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
setSuccess(true);
|
|
401
|
+
setSnackBar({
|
|
402
|
+
show: false,
|
|
403
|
+
message: '',
|
|
404
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
405
|
+
});
|
|
406
|
+
setLoading(true);
|
|
407
|
+
setTimeout(() => {
|
|
408
|
+
setCurrentScreen(VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE);
|
|
409
|
+
setLoading(false);
|
|
410
|
+
}, 1000);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const onProceed = async () => {
|
|
415
|
+
try {
|
|
416
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST) {
|
|
417
|
+
handleContactListProceed();
|
|
418
|
+
} else {
|
|
419
|
+
handleOTPViewProceed();
|
|
420
|
+
}
|
|
421
|
+
const cta = 'Proceed';
|
|
422
|
+
fireEventWithScreenName({
|
|
423
|
+
severityLevel: SeverityLevelValue.LOG,
|
|
424
|
+
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
425
|
+
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
426
|
+
cta: cta,
|
|
427
|
+
});
|
|
428
|
+
} catch (error) {
|
|
429
|
+
setLoading(false);
|
|
430
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST) {
|
|
431
|
+
setSnackBar({
|
|
432
|
+
show: true,
|
|
433
|
+
message: ERROR_GENERATING_OTP,
|
|
434
|
+
type: SnackBarType.OTP_FAILED,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW) {
|
|
438
|
+
setSnackBar({
|
|
439
|
+
show: true,
|
|
440
|
+
message: ERROR_VALIDATE_OTP,
|
|
441
|
+
type: SnackBarType.OTP_FAILED,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const onCancelET = () => {
|
|
450
|
+
setShowCancelModal(true);
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
const handleSelectContact = (contactDetails: ContactTypes) => {
|
|
454
|
+
setSelectedContact(contactDetails);
|
|
455
|
+
setContactList((prevContactList) =>
|
|
456
|
+
prevContactList.map((contact: ContactTypes) => ({
|
|
457
|
+
...contact,
|
|
458
|
+
isSelected: contact?.value === contactDetails.value,
|
|
459
|
+
}))
|
|
460
|
+
);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// *Rendering components*
|
|
464
|
+
const renderGoBackModal = () => {
|
|
262
465
|
return (
|
|
263
466
|
<GoBackModal
|
|
264
467
|
showModal={showBackModal}
|
|
@@ -273,6 +476,7 @@ const ValidateOTPET = (props: ValidateOTPInput) => {
|
|
|
273
476
|
props.mergedObjectiveId,
|
|
274
477
|
ExecutionTaskID.VALIDATE_OTP_ET
|
|
275
478
|
)),
|
|
479
|
+
retryCount: retryCount,
|
|
276
480
|
});
|
|
277
481
|
setShowBackModal(false);
|
|
278
482
|
}}
|
|
@@ -281,170 +485,239 @@ const ValidateOTPET = (props: ValidateOTPInput) => {
|
|
|
281
485
|
);
|
|
282
486
|
};
|
|
283
487
|
|
|
284
|
-
|
|
488
|
+
const renderCancelModal = () => {
|
|
285
489
|
return (
|
|
286
|
-
<
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
490
|
+
<ConfirmCancelModal
|
|
491
|
+
showModal={showCancelModal}
|
|
492
|
+
setShowModal={setShowCancelModal}
|
|
493
|
+
onSuccess={() => {
|
|
494
|
+
onProceedCancel();
|
|
495
|
+
setShowCancelModal(false);
|
|
496
|
+
}}
|
|
497
|
+
onFailure={() => setShowCancelModal(false)}
|
|
498
|
+
/>
|
|
499
|
+
);
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const renderButtons = () => {
|
|
503
|
+
if (loading || currentScreen === VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE)
|
|
504
|
+
return null;
|
|
505
|
+
return (
|
|
506
|
+
<View style={styles.bottomView}>
|
|
507
|
+
<Button
|
|
508
|
+
style={[
|
|
509
|
+
styles.mainBtnStyles,
|
|
510
|
+
CommonStyles.nextButton,
|
|
511
|
+
{ borderRadius: 6 },
|
|
512
|
+
disableProceedBtn && { backgroundColor: '#E0E3EB' },
|
|
513
|
+
]}
|
|
514
|
+
labelStyle={[
|
|
515
|
+
CommonStyles.nextButtonLabel,
|
|
516
|
+
styles.activeBtnText,
|
|
517
|
+
disableProceedBtn && disableProceedBtn && { color: '#A3AAC2' },
|
|
518
|
+
]}
|
|
519
|
+
mode={'contained'}
|
|
520
|
+
uppercase={false}
|
|
521
|
+
disabled={disableProceedBtn}
|
|
522
|
+
onPress={onProceed}
|
|
523
|
+
>
|
|
524
|
+
Proceed
|
|
525
|
+
</Button>
|
|
526
|
+
{props.restrictCancel === true || props.allowCancel === false
|
|
527
|
+
? null
|
|
528
|
+
: props.isSelfLoop == false && (
|
|
529
|
+
<Button
|
|
530
|
+
style={[
|
|
531
|
+
styles.mainBtnStyles,
|
|
532
|
+
CommonStyles.cancelButton,
|
|
533
|
+
{ borderRadius: 4 },
|
|
534
|
+
]}
|
|
535
|
+
labelStyle={[
|
|
536
|
+
CommonStyles.cancelButtonLabel,
|
|
537
|
+
styles.cancelBtnText,
|
|
538
|
+
]}
|
|
539
|
+
mode={'outlined'}
|
|
540
|
+
uppercase={false}
|
|
541
|
+
onPress={onCancelET}
|
|
542
|
+
>
|
|
543
|
+
Cancel
|
|
544
|
+
</Button>
|
|
545
|
+
)}
|
|
546
|
+
</View>
|
|
547
|
+
);
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
const renderLoadingCard = () => {
|
|
551
|
+
return (
|
|
552
|
+
<View
|
|
553
|
+
style={{
|
|
554
|
+
flex: 1,
|
|
555
|
+
justifyContent: 'center',
|
|
556
|
+
}}
|
|
557
|
+
>
|
|
558
|
+
<View style={styles.loadingCard}>
|
|
559
|
+
<ActivityIndicator size="small" color="rgba(107, 142, 255, 1)" />
|
|
560
|
+
<Text style={styles.loadingText}>Loading</Text>
|
|
320
561
|
</View>
|
|
321
|
-
</
|
|
562
|
+
</View>
|
|
322
563
|
);
|
|
323
|
-
}
|
|
324
|
-
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
const renderSnackBar = () => {
|
|
567
|
+
if (!snackBar.show) return null; // Show snackbar only when `snackBar.show` is true
|
|
325
568
|
return (
|
|
326
|
-
<
|
|
327
|
-
<
|
|
328
|
-
{
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
569
|
+
<View style={{ marginHorizontal: 6 }}>
|
|
570
|
+
<SnackBarCustom
|
|
571
|
+
duration={2000}
|
|
572
|
+
type={snackBar.type}
|
|
573
|
+
customBottom={80}
|
|
574
|
+
message={`${snackBar.message}`}
|
|
575
|
+
visible={snackBar.show}
|
|
576
|
+
onDismiss={() => {
|
|
577
|
+
setSnackBar({
|
|
578
|
+
show: false,
|
|
579
|
+
message: '',
|
|
580
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
581
|
+
});
|
|
582
|
+
}}
|
|
583
|
+
/>
|
|
584
|
+
</View>
|
|
585
|
+
);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const renderContent = () => {
|
|
589
|
+
// if (loading) {
|
|
590
|
+
// return renderLoadingCard;
|
|
591
|
+
// }
|
|
592
|
+
|
|
593
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE) {
|
|
594
|
+
return (
|
|
595
|
+
<VerificationComplete
|
|
596
|
+
{...props}
|
|
597
|
+
setLoading={setLoading}
|
|
598
|
+
success={success}
|
|
599
|
+
retryCount={retryCount}
|
|
600
|
+
/>
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST) {
|
|
605
|
+
return (
|
|
606
|
+
<ContactListView
|
|
607
|
+
{...props}
|
|
608
|
+
setIsContactVisited={setIsContactVisited}
|
|
609
|
+
handleSelectContact={handleSelectContact}
|
|
610
|
+
handleBackNavigation={handleBackNavigation}
|
|
611
|
+
contactList={contactList}
|
|
612
|
+
domain={domain}
|
|
613
|
+
/>
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW) {
|
|
618
|
+
return (
|
|
619
|
+
<OTPView
|
|
620
|
+
{...props}
|
|
621
|
+
isContactVisited={isContactVisited}
|
|
622
|
+
otpCode={otpCode}
|
|
623
|
+
otpInputConfig={otpInputConfig}
|
|
624
|
+
selectedContact={selectedContact}
|
|
625
|
+
setCurrentScreen={setCurrentScreen}
|
|
626
|
+
setErrorMessage={setErrorMessage}
|
|
627
|
+
setSnackBar={setSnackBar}
|
|
628
|
+
errorMessage={errorMessage}
|
|
629
|
+
setHasError={setHasError}
|
|
630
|
+
setOTPCode={setOTPCode}
|
|
631
|
+
setLoading={setLoading}
|
|
632
|
+
handleBackNavigation={handleBackNavigation}
|
|
633
|
+
hasError={hasError}
|
|
634
|
+
doorstepOTP={props.doorstepOTP}
|
|
635
|
+
setResendCount={setResendCount}
|
|
636
|
+
resendCount={resendCount}
|
|
637
|
+
resendConfig={resendConfig}
|
|
638
|
+
domain={domain}
|
|
639
|
+
/>
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return null;
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
return (
|
|
647
|
+
<Provider>
|
|
648
|
+
<Portal>
|
|
649
|
+
{loading ? (
|
|
650
|
+
<ProgressDialog
|
|
651
|
+
customModalContentStyle={{ paddingVertical: 32 }}
|
|
652
|
+
visible={loading}
|
|
653
|
+
label="Loading"
|
|
654
|
+
labelStyle={{
|
|
655
|
+
fontWeight: '400',
|
|
656
|
+
marginTop: 16,
|
|
657
|
+
fontFamily:
|
|
658
|
+
Platform.OS === 'android'
|
|
659
|
+
? Fonts.IBMPlexSans_400Regular
|
|
660
|
+
: 'IBMPlexSans-Regular',
|
|
661
|
+
color: '#525B7A',
|
|
662
|
+
letterSpacing: 0.25,
|
|
663
|
+
}}
|
|
664
|
+
/>
|
|
665
|
+
) : currentScreen === VALIDATE_OTP_SCREENS.VERIFICATION_COMPLETE ? (
|
|
666
|
+
<View style={[CommonStyles.mainContainer]}>
|
|
667
|
+
<VerificationComplete
|
|
668
|
+
{...props}
|
|
669
|
+
setLoading={setLoading}
|
|
670
|
+
success={success}
|
|
671
|
+
retryCount={retryCount}
|
|
672
|
+
/>
|
|
673
|
+
</View>
|
|
674
|
+
) : currentScreen === VALIDATE_OTP_SCREENS.CONTACT_LIST ? (
|
|
675
|
+
<View style={[CommonStyles.mainContainer]}>
|
|
676
|
+
{renderGoBackModal()}
|
|
677
|
+
{renderCancelModal()}
|
|
678
|
+
<ContactListView
|
|
679
|
+
{...props}
|
|
680
|
+
setIsContactVisited={setIsContactVisited}
|
|
681
|
+
handleSelectContact={handleSelectContact}
|
|
682
|
+
handleBackNavigation={handleBackNavigation}
|
|
683
|
+
contactList={contactList}
|
|
684
|
+
domain={domain}
|
|
685
|
+
/>
|
|
686
|
+
{renderButtons()}
|
|
687
|
+
{renderSnackBar()}
|
|
688
|
+
</View>
|
|
689
|
+
) : currentScreen === VALIDATE_OTP_SCREENS.OTP_VIEW ? (
|
|
690
|
+
<View style={[CommonStyles.mainContainer]}>
|
|
691
|
+
{renderGoBackModal()}
|
|
692
|
+
{renderCancelModal()}
|
|
693
|
+
<OTPView
|
|
694
|
+
{...props}
|
|
695
|
+
isContactVisited={isContactVisited}
|
|
338
696
|
otpCode={otpCode}
|
|
697
|
+
otpInputConfig={otpInputConfig}
|
|
698
|
+
selectedContact={selectedContact}
|
|
699
|
+
setCurrentScreen={setCurrentScreen}
|
|
700
|
+
setErrorMessage={setErrorMessage}
|
|
701
|
+
setSnackBar={setSnackBar}
|
|
702
|
+
errorMessage={errorMessage}
|
|
703
|
+
setHasError={setHasError}
|
|
339
704
|
setOTPCode={setOTPCode}
|
|
705
|
+
setLoading={setLoading}
|
|
706
|
+
handleBackNavigation={handleBackNavigation}
|
|
340
707
|
hasError={hasError}
|
|
341
|
-
|
|
342
|
-
|
|
708
|
+
doorstepOTP={props.doorstepOTP}
|
|
709
|
+
setResendCount={setResendCount}
|
|
710
|
+
resendCount={resendCount}
|
|
711
|
+
resendConfig={resendConfig}
|
|
712
|
+
domain={domain}
|
|
343
713
|
/>
|
|
344
|
-
{
|
|
345
|
-
{
|
|
714
|
+
{renderButtons()}
|
|
715
|
+
{renderSnackBar()}
|
|
346
716
|
</View>
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
visible={snackBar.show}
|
|
352
|
-
onDismiss={() => {
|
|
353
|
-
setSnackBar({
|
|
354
|
-
show: false,
|
|
355
|
-
message: '',
|
|
356
|
-
type: SnackBarType.SUCCESS,
|
|
357
|
-
});
|
|
358
|
-
}}
|
|
359
|
-
/>
|
|
360
|
-
</View>
|
|
361
|
-
</Provider>
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
return null;
|
|
717
|
+
) : null}
|
|
718
|
+
</Portal>
|
|
719
|
+
</Provider>
|
|
720
|
+
);
|
|
365
721
|
};
|
|
366
722
|
|
|
367
723
|
export default ValidateOTPET;
|
|
368
|
-
|
|
369
|
-
const styles = StyleSheet.create({
|
|
370
|
-
bottomView: {
|
|
371
|
-
flexDirection: 'row-reverse',
|
|
372
|
-
justifyContent: 'space-evenly',
|
|
373
|
-
padding: 16,
|
|
374
|
-
backgroundColor: 'white',
|
|
375
|
-
},
|
|
376
|
-
titleText: {
|
|
377
|
-
justifyContent: 'center',
|
|
378
|
-
fontFamily:
|
|
379
|
-
Platform.OS === 'android'
|
|
380
|
-
? Fonts.IBMPlexSans_400Regular
|
|
381
|
-
: 'IBMPlexSans-Regular',
|
|
382
|
-
fontStyle: 'normal',
|
|
383
|
-
fontSize: 16,
|
|
384
|
-
lineHeight: 20,
|
|
385
|
-
letterSpacing: 0.25,
|
|
386
|
-
textAlign: 'center',
|
|
387
|
-
color: '#3D445C',
|
|
388
|
-
marginBottom: 10,
|
|
389
|
-
},
|
|
390
|
-
otpTitle: {
|
|
391
|
-
marginTop: 10,
|
|
392
|
-
marginBottom: 20,
|
|
393
|
-
fontFamily:
|
|
394
|
-
Platform.OS === 'android'
|
|
395
|
-
? Fonts.IBMPlexSans_400Regular
|
|
396
|
-
: 'IBMPlexSans-Regular',
|
|
397
|
-
fontStyle: 'normal',
|
|
398
|
-
fontSize: 16,
|
|
399
|
-
lineHeight: 20,
|
|
400
|
-
letterSpacing: 0.25,
|
|
401
|
-
color: '#3D445C',
|
|
402
|
-
alignItems: 'center',
|
|
403
|
-
},
|
|
404
|
-
otpContainer: {
|
|
405
|
-
marginTop: 20,
|
|
406
|
-
marginBottom: 40,
|
|
407
|
-
marginHorizontal: 10,
|
|
408
|
-
flex: 1,
|
|
409
|
-
},
|
|
410
|
-
retryButton: {
|
|
411
|
-
alignItems: 'flex-start',
|
|
412
|
-
marginVertical: 10,
|
|
413
|
-
},
|
|
414
|
-
errorMessage: {
|
|
415
|
-
marginTop: 16,
|
|
416
|
-
marginHorizontal: 10,
|
|
417
|
-
color: '#DC2626',
|
|
418
|
-
fontFamily:
|
|
419
|
-
Platform.OS === 'android'
|
|
420
|
-
? Fonts.IBMPlexSans_400Regular
|
|
421
|
-
: 'IBMPlexSans-Regular',
|
|
422
|
-
fontSize: 12,
|
|
423
|
-
lineHeight: 16,
|
|
424
|
-
},
|
|
425
|
-
subText: {
|
|
426
|
-
justifyContent: 'center',
|
|
427
|
-
fontFamily:
|
|
428
|
-
Platform.OS === 'android'
|
|
429
|
-
? Fonts.IBMPlexSans_400Regular
|
|
430
|
-
: 'IBMPlexSans-Regular',
|
|
431
|
-
fontStyle: 'normal',
|
|
432
|
-
fontSize: 14,
|
|
433
|
-
letterSpacing: 0.25,
|
|
434
|
-
lineHeight: 20,
|
|
435
|
-
textAlign: 'center',
|
|
436
|
-
color: '#000000',
|
|
437
|
-
marginBottom: 10,
|
|
438
|
-
},
|
|
439
|
-
modalContent: {
|
|
440
|
-
marginStart: 60,
|
|
441
|
-
marginEnd: 60,
|
|
442
|
-
flex: 1,
|
|
443
|
-
marginBottom: 60,
|
|
444
|
-
},
|
|
445
|
-
modalView: {
|
|
446
|
-
backgroundColor: 'white',
|
|
447
|
-
padding: 15,
|
|
448
|
-
borderRadius: 9,
|
|
449
|
-
},
|
|
450
|
-
});
|