@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,180 +1,350 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1
2
  import * as jsonLogic from 'json-logic-js';
2
- import { JSONPath } from 'jsonpath-plus';
3
3
  import Logger, { LOG_TYPE } from '../../../utils/Logger';
4
- import {
5
- APIData,
6
- getApiResponse,
7
- KeyValueArray,
8
- } from '../../../utils/ApiUtils';
4
+ import { createApiData, getAxiosApiResponse } from '../../../utils/ApiUtils';
9
5
  import { DEFAULT_RETRY_CONFIG } from './constants';
10
6
  import type {
11
- API,
12
- InputType,
13
- Validation,
14
- RetryConfig,
7
+ ResendOTPConfigType,
8
+ EmailAndPhoneResponse,
9
+ ContactType,
10
+ ValidateOTPInput,
11
+ ResendOTPPayloadType,
12
+ ResponseType,
13
+ ErrorResponseType,
14
+ GenerateOtpPayloadType,
15
15
  } from './ValidateOTPSchema';
16
+ import Storage from '../../../utils/storage';
17
+ import {
18
+ SHARED_PREFERENCE_RESEND_COUNT,
19
+ SHARED_PREFERENCE_RETRY_COUNT,
20
+ } from '../../../manager/syncmanager/constants';
21
+ import { ENDPOINTS } from '../../../constants/apiConstants';
22
+ import getUuidByString from 'uuid-by-string';
16
23
 
17
- const isDyanmicValue = function (input: string) {
18
- if (
19
- input.charAt(0) === '{' &&
20
- input.charAt(1) === '{' &&
21
- input.charAt(input.length - 1) === '}' &&
22
- input.charAt(input.length - 2) === '}'
23
- )
24
- return true;
25
- else return false;
26
- };
27
-
28
- export function parseBody(body: any, userInput: any) {
29
- const requestBody = JSON.parse(JSON.stringify(body));
30
- for (const key in requestBody) {
31
- if (Object.prototype.hasOwnProperty.call(requestBody, key)) {
32
- const value = requestBody[key];
33
- if (typeof value === 'object') {
34
- requestBody[key] = parseBody(value, userInput);
35
- } else if (Array.isArray(value)) {
36
- value.forEach((val) => {
37
- requestBody[key] = parseBody(val, userInput);
38
- });
39
- } else {
40
- if (
41
- typeof value === 'string' &&
42
- isDyanmicValue(value) &&
43
- value.includes('userInput')
44
- ) {
45
- if (value.includes('captureInput'))
46
- requestBody[key] = userInput.captureInput;
47
- }
48
- }
49
- }
50
- }
51
- return requestBody;
24
+ export enum OTP_CONFIG {
25
+ OS1 = 'OTP_CONFIG',
26
+ CUSTOM = 'Custom',
52
27
  }
53
28
 
54
- export function parseKeyValue(array: KeyValueArray[], userInput: any) {
55
- array.forEach((item) => {
56
- if (isDyanmicValue(item.value) && item.value.includes('userInput')) {
57
- if (item.value.includes('captureInput'))
58
- item.value = userInput.captureInput;
59
- }
60
- });
61
- return array;
29
+ type PropType = ValidateOTPInput & { domain: string };
30
+
31
+ export enum countType {
32
+ RETRY,
33
+ RESEND,
62
34
  }
63
35
 
64
- export const generateOTP = async (api: API) => {
65
- // TESTING
36
+ export const VALIDATE_OTP_SCREENS = {
37
+ CONTACT_LIST: 'CONTACT_LIST',
38
+ OTP_VIEW: 'OTP_VIEW',
39
+ VERIFICATION_COMPLETE: 'VERIFICATION_COMPLETE',
40
+ };
41
+
42
+ export const generateOTP = async (
43
+ payload: GenerateOtpPayloadType,
44
+ props: PropType
45
+ ): Promise<any | ResponseType | ErrorResponseType> => {
66
46
  try {
67
- const apiData: APIData = {
68
- errorJsonPath: '',
69
- responseJsonPath: '',
70
- uri: api.uri,
71
- httpMethod: api.httpMethod,
72
- timeout: api.timeout,
73
- headers: api.headers,
74
- };
75
- if (api.requestBody) {
76
- apiData.requestBody = api.requestBody;
77
- }
78
- if (api.pathParams) {
79
- apiData.pathParams = api.pathParams;
80
- }
81
- if (api.queryParams) {
82
- apiData.queryParams = api.queryParams;
83
- }
47
+ const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;
48
+ const apiData = createApiData(
49
+ payload,
50
+ props,
51
+ isCustomConfig
52
+ ? props?.otpGeneration?.uri
53
+ : `{baseURI}${ENDPOINTS.GENERATE_OTP_ENDPOINT}`,
54
+ 'POST',
55
+ null,
56
+ isCustomConfig ? props.otpGeneration : undefined
57
+ );
84
58
 
85
- const apiResponse = await getApiResponse(apiData);
59
+ const apiResponse = await getAxiosApiResponse(apiData);
86
60
 
87
- return jsonLogic.apply(
88
- <jsonLogic.RulesLogic>api.responseJsonLogic,
89
- apiResponse.data
90
- );
61
+ if (isCustomConfig && apiData.responseJsonLogic) {
62
+ return jsonLogic.apply(
63
+ <jsonLogic.RulesLogic>apiData.responseJsonLogic,
64
+ apiResponse.data
65
+ );
66
+ }
67
+
68
+ return apiResponse.data;
91
69
  } catch (error: any) {
92
70
  Logger.getInstance().logEvent(
93
71
  '~ generateOTP',
94
72
  error.message,
95
73
  LOG_TYPE.SDK_ERROR
96
74
  );
97
- return false;
75
+ console.error('error: ', JSON.stringify(error));
76
+ return error?.response?.data ?? false;
98
77
  }
99
78
  };
100
79
 
101
- export const checkForValidation = async (
102
- otp: string,
103
- validation: Validation,
104
- userInput: any
105
- ): Promise<boolean> => {
106
- // API
107
- if (validation.selectedIndex === 0) {
108
- const otpValue = JSONPath({
109
- path: '$.userInput.captureInput',
110
- json: userInput,
111
- })[0];
80
+ export const verifyOTP = async (
81
+ payload: any,
82
+ props: PropType
83
+ ): Promise<any | ResponseType | ErrorResponseType> => {
84
+ try {
85
+ const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;
86
+ const apiData = createApiData(
87
+ payload,
88
+ props,
89
+ isCustomConfig
90
+ ? props?.validationApi?.uri
91
+ : `{baseURI}${ENDPOINTS.VERIFY_OTP_ENDPOINT}`,
92
+ 'POST',
93
+ null,
94
+ isCustomConfig ? props.validationApi : undefined
95
+ );
112
96
 
113
- try {
114
- //@ts-ignore
115
- const api: API = validation.logic.api;
116
- const apiData: APIData = {
117
- errorJsonPath: '',
118
- responseJsonPath: '',
119
- uri: api.uri,
120
- httpMethod: api.httpMethod,
121
- timeout: api.timeout,
122
- headers: api.headers,
123
- };
124
- if (api.requestBody) {
125
- const parsedRequestBody = parseBody(api.requestBody, {
126
- captureInput: otpValue,
127
- });
128
- apiData.requestBody = parsedRequestBody;
129
- }
130
- if (api.pathParams) {
131
- parseKeyValue(api.pathParams, { captureInput: otpValue });
132
- apiData.pathParams = api.pathParams;
133
- }
134
- if (api.queryParams) {
135
- parseKeyValue(api.queryParams, { captureInput: otpValue });
136
- apiData.queryParams = api.queryParams;
137
- }
138
- const apiResponse = await getApiResponse(apiData);
97
+ const apiResponse = await getAxiosApiResponse(apiData);
98
+
99
+ if (isCustomConfig && apiData.responseJsonLogic) {
139
100
  return jsonLogic.apply(
140
- <jsonLogic.RulesLogic>api.responseJsonLogic,
101
+ <jsonLogic.RulesLogic>apiData.responseJsonLogic,
141
102
  apiResponse.data
142
103
  );
143
- } catch (error: any) {
144
- Logger.getInstance().logEvent(
145
- '~ checkForValidation',
146
- error.message,
147
- LOG_TYPE.SDK_ERROR
104
+ }
105
+
106
+ return apiResponse.data;
107
+ } catch (error: any) {
108
+ Logger.getInstance().logEvent(
109
+ '~ verifyOTP',
110
+ error.message,
111
+ LOG_TYPE.SDK_ERROR
112
+ );
113
+ console.error('error: ', JSON.stringify(error));
114
+ return error?.response?.data ?? false;
115
+ }
116
+ };
117
+
118
+ export const resendOTP = async (
119
+ payload: ResendOTPPayloadType,
120
+ props: PropType
121
+ ): Promise<any | ResponseType | ErrorResponseType> => {
122
+ try {
123
+ const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;
124
+ const apiData = createApiData(
125
+ payload,
126
+ props,
127
+ isCustomConfig
128
+ ? props?.resendApi?.uri
129
+ : `{baseURI}${ENDPOINTS.RESEND_OTP_ENDPOINT}`,
130
+ 'POST',
131
+ null,
132
+ isCustomConfig ? props.resendApi : undefined
133
+ );
134
+
135
+ const apiResponse = await getAxiosApiResponse(apiData);
136
+
137
+ if (isCustomConfig && apiData.responseJsonLogic) {
138
+ return jsonLogic.apply(
139
+ <jsonLogic.RulesLogic>apiData.responseJsonLogic,
140
+ apiResponse.data
148
141
  );
149
- return false;
150
142
  }
143
+
144
+ return apiResponse.data;
145
+ } catch (error: any) {
146
+ Logger.getInstance().logEvent(
147
+ '~ resendOTP',
148
+ error.message,
149
+ LOG_TYPE.SDK_ERROR
150
+ );
151
+ console.error('error: ', JSON.stringify(error));
152
+ return error?.response?.data ?? false;
153
+ }
154
+ };
155
+
156
+ export const parseResendConfig = (
157
+ inputResendConfig: ResendOTPConfigType | undefined
158
+ ): ResendOTPConfigType => {
159
+ const resendConfig: ResendOTPConfigType = DEFAULT_RETRY_CONFIG;
160
+ if (inputResendConfig) {
161
+ if (inputResendConfig.buttonTitle) {
162
+ resendConfig.buttonTitle = inputResendConfig.buttonTitle;
163
+ }
164
+ if (inputResendConfig.enableDelay) {
165
+ resendConfig.enableDelay = inputResendConfig.enableDelay;
166
+ }
167
+ if (inputResendConfig.maxResends) {
168
+ resendConfig.maxResends = inputResendConfig.maxResends;
169
+ }
170
+ }
171
+ return resendConfig;
172
+ };
173
+
174
+ export function maskContactId(contactId: string) {
175
+ const idString = String(contactId);
176
+
177
+ // Check if it's an email based on the presence of '@'
178
+ if (idString.includes('@')) {
179
+ // Split email into username and domain parts
180
+ const [username, domain] = idString.split('@');
181
+
182
+ // Show first 3 characters and replace the rest with asterisks
183
+ const visibleUsername =
184
+ username.slice(0, 3) + '*'.repeat(username.length - 3);
185
+
186
+ return `${visibleUsername}@${domain}`;
187
+ } else {
188
+ // For non-email contact ID, show first 5 characters as asterisks and last 4 digits
189
+ const lastFourDigits = idString.slice(-4);
190
+ return `***** *${lastFourDigits}`;
151
191
  }
152
- // Exact Value
153
- else if (validation.selectedIndex === 1) {
154
- // @ts-ignore
155
- const value: InputType = validation.logic.value;
156
- return value == otp;
192
+ }
193
+
194
+ export const truncateOrderId = (shipmentId: string) => {
195
+ let displayShipmentId = '';
196
+ if (shipmentId?.length >= 16) {
197
+ const startingTen = shipmentId.slice(0, 5);
198
+ const lastTen = shipmentId.slice(-5);
199
+ displayShipmentId = `${startingTen}...${lastTen}`;
200
+ } else {
201
+ displayShipmentId = shipmentId;
157
202
  }
158
- // Invalid input received
159
- else {
203
+ return displayShipmentId;
204
+ };
205
+
206
+ export const isNotNullOrEmpty = (value: any): boolean => {
207
+ if (value === null || value === undefined) {
208
+ return false;
209
+ }
210
+ if (typeof value === 'string' && value.trim() === '') {
160
211
  return false;
161
212
  }
213
+ if (Array.isArray(value) && value.length === 0) {
214
+ return false;
215
+ }
216
+ return true;
162
217
  };
163
218
 
164
- export const parseRetryConfig = (
165
- inputRetryConfig: RetryConfig | undefined
166
- ): RetryConfig => {
167
- const retryConfig: RetryConfig = DEFAULT_RETRY_CONFIG;
168
- if (inputRetryConfig) {
169
- if (inputRetryConfig.buttonTitle) {
170
- retryConfig.buttonTitle = inputRetryConfig.buttonTitle;
171
- }
172
- if (inputRetryConfig.delay) {
173
- retryConfig.delay = inputRetryConfig.delay;
174
- }
175
- if (inputRetryConfig.maxAttempt) {
176
- retryConfig.maxAttempt = inputRetryConfig.maxAttempt;
219
+ export function generateContactList(
220
+ response: EmailAndPhoneResponse,
221
+ orderId?: string
222
+ ): ContactType[] {
223
+ // Initialize an array to store the transformed contact list
224
+ const contactList: ContactType[] = [];
225
+
226
+ // Handle the primary phone number
227
+ if (response.phone?.number) {
228
+ contactList.push({
229
+ id: response.id, // Unique identifier
230
+ mode: 'PHONE',
231
+ type: 'PRIMARY',
232
+ index: 0,
233
+ value: response.phone.number, // Actual phone number
234
+ orderId,
235
+ });
236
+ }
237
+
238
+ // Handle additional phone numbers
239
+ if (response.additionalPhone?.length) {
240
+ response.additionalPhone.forEach((phone, idx) => {
241
+ if (phone?.number) {
242
+ contactList.push({
243
+ id: response.id, // Unique identifier
244
+ mode: 'PHONE',
245
+ type: 'SECONDARY',
246
+ index: idx,
247
+ value: phone.number, // Actual phone number
248
+ orderId,
249
+ });
250
+ }
251
+ });
252
+ }
253
+
254
+ // Handle the primary email
255
+ if (response.email) {
256
+ contactList.push({
257
+ id: response.id, // Unique identifier
258
+ mode: 'EMAIL',
259
+ type: 'PRIMARY',
260
+ index: 0,
261
+ value: response.email, // Actual email address
262
+ orderId,
263
+ });
264
+ }
265
+
266
+ // Handle additional emails
267
+ if (response.additionalEmail?.length) {
268
+ response.additionalEmail.forEach((email, idx) => {
269
+ if (email?.id) {
270
+ contactList.push({
271
+ id: response.id, // Unique identifier
272
+ mode: 'EMAIL',
273
+ type: 'SECONDARY',
274
+ index: idx,
275
+ value: email.id, // Actual email address
276
+ orderId,
277
+ });
278
+ }
279
+ });
280
+ }
281
+
282
+ return contactList;
283
+ }
284
+
285
+ export const getUniqueRefId = (
286
+ moId: string,
287
+ progressGroupId?: string | null,
288
+ attemptCount?: number | null
289
+ ) => {
290
+ const refId = `${moId}${progressGroupId ? '::' + progressGroupId : ''}${
291
+ attemptCount ? '::' + attemptCount : ''
292
+ }`;
293
+ const _hashedRefId = getUuidByString(refId?.toString()?.trim());
294
+ return _hashedRefId;
295
+ };
296
+
297
+ export const updateRetryCount = async (retryCount: number) => {
298
+ let storage = Storage.getInstance();
299
+
300
+ await storage.setSharedItem(
301
+ SHARED_PREFERENCE_RETRY_COUNT,
302
+ JSON.stringify(retryCount)
303
+ );
304
+ };
305
+
306
+ export const updateResendCount = async (retryCount: number) => {
307
+ let storage = Storage.getInstance();
308
+
309
+ await storage.setSharedItem(
310
+ SHARED_PREFERENCE_RESEND_COUNT,
311
+ JSON.stringify(retryCount)
312
+ );
313
+ };
314
+
315
+ export const getCount = async (type: countType): Promise<number> => {
316
+ const storage = Storage.getInstance();
317
+ let count: any = 0;
318
+
319
+ if (type === countType.RESEND) {
320
+ count = await storage.getSharedItem(SHARED_PREFERENCE_RESEND_COUNT);
321
+ } else if (type === countType.RETRY) {
322
+ count = await storage.getSharedItem(SHARED_PREFERENCE_RETRY_COUNT);
323
+ }
324
+
325
+ // Parse and validate the count
326
+ if (count) {
327
+ try {
328
+ const parsedCount = JSON.parse(count);
329
+ if (typeof parsedCount === 'number') {
330
+ return parsedCount;
331
+ }
332
+ } catch (error) {
333
+ console.warn('Invalid count value:', count);
177
334
  }
178
335
  }
179
- return retryConfig;
336
+
337
+ // Default to 0 if count is invalid
338
+ return 0;
339
+ };
340
+
341
+ export const resetCount = async () => {
342
+ let storage = Storage.getInstance();
343
+
344
+ await storage.setSharedItem(
345
+ SHARED_PREFERENCE_RESEND_COUNT,
346
+ JSON.stringify(0)
347
+ );
348
+
349
+ await storage.setSharedItem(SHARED_PREFERENCE_RETRY_COUNT, JSON.stringify(0));
180
350
  };
@@ -0,0 +1,13 @@
1
+ import { Dimensions } from 'react-native';
2
+ const { width, height } = Dimensions.get('window');
3
+
4
+ //Guideline sizes are based on standard ~5" screen mobile device
5
+ const guidelineBaseWidth = 350;
6
+ const guidelineBaseHeight = 680;
7
+
8
+ const sWidth = (size: number) => (width / guidelineBaseWidth) * size;
9
+ const sHeight = (size: number) => (height / guidelineBaseHeight) * size;
10
+ const sCorner = (size: number, factor = 0.5) =>
11
+ size + (sWidth(size) - size) * factor;
12
+
13
+ export { sWidth, sHeight, sCorner };
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import ModalWidget from './ModalWidget';
3
+ import { StyleSheet } from 'react-native';
4
+
5
+ interface ConfirmCancelProps {
6
+ showModal: boolean;
7
+ setShowModal: React.Dispatch<React.SetStateAction<boolean>>;
8
+ onSuccess: () => any;
9
+ onFailure: () => any;
10
+ }
11
+
12
+ const ConfirmCancelModal = (props: ConfirmCancelProps) => {
13
+ return (
14
+ <ModalWidget
15
+ dismissable={true}
16
+ showModal={props.showModal}
17
+ title={{ label: 'Are you sure you want to cancel orders?' }}
18
+ primaryButton={{
19
+ label: 'Yes',
20
+ onPress: props.onSuccess,
21
+ styles: modalStyles.primaryButtonStyles,
22
+ }}
23
+ secondaryButton={{
24
+ label: 'No',
25
+ onPress: props.onFailure,
26
+ styles: modalStyles.secondaryButtonStyles,
27
+ }}
28
+ />
29
+ );
30
+ };
31
+
32
+ export default ConfirmCancelModal;
33
+
34
+ const modalStyles = StyleSheet.create({
35
+ primaryButtonStyles: {
36
+ marginTop: 16,
37
+ height: 40,
38
+ borderRadius: 6,
39
+ justifyContent: 'center',
40
+ alignItems: 'center',
41
+ },
42
+ secondaryButtonStyles: {
43
+ marginVertical: 16,
44
+ height: 40,
45
+ borderRadius: 6,
46
+ justifyContent: 'center',
47
+ alignItems: 'center',
48
+ },
49
+ });
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-native/no-inline-styles */
1
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
3
  import React from 'react';
3
4
  import {
@@ -23,26 +24,22 @@ import { fireEventWithScreenName } from '../../analytics/sentry/SentryAnalyticsU
23
24
  export interface SnackbarProps {
24
25
  visible: boolean;
25
26
  duration?: number;
26
- /**
27
- * Callback called when Snackbar is dismissed. The `visible` prop needs to be updated when this is called.
28
- */
29
27
  onDismiss: () => void;
30
- /**
31
- * Text content of the Snackbar.
32
- */
33
28
  message: string;
34
29
  type?: SnackBarType;
35
30
  theme: ReactNativePaper.Theme;
36
31
  customBottom?: number;
37
32
  customTop?: number;
38
33
  }
39
- const DURATION_MEDIUM = 3000;
34
+ const DURATION_MEDIUM = 4500;
40
35
 
41
36
  export enum SnackBarType {
42
37
  SUCCESS,
43
38
  FAILURE,
44
39
  WARNING,
45
40
  PAYMENT_WARNING,
41
+ OTP_SUCCESS,
42
+ OTP_FAILED,
46
43
  }
47
44
 
48
45
  const SnackbarCustom = ({
@@ -63,6 +60,11 @@ const SnackbarCustom = ({
63
60
  const hideTimeout = React.useRef<NodeJS.Timeout | undefined>(undefined);
64
61
  const { scale } = theme.animation;
65
62
 
63
+ const isDarkColorType =
64
+ type === SnackBarType.PAYMENT_WARNING ||
65
+ type === SnackBarType.OTP_FAILED ||
66
+ type === SnackBarType.OTP_SUCCESS;
67
+
66
68
  React.useEffect(() => {
67
69
  return () => {
68
70
  if (hideTimeout.current) clearTimeout(hideTimeout.current);
@@ -128,7 +130,7 @@ const SnackbarCustom = ({
128
130
  [
129
131
  styles.container,
130
132
  {
131
- borderRadius: roundness,
133
+ borderRadius: roundness ? roundness : 8,
132
134
  opacity: opacity,
133
135
  transform: [
134
136
  {
@@ -153,6 +155,10 @@ const SnackbarCustom = ({
153
155
  ? styles.warn
154
156
  : type && type === SnackBarType.PAYMENT_WARNING
155
157
  ? styles.paymentWarn
158
+ : type && type === SnackBarType.OTP_SUCCESS
159
+ ? styles.otpSuccess
160
+ : type && type === SnackBarType.OTP_FAILED
161
+ ? styles.otpFailed
156
162
  : styles.main
157
163
  }
158
164
  >
@@ -160,6 +166,10 @@ const SnackbarCustom = ({
160
166
  <AntDesign name="exclamationcircleo" size={20} color="white" />
161
167
  ) : type && type === SnackBarType.PAYMENT_WARNING ? (
162
168
  <AntDesign name="infocirlceo" size={20} color="#D97706" />
169
+ ) : type && type === SnackBarType.OTP_SUCCESS ? (
170
+ <AntDesign name="checkcircleo" size={20} color="#059669" />
171
+ ) : type && type === SnackBarType.OTP_FAILED ? (
172
+ <AntDesign name="closecircleo" size={20} color="#DC2626" />
163
173
  ) : (
164
174
  <AntDesign name="checkcircleo" size={20} color="white" />
165
175
  )}
@@ -167,6 +177,8 @@ const SnackbarCustom = ({
167
177
  style={[
168
178
  styles.messageStyle,
169
179
  type === SnackBarType.PAYMENT_WARNING && { color: '#B45309' },
180
+ type === SnackBarType.OTP_SUCCESS && { color: '#059669' },
181
+ type === SnackBarType.OTP_FAILED && { color: '#DC2626' },
170
182
  ]}
171
183
  >
172
184
  {message}
@@ -174,11 +186,7 @@ const SnackbarCustom = ({
174
186
  <AntDesign
175
187
  name="close"
176
188
  size={20}
177
- color={
178
- type && type === SnackBarType.PAYMENT_WARNING
179
- ? '#3D445C'
180
- : 'white'
181
- }
189
+ color={isDarkColorType ? '#3D445C' : 'white'}
182
190
  onPress={() => {
183
191
  setHidden(true);
184
192
  onDismiss();
@@ -244,6 +252,22 @@ const styles = StyleSheet.create({
244
252
  flex: 1,
245
253
  borderRadius: 8,
246
254
  },
255
+ otpSuccess: {
256
+ padding: 12,
257
+ flexDirection: 'row',
258
+ alignItems: 'center',
259
+ backgroundColor: '#ECFDF5',
260
+ flex: 1,
261
+ borderRadius: 8,
262
+ },
263
+ otpFailed: {
264
+ padding: 12,
265
+ flexDirection: 'row',
266
+ alignItems: 'center',
267
+ backgroundColor: '#FEF2F2',
268
+ flex: 1,
269
+ borderRadius: 8,
270
+ },
247
271
  messageStyle: {
248
272
  fontSize: 14,
249
273
  marginStart: 8,