@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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
import React, { FC, useEffect, useLayoutEffect } from 'react';
|
|
4
|
+
import { BackHandler, Text, View } from 'react-native';
|
|
5
|
+
import { useFocusEffect } from '@react-navigation/native';
|
|
6
|
+
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
7
|
+
|
|
8
|
+
// Components
|
|
9
|
+
import OTPInput from '../sub-components/OTPInput';
|
|
10
|
+
import { ResendOTPButton } from '../sub-components/ResendOTPButton';
|
|
11
|
+
|
|
12
|
+
// Styles
|
|
13
|
+
import styles from '../ValidateOtpStyles';
|
|
14
|
+
|
|
15
|
+
// Utilities
|
|
16
|
+
import { maskContact } from '../../../../utils/ExecTaskUtils';
|
|
17
|
+
import { resendOTP, updateResendCount, VALIDATE_OTP_SCREENS } from '../utils';
|
|
18
|
+
import useResendOtpTimer from '../../../../utils/hooks/useTimer';
|
|
19
|
+
|
|
20
|
+
// Types
|
|
21
|
+
import { ValidateOTPInput } from '../ValidateOTPSchema';
|
|
22
|
+
import { SnackBarType } from '../../../../components/widgets/SnackBarCustom';
|
|
23
|
+
import { ERROR_RESEND_OTP, OTP_SENT_SUCCESSFULLY } from '../constants';
|
|
24
|
+
|
|
25
|
+
// Analytics
|
|
26
|
+
import { fireEventWithScreenName } from '../../../../analytics/sentry/SentryAnalyticsUtils';
|
|
27
|
+
import {
|
|
28
|
+
ScreenNameSdkConstants,
|
|
29
|
+
SentryEventNameSdkConstants,
|
|
30
|
+
SeverityLevelValue,
|
|
31
|
+
} from '../../../../analytics/sentry/SentrySdkConstants';
|
|
32
|
+
|
|
33
|
+
export const OTPView: FC<ValidateOTPInput> = (props) => {
|
|
34
|
+
const { formattedTime, timer, resetTimer } = useResendOtpTimer(
|
|
35
|
+
props.resendConfig?.enableDelay
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const handleBackPress = () => {
|
|
39
|
+
if (props.doorstepOTP && props.isContactVisited) {
|
|
40
|
+
props.setCurrentScreen(VALIDATE_OTP_SCREENS.CONTACT_LIST);
|
|
41
|
+
} else {
|
|
42
|
+
props.handleBackNavigation();
|
|
43
|
+
}
|
|
44
|
+
props.setOTPCode('');
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleResendOtp = async () => {
|
|
49
|
+
const payload = {
|
|
50
|
+
refId: props.refId,
|
|
51
|
+
meta: {
|
|
52
|
+
orderIds: props.orderData?.map((order) => order?.displayInfo?.orderId),
|
|
53
|
+
},
|
|
54
|
+
...(props.doorstepOTP && {
|
|
55
|
+
contactInfo: {
|
|
56
|
+
id: props.selectedContact.id,
|
|
57
|
+
mode: props.selectedContact.mode,
|
|
58
|
+
type: props.selectedContact.type,
|
|
59
|
+
index: props.selectedContact.index,
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
try {
|
|
64
|
+
// if (props.doorstepOTP && !props.isContactVisited) {
|
|
65
|
+
// props.setCurrentScreen(VALIDATE_OTP_SCREENS.CONTACT_LIST);// required may be in future
|
|
66
|
+
// } else {
|
|
67
|
+
props.setOTPCode('');
|
|
68
|
+
// Attempt to resend OTP
|
|
69
|
+
const response = await resendOTP(payload, {
|
|
70
|
+
...props,
|
|
71
|
+
domain: props.domain,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (!response?.status || !response) {
|
|
75
|
+
props.setSnackBar({
|
|
76
|
+
show: true,
|
|
77
|
+
message: response?.data?.result?.message || ERROR_RESEND_OTP,
|
|
78
|
+
type: SnackBarType.OTP_FAILED,
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
} else {
|
|
82
|
+
const resendCountValue =
|
|
83
|
+
Number(
|
|
84
|
+
response?.data?.result?.resendCount ||
|
|
85
|
+
response?.additionalInfo?.resendCount
|
|
86
|
+
) || props.resendCount + 1;
|
|
87
|
+
|
|
88
|
+
props.setResendCount(resendCountValue);
|
|
89
|
+
await updateResendCount(resendCountValue);
|
|
90
|
+
|
|
91
|
+
props.setSnackBar({
|
|
92
|
+
show: true,
|
|
93
|
+
message: OTP_SENT_SUCCESSFULLY,
|
|
94
|
+
type: SnackBarType.OTP_SUCCESS,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Reset the timer
|
|
98
|
+
resetTimer();
|
|
99
|
+
}
|
|
100
|
+
const cta = props.resendConfig.buttonTitle;
|
|
101
|
+
fireEventWithScreenName({
|
|
102
|
+
severityLevel: SeverityLevelValue.LOG,
|
|
103
|
+
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
104
|
+
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
105
|
+
cta: cta,
|
|
106
|
+
});
|
|
107
|
+
// }
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('Error during OTP generation or timer reset:', error);
|
|
110
|
+
props.setSnackBar({
|
|
111
|
+
show: true,
|
|
112
|
+
message: ERROR_RESEND_OTP,
|
|
113
|
+
type: SnackBarType.OTP_FAILED,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// *reset timer on render
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
resetTimer();
|
|
122
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
// Handle back-button click
|
|
126
|
+
useFocusEffect(
|
|
127
|
+
React.useCallback(() => {
|
|
128
|
+
BackHandler.addEventListener('hardwareBackPress', handleBackPress);
|
|
129
|
+
return () =>
|
|
130
|
+
BackHandler.removeEventListener('hardwareBackPress', handleBackPress);
|
|
131
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
132
|
+
}, [])
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
useLayoutEffect(() => {
|
|
136
|
+
props.navigation.setOptions({
|
|
137
|
+
title: props.title,
|
|
138
|
+
headerLeft: () => {
|
|
139
|
+
return (
|
|
140
|
+
<Icon
|
|
141
|
+
onPress={() => {
|
|
142
|
+
handleBackPress();
|
|
143
|
+
const cta = 'Arrow Back';
|
|
144
|
+
fireEventWithScreenName({
|
|
145
|
+
severityLevel: SeverityLevelValue.LOG,
|
|
146
|
+
eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
|
|
147
|
+
screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
|
|
148
|
+
cta: cta,
|
|
149
|
+
});
|
|
150
|
+
}}
|
|
151
|
+
name="arrow-back"
|
|
152
|
+
color={'black'}
|
|
153
|
+
size={25}
|
|
154
|
+
style={{
|
|
155
|
+
paddingRight: 15,
|
|
156
|
+
paddingTop: 5,
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
163
|
+
}, []);
|
|
164
|
+
|
|
165
|
+
// *render error message for OTP input
|
|
166
|
+
const renderErrorMessage = () => {
|
|
167
|
+
return props.errorMessage ? (
|
|
168
|
+
<Text style={styles.errorMessage}>{props.errorMessage}</Text>
|
|
169
|
+
) : null;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// *render retry button
|
|
173
|
+
const renderRetryButton = () => {
|
|
174
|
+
const enableRetry = props.resendOTP.enableResends;
|
|
175
|
+
|
|
176
|
+
if (enableRetry) {
|
|
177
|
+
return (
|
|
178
|
+
<ResendOTPButton
|
|
179
|
+
{...props}
|
|
180
|
+
formattedTime={formattedTime}
|
|
181
|
+
handleResendOtp={handleResendOtp}
|
|
182
|
+
timer={timer}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
} else return null;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<View style={{ flex: 1 }}>
|
|
190
|
+
<View style={styles.titleContainer}>
|
|
191
|
+
<Text style={styles.titleText}>
|
|
192
|
+
{props?.validateMessage?.toString()?.length > 0
|
|
193
|
+
? props.validateMessage
|
|
194
|
+
: 'Enter OTP received by consignee'}
|
|
195
|
+
</Text>
|
|
196
|
+
</View>
|
|
197
|
+
<View style={styles.otpContainer}>
|
|
198
|
+
<Text style={styles.otpTextMsg}>
|
|
199
|
+
OTP sent to{' '}
|
|
200
|
+
{props?.selectedContact?.value &&
|
|
201
|
+
maskContact(props?.selectedContact?.value)}
|
|
202
|
+
</Text>
|
|
203
|
+
<OTPInput
|
|
204
|
+
input={props.otpInputConfig}
|
|
205
|
+
otpCode={props.otpCode}
|
|
206
|
+
setOTPCode={props.setOTPCode}
|
|
207
|
+
hasError={props.hasError}
|
|
208
|
+
setHasError={props.setHasError}
|
|
209
|
+
setErrorMessage={props.setErrorMessage}
|
|
210
|
+
/>
|
|
211
|
+
{renderErrorMessage()}
|
|
212
|
+
{renderRetryButton()}
|
|
213
|
+
</View>
|
|
214
|
+
</View>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
3
|
+
import React, { FC, useEffect, useLayoutEffect } from 'react';
|
|
4
|
+
import { Text, View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
// Styles
|
|
7
|
+
import styles from '../ValidateOtpStyles';
|
|
8
|
+
|
|
9
|
+
// Components
|
|
10
|
+
import FastImage from 'react-native-fast-image';
|
|
11
|
+
|
|
12
|
+
// Utilities
|
|
13
|
+
import { getBaseETResponse } from '../../../../utils/ExecTaskUtils';
|
|
14
|
+
import { getEventCodeByET } from '../../../../manager/dispatchCodes/EventCodeContainer';
|
|
15
|
+
import { RETRY_LIMIT_REACHED_CODE } from '../../../../constants/constants';
|
|
16
|
+
|
|
17
|
+
// Types
|
|
18
|
+
import {
|
|
19
|
+
BaseEventCodes,
|
|
20
|
+
EntityCode,
|
|
21
|
+
ExecutionTaskID,
|
|
22
|
+
} from '../../../../models/execTasks/ETConfig';
|
|
23
|
+
|
|
24
|
+
const DefaultSubmitTimeout = 3000;
|
|
25
|
+
|
|
26
|
+
const VerificationComplete: FC<any> = (props) => {
|
|
27
|
+
// TO hide header for modal screen
|
|
28
|
+
useLayoutEffect(() => {
|
|
29
|
+
props.navigation.setOptions({
|
|
30
|
+
headerShown: false,
|
|
31
|
+
});
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
const sendSuccessOutput = async () => {
|
|
36
|
+
const _etOutput = await getBaseETResponse(
|
|
37
|
+
EntityCode.VALIDATE_OTP_ET,
|
|
38
|
+
true,
|
|
39
|
+
getEventCodeByET(
|
|
40
|
+
ExecutionTaskID.VALIDATE_OTP_ET,
|
|
41
|
+
true,
|
|
42
|
+
props.applicableReasons?.success
|
|
43
|
+
),
|
|
44
|
+
'',
|
|
45
|
+
props.mergedObjectiveId,
|
|
46
|
+
ExecutionTaskID.VALIDATE_OTP_ET
|
|
47
|
+
);
|
|
48
|
+
setTimeout(async () => {
|
|
49
|
+
props.onSubmitET({
|
|
50
|
+
..._etOutput,
|
|
51
|
+
retryCount: props.retryCount,
|
|
52
|
+
});
|
|
53
|
+
}, DefaultSubmitTimeout);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const sendFailedOutput = async () => {
|
|
57
|
+
const _etOutput = await getBaseETResponse(
|
|
58
|
+
EntityCode.VALIDATE_OTP_ET,
|
|
59
|
+
false,
|
|
60
|
+
BaseEventCodes.ENTITY_FAILURE,
|
|
61
|
+
RETRY_LIMIT_REACHED_CODE,
|
|
62
|
+
props.mergedObjectiveId,
|
|
63
|
+
ExecutionTaskID.VALIDATE_OTP_ET
|
|
64
|
+
);
|
|
65
|
+
setTimeout(async () => {
|
|
66
|
+
props.onSubmitET({
|
|
67
|
+
..._etOutput,
|
|
68
|
+
retryCount: props.retryCount,
|
|
69
|
+
});
|
|
70
|
+
}, DefaultSubmitTimeout);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
props.setLoading(false);
|
|
75
|
+
if (props.success) {
|
|
76
|
+
sendSuccessOutput();
|
|
77
|
+
} else {
|
|
78
|
+
sendFailedOutput();
|
|
79
|
+
}
|
|
80
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const renderSuccessCard = () => {
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<FastImage
|
|
87
|
+
source={require('../../../../icons/icSuccess.gif')}
|
|
88
|
+
style={{ height: 116, width: 116 }} // Use consistent dimensions here
|
|
89
|
+
resizeMode="contain" // Ensures the GIF is displayed properly without distortion
|
|
90
|
+
/>
|
|
91
|
+
<Text style={styles.otpResponseText}>OTP verified successfully!</Text>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const renderFailedCard = () => {
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
<FastImage
|
|
100
|
+
source={require('../../../../icons/icFailed.gif')}
|
|
101
|
+
style={{ height: 116, width: 116 }} // Use consistent dimensions here
|
|
102
|
+
resizeMode="contain" // Ensures the GIF is displayed properly without distortion
|
|
103
|
+
/>
|
|
104
|
+
<Text style={styles.otpResponseText}>OTP verification Failed!</Text>
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<View style={{ flex: 1 }}>
|
|
111
|
+
<View
|
|
112
|
+
style={{
|
|
113
|
+
flex: 1,
|
|
114
|
+
justifyContent: 'center',
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
<View style={styles.responseCard}>
|
|
118
|
+
{props.success ? renderSuccessCard() : renderFailedCard()}
|
|
119
|
+
</View>
|
|
120
|
+
</View>
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
export default VerificationComplete;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
export const INVALID_OTP = `
|
|
1
|
+
export const INVALID_OTP = `Entered incorrect OTP. <length> attempts left.`;
|
|
2
|
+
export const INVALID_OTP_ONE_ATTEMPT_LEFT = `OTP verification failed! Please enter the correct OTP within 1 attempt.`;
|
|
2
3
|
export const INVALID_OTP_LENGTH = `OTP should be of length <length>`;
|
|
3
4
|
export const INVALID_REGEX = `Invalid OTP entered. Must match the expected pattern.`;
|
|
4
|
-
export const ERROR_GENERATING_OTP = `
|
|
5
|
+
export const ERROR_GENERATING_OTP = `Unable to send OTP. Please try again.`;
|
|
6
|
+
export const UNABLE_TO_SEND_OTP = `Unable to send new OTP as maximum limit reached.`;
|
|
7
|
+
export const ERROR_RESEND_OTP = 'Failed to resend OTP. Try again.';
|
|
8
|
+
export const ERROR_VALIDATE_OTP = 'Failed to validate OTP. Try again.';
|
|
9
|
+
export const OTP_SENT_SUCCESSFULLY = 'OTP sent to the customer!';
|
|
10
|
+
export const OTP_VERIFIED_SUCCESSFULLY = 'OTP verified successfully!';
|
|
5
11
|
export const mobileSVG = `<svg width="164" height="164" viewBox="0 0 164 164" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
6
12
|
<mask id="mask0_3391_199849" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="164" height="164">
|
|
7
13
|
<rect width="164" height="164" fill="url(#pattern0)"/>
|
|
@@ -19,6 +25,7 @@ export const mobileSVG = `<svg width="164" height="164" viewBox="0 0 164 164" fi
|
|
|
19
25
|
`;
|
|
20
26
|
export const DEFAULT_RETRY_CONFIG = {
|
|
21
27
|
buttonTitle: 'Resend OTP',
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
enableResends: true,
|
|
29
|
+
enableDelay: 60,
|
|
30
|
+
maxResends: 5,
|
|
24
31
|
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Text, TouchableOpacity, View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
// Styles
|
|
6
|
+
import styles from '../ValidateOtpStyles';
|
|
7
|
+
|
|
8
|
+
// Types
|
|
9
|
+
import { ContactTypes } from '../ValidateOTPSchema';
|
|
10
|
+
|
|
11
|
+
// Icons
|
|
12
|
+
import { RadioCheckedIcon, RadioUncheckedIcon } from '../../../../icons';
|
|
13
|
+
|
|
14
|
+
// Utilities
|
|
15
|
+
import { isNotNullOrEmpty, truncateOrderId } from '../utils';
|
|
16
|
+
import { sHeight } from '../../../../components/utils/Scale';
|
|
17
|
+
import { maskContact } from '../../../../utils/ExecTaskUtils';
|
|
18
|
+
|
|
19
|
+
interface ContactCardPropType {
|
|
20
|
+
handleSelectContact: (contactDetails: ContactTypes) => void;
|
|
21
|
+
contactDetails: ContactTypes;
|
|
22
|
+
}
|
|
23
|
+
export const ContactCard = (props: ContactCardPropType) => {
|
|
24
|
+
const { handleSelectContact, contactDetails } = props;
|
|
25
|
+
return (
|
|
26
|
+
<TouchableOpacity
|
|
27
|
+
activeOpacity={0.75}
|
|
28
|
+
style={[
|
|
29
|
+
styles.contactCard,
|
|
30
|
+
contactDetails?.isSelected && styles.selectedCard,
|
|
31
|
+
]}
|
|
32
|
+
onPress={() => handleSelectContact(contactDetails)}
|
|
33
|
+
>
|
|
34
|
+
<View style={[styles.rowContainer]}>
|
|
35
|
+
{contactDetails?.isSelected ? (
|
|
36
|
+
<RadioCheckedIcon style={[styles.radioIcon]} />
|
|
37
|
+
) : (
|
|
38
|
+
<RadioUncheckedIcon style={[styles.radioIcon]} />
|
|
39
|
+
)}
|
|
40
|
+
<View style={styles.columnContainer}>
|
|
41
|
+
{/* Contact */}
|
|
42
|
+
<View style={[styles.rowContainer, { marginBottom: 8 }]}>
|
|
43
|
+
<Text style={[styles.contactTitle, { padding: 0, margin: 0 }]}>
|
|
44
|
+
{contactDetails?.value && maskContact(contactDetails?.value)}
|
|
45
|
+
</Text>
|
|
46
|
+
</View>
|
|
47
|
+
{isNotNullOrEmpty(contactDetails?.orderId) && (
|
|
48
|
+
<View style={styles.rowContainer}>
|
|
49
|
+
<Text style={[styles.titleText, styles.contactLabel]}>
|
|
50
|
+
Order ID
|
|
51
|
+
</Text>
|
|
52
|
+
<Text style={[styles.titleText, styles.contactText]}>
|
|
53
|
+
{contactDetails?.orderId &&
|
|
54
|
+
truncateOrderId(contactDetails?.orderId)}
|
|
55
|
+
</Text>
|
|
56
|
+
</View>
|
|
57
|
+
)}
|
|
58
|
+
{isNotNullOrEmpty(contactDetails?.orderFrom) && (
|
|
59
|
+
<View style={[styles.rowContainer, { marginTop: sHeight(4) }]}>
|
|
60
|
+
<Text style={[styles.titleText, styles.contactLabel]}>
|
|
61
|
+
Order From
|
|
62
|
+
</Text>
|
|
63
|
+
<Text style={[styles.titleText, styles.contactText]}>
|
|
64
|
+
{contactDetails?.orderFrom}
|
|
65
|
+
</Text>
|
|
66
|
+
</View>
|
|
67
|
+
)}
|
|
68
|
+
</View>
|
|
69
|
+
</View>
|
|
70
|
+
</TouchableOpacity>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
// External imports
|
|
2
3
|
import React, { useEffect } from 'react';
|
|
4
|
+
import { StyleSheet, Pressable, Keyboard, Platform } from 'react-native';
|
|
5
|
+
|
|
6
|
+
// Internal imports
|
|
3
7
|
import SplitTextInput from '../../../widgets/SplitTextInput';
|
|
4
8
|
import { Fonts } from '../../../../styles/executionTasks/CommonStyles';
|
|
5
9
|
import { InputType, CaptureInput } from '../ValidateOTPSchema';
|
|
6
10
|
import { INVALID_REGEX } from '../constants';
|
|
7
|
-
import { ScreenNameSdkConstants, SentryEventNameSdkConstants, SeverityLevelValue } from '../../../../analytics/sentry/SentrySdkConstants';
|
|
8
|
-
import { fireEventWithScreenName } from '../../../../analytics/sentry/SentryAnalyticsUtils';
|
|
9
11
|
|
|
10
12
|
export interface OTPInputProps {
|
|
11
13
|
input: CaptureInput;
|
|
@@ -17,9 +19,11 @@ export interface OTPInputProps {
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const OTPInput = (props: OTPInputProps) => {
|
|
20
|
-
const maximumCodeLength = props.input.length;
|
|
22
|
+
const maximumCodeLength = props.input.length || 6;
|
|
21
23
|
const keyboardType =
|
|
22
|
-
props.input.inputType === InputType.NUMBER
|
|
24
|
+
props.input.inputType === InputType.NUMBER || InputType.NUMERIC
|
|
25
|
+
? 'number-pad'
|
|
26
|
+
: 'default';
|
|
23
27
|
|
|
24
28
|
useEffect(() => {
|
|
25
29
|
if (
|
|
@@ -33,7 +37,7 @@ const OTPInput = (props: OTPInputProps) => {
|
|
|
33
37
|
if (hasError) props.setErrorMessage(INVALID_REGEX);
|
|
34
38
|
else props.setErrorMessage('');
|
|
35
39
|
}
|
|
36
|
-
}, [props.otpCode]);
|
|
40
|
+
}, [maximumCodeLength, props, props.otpCode]);
|
|
37
41
|
|
|
38
42
|
return (
|
|
39
43
|
<>
|
|
@@ -68,7 +72,9 @@ const styles = StyleSheet.create({
|
|
|
68
72
|
? Fonts.IBMPlexSans_400Regular
|
|
69
73
|
: 'IBMPlexSans-Regular',
|
|
70
74
|
color: '#3D445C',
|
|
71
|
-
fontSize:
|
|
75
|
+
fontSize: 16,
|
|
76
|
+
lineHeight: 24,
|
|
77
|
+
fontWeight: '400',
|
|
72
78
|
textAlign: 'center',
|
|
73
79
|
},
|
|
74
80
|
errorMessage: {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* eslint-disable react-native/no-inline-styles */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Text, TouchableOpacity, View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
// Styles
|
|
7
|
+
import styles from '../ValidateOtpStyles';
|
|
8
|
+
|
|
9
|
+
// Types
|
|
10
|
+
import { ResendOTPConfigType } from '../ValidateOTPSchema';
|
|
11
|
+
|
|
12
|
+
// Icons
|
|
13
|
+
import { InfoExclamatoryDarkIcon } from '../../../../icons';
|
|
14
|
+
|
|
15
|
+
interface ResendOTPButtonPropType {
|
|
16
|
+
timer: number;
|
|
17
|
+
resendConfig: ResendOTPConfigType;
|
|
18
|
+
resendCount: number;
|
|
19
|
+
formattedTime: string;
|
|
20
|
+
handleResendOtp: () => void;
|
|
21
|
+
resendOTP?: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ResendOTPButton = (props: ResendOTPButtonPropType) => {
|
|
25
|
+
const { timer, resendConfig, formattedTime, handleResendOtp, resendCount } =
|
|
26
|
+
props;
|
|
27
|
+
const enableRetry = props?.resendOTP?.enableResends;
|
|
28
|
+
return (
|
|
29
|
+
<View>
|
|
30
|
+
{resendCount >= resendConfig.maxResends ? (
|
|
31
|
+
<View>
|
|
32
|
+
<TouchableOpacity disabled onPress={handleResendOtp}>
|
|
33
|
+
<Text
|
|
34
|
+
style={[
|
|
35
|
+
styles.resendOtpMsg,
|
|
36
|
+
styles.resendOtpBtn,
|
|
37
|
+
{
|
|
38
|
+
color: '#E0E3EB',
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
>
|
|
42
|
+
{resendConfig.buttonTitle}
|
|
43
|
+
</Text>
|
|
44
|
+
</TouchableOpacity>
|
|
45
|
+
|
|
46
|
+
<View style={styles.maxLimitReachBox}>
|
|
47
|
+
<InfoExclamatoryDarkIcon
|
|
48
|
+
height={22}
|
|
49
|
+
width={22}
|
|
50
|
+
style={{ padding: 4 }}
|
|
51
|
+
fill={'#525B7A'}
|
|
52
|
+
/>
|
|
53
|
+
<Text style={styles.maxLimitReachText}>
|
|
54
|
+
Maximum resend limit reached.
|
|
55
|
+
</Text>
|
|
56
|
+
</View>
|
|
57
|
+
</View>
|
|
58
|
+
) : Number(timer) !== 0 ? (
|
|
59
|
+
<Text style={styles.resendOtpMsg}>
|
|
60
|
+
{`${resendConfig.buttonTitle} ${timer ? `in ${formattedTime}` : ''}`}
|
|
61
|
+
</Text>
|
|
62
|
+
) : (
|
|
63
|
+
<TouchableOpacity
|
|
64
|
+
disabled={
|
|
65
|
+
Boolean(timer) ||
|
|
66
|
+
resendCount >= resendConfig.maxResends ||
|
|
67
|
+
!enableRetry
|
|
68
|
+
}
|
|
69
|
+
onPress={handleResendOtp}
|
|
70
|
+
>
|
|
71
|
+
<Text
|
|
72
|
+
style={[
|
|
73
|
+
styles.resendOtpMsg,
|
|
74
|
+
styles.resendOtpBtn,
|
|
75
|
+
!enableRetry && {
|
|
76
|
+
color: '#E0E3EB',
|
|
77
|
+
},
|
|
78
|
+
]}
|
|
79
|
+
>
|
|
80
|
+
{resendConfig.buttonTitle}
|
|
81
|
+
</Text>
|
|
82
|
+
</TouchableOpacity>
|
|
83
|
+
)}
|
|
84
|
+
</View>
|
|
85
|
+
);
|
|
86
|
+
};
|