@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.
Files changed (218) hide show
  1. package/android/build.gradle +38 -9
  2. package/android/gradle.properties +17 -2
  3. package/lib/commonjs/components/dispatch/DispatchExecNavigator.js.map +1 -1
  4. package/lib/commonjs/components/executiontasks/forms/widgets/DateTimeWidget.js.map +1 -1
  5. package/lib/commonjs/components/executiontasks/imageCapture/CaptureUtils.js +1 -1
  6. package/lib/commonjs/components/executiontasks/imageCapture/CaptureUtils.js.map +1 -1
  7. package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPET.js +467 -287
  8. package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPET.js.map +1 -1
  9. package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPSchema.js +14 -1
  10. package/lib/commonjs/components/executiontasks/validateOTP/ValidateOTPSchema.js.map +1 -1
  11. package/lib/commonjs/components/executiontasks/validateOTP/ValidateOtpStyles.js +270 -0
  12. package/lib/commonjs/components/executiontasks/validateOTP/ValidateOtpStyles.js.map +1 -0
  13. package/lib/commonjs/components/executiontasks/validateOTP/components/ContactListView.js +99 -0
  14. package/lib/commonjs/components/executiontasks/validateOTP/components/ContactListView.js.map +1 -0
  15. package/lib/commonjs/components/executiontasks/validateOTP/components/OTPView.js +195 -0
  16. package/lib/commonjs/components/executiontasks/validateOTP/components/OTPView.js.map +1 -0
  17. package/lib/commonjs/components/executiontasks/validateOTP/components/VerificationComplete.js +106 -0
  18. package/lib/commonjs/components/executiontasks/validateOTP/components/VerificationComplete.js.map +1 -0
  19. package/lib/commonjs/components/executiontasks/validateOTP/constants.js +12 -5
  20. package/lib/commonjs/components/executiontasks/validateOTP/constants.js.map +1 -1
  21. package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ContactCard.js +68 -0
  22. package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ContactCard.js.map +1 -0
  23. package/lib/commonjs/components/executiontasks/validateOTP/sub-components/OTPInput.js +12 -5
  24. package/lib/commonjs/components/executiontasks/validateOTP/sub-components/OTPInput.js.map +1 -1
  25. package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js +61 -0
  26. package/lib/commonjs/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js.map +1 -0
  27. package/lib/commonjs/components/executiontasks/validateOTP/utils.js +235 -114
  28. package/lib/commonjs/components/executiontasks/validateOTP/utils.js.map +1 -1
  29. package/lib/commonjs/components/utils/Scale.js +22 -0
  30. package/lib/commonjs/components/utils/Scale.js.map +1 -0
  31. package/lib/commonjs/components/widgets/ConfirmCancelModal.js +47 -0
  32. package/lib/commonjs/components/widgets/ConfirmCancelModal.js.map +1 -0
  33. package/lib/commonjs/components/widgets/SnackBarCustom.js +36 -4
  34. package/lib/commonjs/components/widgets/SnackBarCustom.js.map +1 -1
  35. package/lib/commonjs/components/widgets/SplitTextInput.js +48 -18
  36. package/lib/commonjs/components/widgets/SplitTextInput.js.map +1 -1
  37. package/lib/commonjs/constants/apiConstants.js +4 -1
  38. package/lib/commonjs/constants/apiConstants.js.map +1 -1
  39. package/lib/commonjs/constants/constants.js +2 -1
  40. package/lib/commonjs/constants/constants.js.map +1 -1
  41. package/lib/commonjs/icons/icExclamationcircleo_dark.svg +3 -0
  42. package/lib/commonjs/icons/icFailed.gif +0 -0
  43. package/lib/commonjs/icons/icRadioChecked.svg +4 -0
  44. package/lib/commonjs/icons/icRadioUnchecked.svg +4 -0
  45. package/lib/commonjs/icons/icSuccess.gif +0 -0
  46. package/lib/commonjs/icons/index.js +28 -0
  47. package/lib/commonjs/icons/index.js.map +1 -0
  48. package/lib/commonjs/index.js +19 -0
  49. package/lib/commonjs/index.js.map +1 -1
  50. package/lib/commonjs/manager/sdk/DispatchSDKManager.js +5 -4
  51. package/lib/commonjs/manager/sdk/DispatchSDKManager.js.map +1 -1
  52. package/lib/commonjs/manager/sdk/callbacksHandler.js +9 -2
  53. package/lib/commonjs/manager/sdk/callbacksHandler.js.map +1 -1
  54. package/lib/commonjs/manager/syncmanager/constants.js +3 -1
  55. package/lib/commonjs/manager/syncmanager/constants.js.map +1 -1
  56. package/lib/commonjs/manager/syncmanager/document/DocumentHttpClient.js +3 -2
  57. package/lib/commonjs/manager/syncmanager/document/DocumentHttpClient.js.map +1 -1
  58. package/lib/commonjs/manager/syncmanager/document/DocumentSyncManager.js +70 -80
  59. package/lib/commonjs/manager/syncmanager/document/DocumentSyncManager.js.map +1 -1
  60. package/lib/commonjs/models/sdk.js +1 -0
  61. package/lib/commonjs/models/sdk.js.map +1 -1
  62. package/lib/commonjs/ui/screens/ValidateOTPScreen.js +132 -12
  63. package/lib/commonjs/ui/screens/ValidateOTPScreen.js.map +1 -1
  64. package/lib/commonjs/utils/ApiUtils.js +122 -3
  65. package/lib/commonjs/utils/ApiUtils.js.map +1 -1
  66. package/lib/commonjs/utils/ExecTaskUtils.js +67 -7
  67. package/lib/commonjs/utils/ExecTaskUtils.js.map +1 -1
  68. package/lib/commonjs/utils/context/valdiateOTPContext.js +11 -0
  69. package/lib/commonjs/utils/context/valdiateOTPContext.js.map +1 -0
  70. package/lib/commonjs/utils/helper.js.map +1 -1
  71. package/lib/commonjs/utils/hooks/useTimer.js +68 -30
  72. package/lib/commonjs/utils/hooks/useTimer.js.map +1 -1
  73. package/lib/module/components/dispatch/DispatchExecNavigator.js.map +1 -1
  74. package/lib/module/components/executiontasks/forms/widgets/DateTimeWidget.js.map +1 -1
  75. package/lib/module/components/executiontasks/imageCapture/CaptureUtils.js +1 -1
  76. package/lib/module/components/executiontasks/imageCapture/CaptureUtils.js.map +1 -1
  77. package/lib/module/components/executiontasks/validateOTP/ValidateOTPET.js +480 -290
  78. package/lib/module/components/executiontasks/validateOTP/ValidateOTPET.js.map +1 -1
  79. package/lib/module/components/executiontasks/validateOTP/ValidateOTPSchema.js +14 -0
  80. package/lib/module/components/executiontasks/validateOTP/ValidateOTPSchema.js.map +1 -1
  81. package/lib/module/components/executiontasks/validateOTP/ValidateOtpStyles.js +264 -0
  82. package/lib/module/components/executiontasks/validateOTP/ValidateOtpStyles.js.map +1 -0
  83. package/lib/module/components/executiontasks/validateOTP/components/ContactListView.js +88 -0
  84. package/lib/module/components/executiontasks/validateOTP/components/ContactListView.js.map +1 -0
  85. package/lib/module/components/executiontasks/validateOTP/components/OTPView.js +194 -0
  86. package/lib/module/components/executiontasks/validateOTP/components/OTPView.js.map +1 -0
  87. package/lib/module/components/executiontasks/validateOTP/components/VerificationComplete.js +96 -0
  88. package/lib/module/components/executiontasks/validateOTP/components/VerificationComplete.js.map +1 -0
  89. package/lib/module/components/executiontasks/validateOTP/constants.js +11 -4
  90. package/lib/module/components/executiontasks/validateOTP/constants.js.map +1 -1
  91. package/lib/module/components/executiontasks/validateOTP/sub-components/ContactCard.js +59 -0
  92. package/lib/module/components/executiontasks/validateOTP/sub-components/ContactCard.js.map +1 -0
  93. package/lib/module/components/executiontasks/validateOTP/sub-components/OTPInput.js +11 -5
  94. package/lib/module/components/executiontasks/validateOTP/sub-components/OTPInput.js.map +1 -1
  95. package/lib/module/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js +52 -0
  96. package/lib/module/components/executiontasks/validateOTP/sub-components/ResendOTPButton.js.map +1 -0
  97. package/lib/module/components/executiontasks/validateOTP/utils.js +219 -108
  98. package/lib/module/components/executiontasks/validateOTP/utils.js.map +1 -1
  99. package/lib/module/components/utils/Scale.js +14 -0
  100. package/lib/module/components/utils/Scale.js.map +1 -0
  101. package/lib/module/components/widgets/ConfirmCancelModal.js +40 -0
  102. package/lib/module/components/widgets/ConfirmCancelModal.js.map +1 -0
  103. package/lib/module/components/widgets/SnackBarCustom.js +36 -4
  104. package/lib/module/components/widgets/SnackBarCustom.js.map +1 -1
  105. package/lib/module/components/widgets/SplitTextInput.js +48 -19
  106. package/lib/module/components/widgets/SplitTextInput.js.map +1 -1
  107. package/lib/module/constants/apiConstants.js +4 -1
  108. package/lib/module/constants/apiConstants.js.map +1 -1
  109. package/lib/module/constants/constants.js +1 -0
  110. package/lib/module/constants/constants.js.map +1 -1
  111. package/lib/module/icons/icExclamationcircleo_dark.svg +3 -0
  112. package/lib/module/icons/icFailed.gif +0 -0
  113. package/lib/module/icons/icRadioChecked.svg +4 -0
  114. package/lib/module/icons/icRadioUnchecked.svg +4 -0
  115. package/lib/module/icons/icSuccess.gif +0 -0
  116. package/lib/module/icons/index.js +5 -0
  117. package/lib/module/icons/index.js.map +1 -0
  118. package/lib/module/index.js +2 -0
  119. package/lib/module/index.js.map +1 -1
  120. package/lib/module/manager/sdk/DispatchSDKManager.js +5 -3
  121. package/lib/module/manager/sdk/DispatchSDKManager.js.map +1 -1
  122. package/lib/module/manager/sdk/callbacksHandler.js +12 -3
  123. package/lib/module/manager/sdk/callbacksHandler.js.map +1 -1
  124. package/lib/module/manager/syncmanager/constants.js +2 -0
  125. package/lib/module/manager/syncmanager/constants.js.map +1 -1
  126. package/lib/module/manager/syncmanager/document/DocumentHttpClient.js +3 -2
  127. package/lib/module/manager/syncmanager/document/DocumentHttpClient.js.map +1 -1
  128. package/lib/module/manager/syncmanager/document/DocumentSyncManager.js +70 -80
  129. package/lib/module/manager/syncmanager/document/DocumentSyncManager.js.map +1 -1
  130. package/lib/module/models/sdk.js +2 -0
  131. package/lib/module/models/sdk.js.map +1 -1
  132. package/lib/module/ui/screens/ValidateOTPScreen.js +139 -11
  133. package/lib/module/ui/screens/ValidateOTPScreen.js.map +1 -1
  134. package/lib/module/utils/ApiUtils.js +118 -2
  135. package/lib/module/utils/ApiUtils.js.map +1 -1
  136. package/lib/module/utils/ExecTaskUtils.js +66 -7
  137. package/lib/module/utils/ExecTaskUtils.js.map +1 -1
  138. package/lib/module/utils/context/valdiateOTPContext.js +4 -0
  139. package/lib/module/utils/context/valdiateOTPContext.js.map +1 -0
  140. package/lib/module/utils/helper.js +1 -0
  141. package/lib/module/utils/helper.js.map +1 -1
  142. package/lib/module/utils/hooks/useTimer.js +67 -30
  143. package/lib/module/utils/hooks/useTimer.js.map +1 -1
  144. package/lib/typescript/components/executiontasks/collectPayment/PaymentStyles.d.ts +3 -3
  145. package/lib/typescript/components/executiontasks/deliver/DeliverETInput.d.ts +0 -1
  146. package/lib/typescript/components/executiontasks/scan/modalConstant.d.ts +0 -1
  147. package/lib/typescript/components/executiontasks/validateOTP/ValidateOTPET.d.ts +3 -3
  148. package/lib/typescript/components/executiontasks/validateOTP/ValidateOTPSchema.d.ts +169 -5
  149. package/lib/typescript/components/executiontasks/validateOTP/ValidateOtpStyles.d.ts +255 -0
  150. package/lib/typescript/components/executiontasks/validateOTP/components/ContactListView.d.ts +3 -0
  151. package/lib/typescript/components/executiontasks/validateOTP/components/OTPView.d.ts +3 -0
  152. package/lib/typescript/components/executiontasks/validateOTP/components/VerificationComplete.d.ts +3 -0
  153. package/lib/typescript/components/executiontasks/validateOTP/constants.d.ts +11 -4
  154. package/lib/typescript/components/executiontasks/validateOTP/sub-components/ContactCard.d.ts +8 -0
  155. package/lib/typescript/components/executiontasks/validateOTP/sub-components/ResendOTPButton.d.ts +12 -0
  156. package/lib/typescript/components/executiontasks/validateOTP/utils.d.ts +31 -7
  157. package/lib/typescript/components/utils/Scale.d.ts +4 -0
  158. package/lib/typescript/components/widgets/ConfirmCancelModal.d.ts +9 -0
  159. package/lib/typescript/components/widgets/SnackBarCustom.d.ts +4 -8
  160. package/lib/typescript/components/widgets/SplitTextInput.d.ts +1 -1
  161. package/lib/typescript/components/widgets/Timer.d.ts +3 -3
  162. package/lib/typescript/constants/apiConstants.d.ts +3 -0
  163. package/lib/typescript/constants/constants.d.ts +1 -0
  164. package/lib/typescript/icons/index.d.ts +4 -0
  165. package/lib/typescript/index.d.ts +2 -0
  166. package/lib/typescript/manager/sdk/callbacksHandler.d.ts +4 -1
  167. package/lib/typescript/manager/syncmanager/constants.d.ts +2 -0
  168. package/lib/typescript/models/execTasks/ETConfig.d.ts +1 -1
  169. package/lib/typescript/models/sdk.d.ts +3 -0
  170. package/lib/typescript/network/GraphQLClient.d.ts +4 -4
  171. package/lib/typescript/styles/executionTasks/CommonStyles.d.ts +2 -2
  172. package/lib/typescript/ui/screens/HttpRequestScreen.d.ts +0 -1
  173. package/lib/typescript/utils/ApiUtils.d.ts +6 -2
  174. package/lib/typescript/utils/ExecTaskUtils.d.ts +1 -0
  175. package/lib/typescript/utils/context/paymentContext.d.ts +0 -1
  176. package/lib/typescript/utils/context/valdiateOTPContext.d.ts +6 -0
  177. package/lib/typescript/utils/hooks/useModal.d.ts +0 -2
  178. package/lib/typescript/utils/hooks/useTimer.d.ts +7 -5
  179. package/package.json +46 -44
  180. package/src/components/dispatch/DispatchExecNavigator.tsx +1 -1
  181. package/src/components/executiontasks/forms/widgets/DateTimeWidget.tsx +2 -2
  182. package/src/components/executiontasks/imageCapture/CaptureUtils.ts +1 -1
  183. package/src/components/executiontasks/validateOTP/ValidateOTPET.tsx +654 -381
  184. package/src/components/executiontasks/validateOTP/ValidateOTPSchema.ts +193 -8
  185. package/src/components/executiontasks/validateOTP/ValidateOtpStyles.ts +296 -0
  186. package/src/components/executiontasks/validateOTP/components/ContactListView.tsx +109 -0
  187. package/src/components/executiontasks/validateOTP/components/OTPView.tsx +216 -0
  188. package/src/components/executiontasks/validateOTP/components/VerificationComplete.tsx +124 -0
  189. package/src/components/executiontasks/validateOTP/constants.ts +11 -4
  190. package/src/components/executiontasks/validateOTP/sub-components/ContactCard.tsx +72 -0
  191. package/src/components/executiontasks/validateOTP/sub-components/OTPInput.tsx +13 -7
  192. package/src/components/executiontasks/validateOTP/sub-components/ResendOTPButton.tsx +86 -0
  193. package/src/components/executiontasks/validateOTP/utils.ts +313 -143
  194. package/src/components/utils/Scale.ts +13 -0
  195. package/src/components/widgets/ConfirmCancelModal.tsx +49 -0
  196. package/src/components/widgets/SnackBarCustom.tsx +37 -13
  197. package/src/components/widgets/SplitTextInput.tsx +58 -21
  198. package/src/constants/apiConstants.ts +3 -0
  199. package/src/constants/constants.ts +2 -2
  200. package/src/icons/icExclamationcircleo_dark.svg +3 -0
  201. package/src/icons/icFailed.gif +0 -0
  202. package/src/icons/icRadioChecked.svg +4 -0
  203. package/src/icons/icRadioUnchecked.svg +4 -0
  204. package/src/icons/icSuccess.gif +0 -0
  205. package/src/icons/index.ts +5 -0
  206. package/src/index.tsx +2 -0
  207. package/src/manager/sdk/DispatchSDKManager.ts +6 -5
  208. package/src/manager/sdk/callbacksHandler.ts +29 -12
  209. package/src/manager/syncmanager/constants.ts +2 -0
  210. package/src/manager/syncmanager/document/DocumentHttpClient.ts +29 -29
  211. package/src/manager/syncmanager/document/DocumentSyncManager.ts +75 -84
  212. package/src/models/sdk.ts +6 -0
  213. package/src/ui/screens/ValidateOTPScreen.tsx +194 -32
  214. package/src/utils/ApiUtils.ts +131 -3
  215. package/src/utils/ExecTaskUtils.ts +77 -15
  216. package/src/utils/context/valdiateOTPContext.ts +9 -0
  217. package/src/utils/helper.ts +0 -1
  218. package/src/utils/hooks/useTimer.ts +94 -36
@@ -1,354 +1,544 @@
1
- import { View, Text, StyleSheet, BackHandler, Platform } from 'react-native';
2
- import React, { useState, useLayoutEffect } from 'react';
3
- import { Button, Provider } from 'react-native-paper';
4
- import { SvgXml } from 'react-native-svg';
5
- import OTPInput from './sub-components/OTPInput';
6
- import useTimer from '../../../utils/hooks/useTimer';
7
- import { CommonStyles, Fonts } from '../../../styles/executionTasks/CommonStyles';
8
- import { generateOTP, parseRetryConfig } from './utils';
9
- import { checkForValidation } from './utils';
10
- import { ERROR_GENERATING_OTP, INVALID_OTP, INVALID_OTP_LENGTH, mobileSVG } from './constants';
11
- import { EntityCode, ExecutionTaskID } from '../../../models/execTasks/ETConfig';
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 SnackBarCustom, { SnackBarType } from '../../../components/widgets/SnackBarCustom';
15
- import Icon from 'react-native-vector-icons/MaterialIcons';
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 { hasGoBackConnector } from '../../../components/utils';
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 { useFocusEffect } from '@react-navigation/native';
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 _props$generationLogi, _props$generationLogi2;
24
- const [showBackModal, setShowBackModal] = useState(false);
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
- // Handle back-button click
27
- useFocusEffect(React.useCallback(() => {
28
- const onBackPress = () => {
29
- var _props$taskMeta;
30
- if ((_props$taskMeta = props.taskMeta) !== null && _props$taskMeta !== void 0 && _props$taskMeta.enableGoBack && hasGoBackConnector(props.applicableReasons)) {
31
- setShowBackModal(true);
32
- return true;
33
- } else {
34
- props.navigation.goBack();
35
- return true;
36
- }
37
- };
38
- BackHandler.addEventListener('hardwareBackPress', onBackPress);
39
- return () => BackHandler.removeEventListener('hardwareBackPress', onBackPress);
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 = otpCode => {
74
+ const setOTPCode = code => {
84
75
  setUserInput({
85
76
  ...userInput,
86
- captureInput: otpCode
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.SUCCESS,
97
+ type: SnackBarType.OTP_SUCCESS,
94
98
  message: ''
95
99
  });
96
- const renderButtons = () => {
97
- return /*#__PURE__*/React.createElement(View, {
98
- style: styles.bottomView
99
- }, /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Button, {
100
- style: [CommonStyles.nextButton, {
101
- width: 165,
102
- marginStart: 10
103
- }],
104
- labelStyle: CommonStyles.nextButtonLabel,
105
- mode: 'contained',
106
- uppercase: false,
107
- onPress: async () => {
108
- var _props$generationLogi3;
109
- // send OTP Generation using props
110
- if (sendOTP && props.generationLogic && (_props$generationLogi3 = props.generationLogic) !== null && _props$generationLogi3 !== void 0 && _props$generationLogi3.generateOnLoad) {
111
- const response = await generateOTP(props.generationLogic.api);
112
- resetTimer();
113
- if (response) setSendOTP(false);else setSnackBar({
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: ERROR_GENERATING_OTP,
116
- type: SnackBarType.FAILURE
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
- // check for Validation
120
- else if (!sendOTP) {
121
- if (otpCode.length < props.captureInput.length) {
122
- setSnackBar({
123
- show: true,
124
- message: INVALID_OTP_LENGTH.replace('<length>', `${props.captureInput.length}`),
125
- type: SnackBarType.FAILURE
126
- });
127
- } else {
128
- const isValid = await checkForValidation(otpCode, props.validation, {
129
- userInput
130
- });
131
- if (!isValid) {
132
- setErrorMessage(INVALID_OTP);
133
- setHasError(true);
134
- } else {
135
- var _props$applicableReas;
136
- props.onSubmitET({
137
- ...(await getBaseETResponse(EntityCode.VALIDATE_OTP_ET, true, getEventCodeByET(ExecutionTaskID.VALIDATE_OTP_ET, true, (_props$applicableReas = props.applicableReasons) === null || _props$applicableReas === void 0 ? void 0 : _props$applicableReas.success), '', props.mergedObjectiveId, ExecutionTaskID.VALIDATE_OTP_ET))
138
- });
139
- }
140
- }
141
- }
142
- const cta = 'Proceed';
143
- fireEventWithScreenName({
144
- severityLevel: SeverityLevelValue.LOG,
145
- eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
146
- screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
147
- cta: cta
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
- }, "Proceed")), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Button, {
151
- style: [CommonStyles.cancelButton, {
152
- width: 165,
153
- marginEnd: 10
154
- }],
155
- labelStyle: CommonStyles.cancelButtonLabel,
156
- mode: 'outlined',
157
- uppercase: false,
158
- onPress: async () => {
159
- var _props$applicableReas2;
160
- // Cancel the ET
161
- props.onSubmitET({
162
- ...(await getBaseETResponse(EntityCode.VALIDATE_OTP_ET, false, getEventCodeByET(ExecutionTaskID.VALIDATE_OTP_ET, false, (_props$applicableReas2 = props.applicableReasons) === null || _props$applicableReas2 === void 0 ? void 0 : _props$applicableReas2.failure), '', props.mergedObjectiveId, ExecutionTaskID.VALIDATE_OTP_ET))
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
- const cta = 'Skip';
165
- fireEventWithScreenName({
166
- severityLevel: SeverityLevelValue.LOG,
167
- eventName: SentryEventNameSdkConstants.BUTTON_CLICKED,
168
- screenName: ScreenNameSdkConstants.VALIDATE_OTP_ET_SCREEN,
169
- cta: cta
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
- }, "Skip")));
345
+ }
346
+ return;
173
347
  };
174
- const renderRetryButton = () => {
175
- var _props$generationLogi4;
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 renderErrorMessage = () => {
201
- return errorMessage ? /*#__PURE__*/React.createElement(Text, {
202
- style: styles.errorMessage
203
- }, errorMessage) : null;
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
- const renderModal = () => {
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
- if (sendOTP) {
219
- return /*#__PURE__*/React.createElement(Provider, null, /*#__PURE__*/React.createElement(View, {
220
- style: CommonStyles.mainContainer
221
- }, renderModal(), /*#__PURE__*/React.createElement(View, {
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
- marginBottom: 16
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.SUCCESS
443
+ type: SnackBarType.OTP_SUCCESS
277
444
  });
278
445
  }
279
- })));
280
- }
281
- return null;
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