@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,133 +1,244 @@
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 { getApiResponse } from '../../../utils/ApiUtils';
4
+ import { createApiData, getAxiosApiResponse } from '../../../utils/ApiUtils';
5
5
  import { DEFAULT_RETRY_CONFIG } from './constants';
6
- const isDyanmicValue = function (input) {
7
- if (input.charAt(0) === '{' && input.charAt(1) === '{' && input.charAt(input.length - 1) === '}' && input.charAt(input.length - 2) === '}') return true;else return false;
6
+ import Storage from '../../../utils/storage';
7
+ import { SHARED_PREFERENCE_RESEND_COUNT, SHARED_PREFERENCE_RETRY_COUNT } from '../../../manager/syncmanager/constants';
8
+ import { ENDPOINTS } from '../../../constants/apiConstants';
9
+ import getUuidByString from 'uuid-by-string';
10
+ export let OTP_CONFIG = /*#__PURE__*/function (OTP_CONFIG) {
11
+ OTP_CONFIG["OS1"] = "OTP_CONFIG";
12
+ OTP_CONFIG["CUSTOM"] = "Custom";
13
+ return OTP_CONFIG;
14
+ }({});
15
+ export let countType = /*#__PURE__*/function (countType) {
16
+ countType[countType["RETRY"] = 0] = "RETRY";
17
+ countType[countType["RESEND"] = 1] = "RESEND";
18
+ return countType;
19
+ }({});
20
+ export const VALIDATE_OTP_SCREENS = {
21
+ CONTACT_LIST: 'CONTACT_LIST',
22
+ OTP_VIEW: 'OTP_VIEW',
23
+ VERIFICATION_COMPLETE: 'VERIFICATION_COMPLETE'
8
24
  };
9
- export function parseBody(body, userInput) {
10
- const requestBody = JSON.parse(JSON.stringify(body));
11
- for (const key in requestBody) {
12
- if (Object.prototype.hasOwnProperty.call(requestBody, key)) {
13
- const value = requestBody[key];
14
- if (typeof value === 'object') {
15
- requestBody[key] = parseBody(value, userInput);
16
- } else if (Array.isArray(value)) {
17
- value.forEach(val => {
18
- requestBody[key] = parseBody(val, userInput);
19
- });
20
- } else {
21
- if (typeof value === 'string' && isDyanmicValue(value) && value.includes('userInput')) {
22
- if (value.includes('captureInput')) requestBody[key] = userInput.captureInput;
23
- }
24
- }
25
+ export const generateOTP = async (payload, props) => {
26
+ try {
27
+ var _props$otpGeneration;
28
+ const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;
29
+ const apiData = createApiData(payload, props, isCustomConfig ? props === null || props === void 0 || (_props$otpGeneration = props.otpGeneration) === null || _props$otpGeneration === void 0 ? void 0 : _props$otpGeneration.uri : `{baseURI}${ENDPOINTS.GENERATE_OTP_ENDPOINT}`, 'POST', null, isCustomConfig ? props.otpGeneration : undefined);
30
+ const apiResponse = await getAxiosApiResponse(apiData);
31
+ if (isCustomConfig && apiData.responseJsonLogic) {
32
+ return jsonLogic.apply(apiData.responseJsonLogic, apiResponse.data);
25
33
  }
34
+ return apiResponse.data;
35
+ } catch (error) {
36
+ var _error$response;
37
+ Logger.getInstance().logEvent('~ generateOTP', error.message, LOG_TYPE.SDK_ERROR);
38
+ console.error('error: ', JSON.stringify(error));
39
+ return (error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) ?? false;
26
40
  }
27
- return requestBody;
28
- }
29
- export function parseKeyValue(array, userInput) {
30
- array.forEach(item => {
31
- if (isDyanmicValue(item.value) && item.value.includes('userInput')) {
32
- if (item.value.includes('captureInput')) item.value = userInput.captureInput;
41
+ };
42
+ export const verifyOTP = async (payload, props) => {
43
+ try {
44
+ var _props$validationApi;
45
+ const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;
46
+ const apiData = createApiData(payload, props, isCustomConfig ? props === null || props === void 0 || (_props$validationApi = props.validationApi) === null || _props$validationApi === void 0 ? void 0 : _props$validationApi.uri : `{baseURI}${ENDPOINTS.VERIFY_OTP_ENDPOINT}`, 'POST', null, isCustomConfig ? props.validationApi : undefined);
47
+ const apiResponse = await getAxiosApiResponse(apiData);
48
+ if (isCustomConfig && apiData.responseJsonLogic) {
49
+ return jsonLogic.apply(apiData.responseJsonLogic, apiResponse.data);
33
50
  }
34
- });
35
- return array;
36
- }
37
- export const generateOTP = async api => {
38
- // TESTING
51
+ return apiResponse.data;
52
+ } catch (error) {
53
+ var _error$response2;
54
+ Logger.getInstance().logEvent('~ verifyOTP', error.message, LOG_TYPE.SDK_ERROR);
55
+ console.error('error: ', JSON.stringify(error));
56
+ return (error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) ?? false;
57
+ }
58
+ };
59
+ export const resendOTP = async (payload, props) => {
39
60
  try {
40
- const apiData = {
41
- errorJsonPath: '',
42
- responseJsonPath: '',
43
- uri: api.uri,
44
- httpMethod: api.httpMethod,
45
- timeout: api.timeout,
46
- headers: api.headers
47
- };
48
- if (api.requestBody) {
49
- apiData.requestBody = api.requestBody;
61
+ var _props$resendApi;
62
+ const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;
63
+ const apiData = createApiData(payload, props, isCustomConfig ? props === null || props === void 0 || (_props$resendApi = props.resendApi) === null || _props$resendApi === void 0 ? void 0 : _props$resendApi.uri : `{baseURI}${ENDPOINTS.RESEND_OTP_ENDPOINT}`, 'POST', null, isCustomConfig ? props.resendApi : undefined);
64
+ const apiResponse = await getAxiosApiResponse(apiData);
65
+ if (isCustomConfig && apiData.responseJsonLogic) {
66
+ return jsonLogic.apply(apiData.responseJsonLogic, apiResponse.data);
50
67
  }
51
- if (api.pathParams) {
52
- apiData.pathParams = api.pathParams;
68
+ return apiResponse.data;
69
+ } catch (error) {
70
+ var _error$response3;
71
+ Logger.getInstance().logEvent('~ resendOTP', error.message, LOG_TYPE.SDK_ERROR);
72
+ console.error('error: ', JSON.stringify(error));
73
+ return (error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) ?? false;
74
+ }
75
+ };
76
+ export const parseResendConfig = inputResendConfig => {
77
+ const resendConfig = DEFAULT_RETRY_CONFIG;
78
+ if (inputResendConfig) {
79
+ if (inputResendConfig.buttonTitle) {
80
+ resendConfig.buttonTitle = inputResendConfig.buttonTitle;
53
81
  }
54
- if (api.queryParams) {
55
- apiData.queryParams = api.queryParams;
82
+ if (inputResendConfig.enableDelay) {
83
+ resendConfig.enableDelay = inputResendConfig.enableDelay;
56
84
  }
57
- const apiResponse = await getApiResponse(apiData);
58
- return jsonLogic.apply(api.responseJsonLogic, apiResponse.data);
59
- } catch (error) {
60
- Logger.getInstance().logEvent('~ generateOTP', error.message, LOG_TYPE.SDK_ERROR);
85
+ if (inputResendConfig.maxResends) {
86
+ resendConfig.maxResends = inputResendConfig.maxResends;
87
+ }
88
+ }
89
+ return resendConfig;
90
+ };
91
+ export function maskContactId(contactId) {
92
+ const idString = String(contactId);
93
+
94
+ // Check if it's an email based on the presence of '@'
95
+ if (idString.includes('@')) {
96
+ // Split email into username and domain parts
97
+ const [username, domain] = idString.split('@');
98
+
99
+ // Show first 3 characters and replace the rest with asterisks
100
+ const visibleUsername = username.slice(0, 3) + '*'.repeat(username.length - 3);
101
+ return `${visibleUsername}@${domain}`;
102
+ } else {
103
+ // For non-email contact ID, show first 5 characters as asterisks and last 4 digits
104
+ const lastFourDigits = idString.slice(-4);
105
+ return `***** *${lastFourDigits}`;
106
+ }
107
+ }
108
+ export const truncateOrderId = shipmentId => {
109
+ let displayShipmentId = '';
110
+ if ((shipmentId === null || shipmentId === void 0 ? void 0 : shipmentId.length) >= 16) {
111
+ const startingTen = shipmentId.slice(0, 5);
112
+ const lastTen = shipmentId.slice(-5);
113
+ displayShipmentId = `${startingTen}...${lastTen}`;
114
+ } else {
115
+ displayShipmentId = shipmentId;
116
+ }
117
+ return displayShipmentId;
118
+ };
119
+ export const isNotNullOrEmpty = value => {
120
+ if (value === null || value === undefined) {
61
121
  return false;
62
122
  }
123
+ if (typeof value === 'string' && value.trim() === '') {
124
+ return false;
125
+ }
126
+ if (Array.isArray(value) && value.length === 0) {
127
+ return false;
128
+ }
129
+ return true;
63
130
  };
64
- export const checkForValidation = async (otp, validation, userInput) => {
65
- // API
66
- if (validation.selectedIndex === 0) {
67
- const otpValue = JSONPath({
68
- path: '$.userInput.captureInput',
69
- json: userInput
70
- })[0];
71
- try {
72
- //@ts-ignore
73
- const api = validation.logic.api;
74
- const apiData = {
75
- errorJsonPath: '',
76
- responseJsonPath: '',
77
- uri: api.uri,
78
- httpMethod: api.httpMethod,
79
- timeout: api.timeout,
80
- headers: api.headers
81
- };
82
- if (api.requestBody) {
83
- const parsedRequestBody = parseBody(api.requestBody, {
84
- captureInput: otpValue
131
+ export function generateContactList(response, orderId) {
132
+ var _response$phone, _response$additionalP, _response$additionalE;
133
+ // Initialize an array to store the transformed contact list
134
+ const contactList = [];
135
+
136
+ // Handle the primary phone number
137
+ if ((_response$phone = response.phone) !== null && _response$phone !== void 0 && _response$phone.number) {
138
+ contactList.push({
139
+ id: response.id,
140
+ // Unique identifier
141
+ mode: 'PHONE',
142
+ type: 'PRIMARY',
143
+ index: 0,
144
+ value: response.phone.number,
145
+ // Actual phone number
146
+ orderId
147
+ });
148
+ }
149
+
150
+ // Handle additional phone numbers
151
+ if ((_response$additionalP = response.additionalPhone) !== null && _response$additionalP !== void 0 && _response$additionalP.length) {
152
+ response.additionalPhone.forEach((phone, idx) => {
153
+ if (phone !== null && phone !== void 0 && phone.number) {
154
+ contactList.push({
155
+ id: response.id,
156
+ // Unique identifier
157
+ mode: 'PHONE',
158
+ type: 'SECONDARY',
159
+ index: idx,
160
+ value: phone.number,
161
+ // Actual phone number
162
+ orderId
85
163
  });
86
- apiData.requestBody = parsedRequestBody;
87
164
  }
88
- if (api.pathParams) {
89
- parseKeyValue(api.pathParams, {
90
- captureInput: otpValue
165
+ });
166
+ }
167
+
168
+ // Handle the primary email
169
+ if (response.email) {
170
+ contactList.push({
171
+ id: response.id,
172
+ // Unique identifier
173
+ mode: 'EMAIL',
174
+ type: 'PRIMARY',
175
+ index: 0,
176
+ value: response.email,
177
+ // Actual email address
178
+ orderId
179
+ });
180
+ }
181
+
182
+ // Handle additional emails
183
+ if ((_response$additionalE = response.additionalEmail) !== null && _response$additionalE !== void 0 && _response$additionalE.length) {
184
+ response.additionalEmail.forEach((email, idx) => {
185
+ if (email !== null && email !== void 0 && email.id) {
186
+ contactList.push({
187
+ id: response.id,
188
+ // Unique identifier
189
+ mode: 'EMAIL',
190
+ type: 'SECONDARY',
191
+ index: idx,
192
+ value: email.id,
193
+ // Actual email address
194
+ orderId
91
195
  });
92
- apiData.pathParams = api.pathParams;
93
196
  }
94
- if (api.queryParams) {
95
- parseKeyValue(api.queryParams, {
96
- captureInput: otpValue
97
- });
98
- apiData.queryParams = api.queryParams;
197
+ });
198
+ }
199
+ return contactList;
200
+ }
201
+ export const getUniqueRefId = (moId, progressGroupId, attemptCount) => {
202
+ var _refId$toString;
203
+ const refId = `${moId}${progressGroupId ? '::' + progressGroupId : ''}${attemptCount ? '::' + attemptCount : ''}`;
204
+ const _hashedRefId = getUuidByString(refId === null || refId === void 0 || (_refId$toString = refId.toString()) === null || _refId$toString === void 0 ? void 0 : _refId$toString.trim());
205
+ return _hashedRefId;
206
+ };
207
+ export const updateRetryCount = async retryCount => {
208
+ let storage = Storage.getInstance();
209
+ await storage.setSharedItem(SHARED_PREFERENCE_RETRY_COUNT, JSON.stringify(retryCount));
210
+ };
211
+ export const updateResendCount = async retryCount => {
212
+ let storage = Storage.getInstance();
213
+ await storage.setSharedItem(SHARED_PREFERENCE_RESEND_COUNT, JSON.stringify(retryCount));
214
+ };
215
+ export const getCount = async type => {
216
+ const storage = Storage.getInstance();
217
+ let count = 0;
218
+ if (type === countType.RESEND) {
219
+ count = await storage.getSharedItem(SHARED_PREFERENCE_RESEND_COUNT);
220
+ } else if (type === countType.RETRY) {
221
+ count = await storage.getSharedItem(SHARED_PREFERENCE_RETRY_COUNT);
222
+ }
223
+
224
+ // Parse and validate the count
225
+ if (count) {
226
+ try {
227
+ const parsedCount = JSON.parse(count);
228
+ if (typeof parsedCount === 'number') {
229
+ return parsedCount;
99
230
  }
100
- const apiResponse = await getApiResponse(apiData);
101
- return jsonLogic.apply(api.responseJsonLogic, apiResponse.data);
102
231
  } catch (error) {
103
- Logger.getInstance().logEvent('~ checkForValidation', error.message, LOG_TYPE.SDK_ERROR);
104
- return false;
232
+ console.warn('Invalid count value:', count);
105
233
  }
106
234
  }
107
- // Exact Value
108
- else if (validation.selectedIndex === 1) {
109
- // @ts-ignore
110
- const value = validation.logic.value;
111
- return value == otp;
112
- }
113
- // Invalid input received
114
- else {
115
- return false;
116
- }
235
+
236
+ // Default to 0 if count is invalid
237
+ return 0;
117
238
  };
118
- export const parseRetryConfig = inputRetryConfig => {
119
- const retryConfig = DEFAULT_RETRY_CONFIG;
120
- if (inputRetryConfig) {
121
- if (inputRetryConfig.buttonTitle) {
122
- retryConfig.buttonTitle = inputRetryConfig.buttonTitle;
123
- }
124
- if (inputRetryConfig.delay) {
125
- retryConfig.delay = inputRetryConfig.delay;
126
- }
127
- if (inputRetryConfig.maxAttempt) {
128
- retryConfig.maxAttempt = inputRetryConfig.maxAttempt;
129
- }
130
- }
131
- return retryConfig;
239
+ export const resetCount = async () => {
240
+ let storage = Storage.getInstance();
241
+ await storage.setSharedItem(SHARED_PREFERENCE_RESEND_COUNT, JSON.stringify(0));
242
+ await storage.setSharedItem(SHARED_PREFERENCE_RETRY_COUNT, JSON.stringify(0));
132
243
  };
133
244
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["jsonLogic","JSONPath","Logger","LOG_TYPE","getApiResponse","DEFAULT_RETRY_CONFIG","isDyanmicValue","input","charAt","length","parseBody","body","userInput","requestBody","JSON","parse","stringify","key","Object","prototype","hasOwnProperty","call","value","Array","isArray","forEach","val","includes","captureInput","parseKeyValue","array","item","generateOTP","api","apiData","errorJsonPath","responseJsonPath","uri","httpMethod","timeout","headers","pathParams","queryParams","apiResponse","apply","responseJsonLogic","data","error","getInstance","logEvent","message","SDK_ERROR","checkForValidation","otp","validation","selectedIndex","otpValue","path","json","logic","parsedRequestBody","parseRetryConfig","inputRetryConfig","retryConfig","buttonTitle","delay","maxAttempt"],"sources":["utils.ts"],"sourcesContent":["import * as jsonLogic from 'json-logic-js';\nimport { JSONPath } from 'jsonpath-plus';\nimport Logger, { LOG_TYPE } from '../../../utils/Logger';\nimport {\n APIData,\n getApiResponse,\n KeyValueArray,\n} from '../../../utils/ApiUtils';\nimport { DEFAULT_RETRY_CONFIG } from './constants';\nimport type {\n API,\n InputType,\n Validation,\n RetryConfig,\n} from './ValidateOTPSchema';\n\nconst isDyanmicValue = function (input: string) {\n if (\n input.charAt(0) === '{' &&\n input.charAt(1) === '{' &&\n input.charAt(input.length - 1) === '}' &&\n input.charAt(input.length - 2) === '}'\n )\n return true;\n else return false;\n};\n\nexport function parseBody(body: any, userInput: any) {\n const requestBody = JSON.parse(JSON.stringify(body));\n for (const key in requestBody) {\n if (Object.prototype.hasOwnProperty.call(requestBody, key)) {\n const value = requestBody[key];\n if (typeof value === 'object') {\n requestBody[key] = parseBody(value, userInput);\n } else if (Array.isArray(value)) {\n value.forEach((val) => {\n requestBody[key] = parseBody(val, userInput);\n });\n } else {\n if (\n typeof value === 'string' &&\n isDyanmicValue(value) &&\n value.includes('userInput')\n ) {\n if (value.includes('captureInput'))\n requestBody[key] = userInput.captureInput;\n }\n }\n }\n }\n return requestBody;\n}\n\nexport function parseKeyValue(array: KeyValueArray[], userInput: any) {\n array.forEach((item) => {\n if (isDyanmicValue(item.value) && item.value.includes('userInput')) {\n if (item.value.includes('captureInput'))\n item.value = userInput.captureInput;\n }\n });\n return array;\n}\n\nexport const generateOTP = async (api: API) => {\n // TESTING\n try {\n const apiData: APIData = {\n errorJsonPath: '',\n responseJsonPath: '',\n uri: api.uri,\n httpMethod: api.httpMethod,\n timeout: api.timeout,\n headers: api.headers,\n };\n if (api.requestBody) {\n apiData.requestBody = api.requestBody;\n }\n if (api.pathParams) {\n apiData.pathParams = api.pathParams;\n }\n if (api.queryParams) {\n apiData.queryParams = api.queryParams;\n }\n\n const apiResponse = await getApiResponse(apiData);\n\n return jsonLogic.apply(\n <jsonLogic.RulesLogic>api.responseJsonLogic,\n apiResponse.data\n );\n } catch (error: any) {\n Logger.getInstance().logEvent(\n '~ generateOTP',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n return false;\n }\n};\n\nexport const checkForValidation = async (\n otp: string,\n validation: Validation,\n userInput: any\n): Promise<boolean> => {\n // API\n if (validation.selectedIndex === 0) {\n const otpValue = JSONPath({\n path: '$.userInput.captureInput',\n json: userInput,\n })[0];\n\n try {\n //@ts-ignore\n const api: API = validation.logic.api;\n const apiData: APIData = {\n errorJsonPath: '',\n responseJsonPath: '',\n uri: api.uri,\n httpMethod: api.httpMethod,\n timeout: api.timeout,\n headers: api.headers,\n };\n if (api.requestBody) {\n const parsedRequestBody = parseBody(api.requestBody, {\n captureInput: otpValue,\n });\n apiData.requestBody = parsedRequestBody;\n }\n if (api.pathParams) {\n parseKeyValue(api.pathParams, { captureInput: otpValue });\n apiData.pathParams = api.pathParams;\n }\n if (api.queryParams) {\n parseKeyValue(api.queryParams, { captureInput: otpValue });\n apiData.queryParams = api.queryParams;\n }\n const apiResponse = await getApiResponse(apiData);\n return jsonLogic.apply(\n <jsonLogic.RulesLogic>api.responseJsonLogic,\n apiResponse.data\n );\n } catch (error: any) {\n Logger.getInstance().logEvent(\n '~ checkForValidation',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n return false;\n }\n }\n // Exact Value\n else if (validation.selectedIndex === 1) {\n // @ts-ignore\n const value: InputType = validation.logic.value;\n return value == otp;\n }\n // Invalid input received\n else {\n return false;\n }\n};\n\nexport const parseRetryConfig = (\n inputRetryConfig: RetryConfig | undefined\n): RetryConfig => {\n const retryConfig: RetryConfig = DEFAULT_RETRY_CONFIG;\n if (inputRetryConfig) {\n if (inputRetryConfig.buttonTitle) {\n retryConfig.buttonTitle = inputRetryConfig.buttonTitle;\n }\n if (inputRetryConfig.delay) {\n retryConfig.delay = inputRetryConfig.delay;\n }\n if (inputRetryConfig.maxAttempt) {\n retryConfig.maxAttempt = inputRetryConfig.maxAttempt;\n }\n }\n return retryConfig;\n};\n"],"mappings":"AAAA,OAAO,KAAKA,SAAS,MAAM,eAAe;AAC1C,SAASC,QAAQ,QAAQ,eAAe;AACxC,OAAOC,MAAM,IAAIC,QAAQ,QAAQ,uBAAuB;AACxD,SAEEC,cAAc,QAET,yBAAyB;AAChC,SAASC,oBAAoB,QAAQ,aAAa;AAQlD,MAAMC,cAAc,GAAG,SAAAA,CAAUC,KAAa,EAAE;EAC9C,IACEA,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IACvBD,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IACvBD,KAAK,CAACC,MAAM,CAACD,KAAK,CAACE,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,IACtCF,KAAK,CAACC,MAAM,CAACD,KAAK,CAACE,MAAM,GAAG,CAAC,CAAC,KAAK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C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAC3B,sBAAsB,EACtBF,KAAK,CAACG,OAAO,EACb/C,QAAQ,CAACgD,SACX,CAAC;MACD,OAAO,KAAK;IACd;EACF;EACA;EAAA,KACK,IAAIG,UAAU,CAACC,aAAa,KAAK,CAAC,EAAE;IACvC;IACA,MAAMjC,KAAgB,GAAGgC,UAAU,CAACK,KAAK,CAACrC,KAAK;IAC/C,OAAOA,KAAK,IAAI+B,GAAG;EACrB;EACA;EAAA,KACK;IACH,OAAO,KAAK;EACd;AACF,CAAC;AAED,OAAO,MAAMQ,gBAAgB,GAC3BC,gBAAyC,IACzB;EAChB,MAAMC,WAAwB,GAAG1D,oBAAoB;EACrD,IAAIyD,gBAAgB,EAAE;IACpB,IAAIA,gBAAgB,CAACE,WAAW,EAAE;MAChCD,WAAW,CAACC,WAAW,GAAGF,gBAAgB,CAACE,WAAW;IACxD;IACA,IAAIF,gBAAgB,CAACG,KAAK,EAAE;MAC1BF,WAAW,CAACE,KAAK,GAAGH,gBAAgB,CAACG,KAAK;IAC5C;IACA,IAAIH,gBAAgB,CAACI,UAAU,EAAE;MAC/BH,WAAW,CAACG,UAAU,GAAGJ,gBAAgB,CAACI,UAAU;IACtD;EACF;EACA,OAAOH,WAAW;AACpB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["jsonLogic","Logger","LOG_TYPE","createApiData","getAxiosApiResponse","DEFAULT_RETRY_CONFIG","Storage","SHARED_PREFERENCE_RESEND_COUNT","SHARED_PREFERENCE_RETRY_COUNT","ENDPOINTS","getUuidByString","OTP_CONFIG","countType","VALIDATE_OTP_SCREENS","CONTACT_LIST","OTP_VIEW","VERIFICATION_COMPLETE","generateOTP","payload","props","_props$otpGeneration","isCustomConfig","otpConfig","CUSTOM","apiData","otpGeneration","uri","GENERATE_OTP_ENDPOINT","undefined","apiResponse","responseJsonLogic","apply","data","error","_error$response","getInstance","logEvent","message","SDK_ERROR","console","JSON","stringify","response","verifyOTP","_props$validationApi","validationApi","VERIFY_OTP_ENDPOINT","_error$response2","resendOTP","_props$resendApi","resendApi","RESEND_OTP_ENDPOINT","_error$response3","parseResendConfig","inputResendConfig","resendConfig","buttonTitle","enableDelay","maxResends","maskContactId","contactId","idString","String","includes","username","domain","split","visibleUsername","slice","repeat","length","lastFourDigits","truncateOrderId","shipmentId","displayShipmentId","startingTen","lastTen","isNotNullOrEmpty","value","trim","Array","isArray","generateContactList","orderId","_response$phone","_response$additionalP","_response$additionalE","contactList","phone","number","push","id","mode","type","index","additionalPhone","forEach","idx","email","additionalEmail","getUniqueRefId","moId","progressGroupId","attemptCount","_refId$toString","refId","_hashedRefId","toString","updateRetryCount","retryCount","storage","setSharedItem","updateResendCount","getCount","count","RESEND","getSharedItem","RETRY","parsedCount","parse","warn","resetCount"],"sources":["utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport * as jsonLogic from 'json-logic-js';\nimport Logger, { LOG_TYPE } from '../../../utils/Logger';\nimport { createApiData, getAxiosApiResponse } from '../../../utils/ApiUtils';\nimport { DEFAULT_RETRY_CONFIG } from './constants';\nimport type {\n ResendOTPConfigType,\n EmailAndPhoneResponse,\n ContactType,\n ValidateOTPInput,\n ResendOTPPayloadType,\n ResponseType,\n ErrorResponseType,\n GenerateOtpPayloadType,\n} from './ValidateOTPSchema';\nimport Storage from '../../../utils/storage';\nimport {\n SHARED_PREFERENCE_RESEND_COUNT,\n SHARED_PREFERENCE_RETRY_COUNT,\n} from '../../../manager/syncmanager/constants';\nimport { ENDPOINTS } from '../../../constants/apiConstants';\nimport getUuidByString from 'uuid-by-string';\n\nexport enum OTP_CONFIG {\n OS1 = 'OTP_CONFIG',\n CUSTOM = 'Custom',\n}\n\ntype PropType = ValidateOTPInput & { domain: string };\n\nexport enum countType {\n RETRY,\n RESEND,\n}\n\nexport const VALIDATE_OTP_SCREENS = {\n CONTACT_LIST: 'CONTACT_LIST',\n OTP_VIEW: 'OTP_VIEW',\n VERIFICATION_COMPLETE: 'VERIFICATION_COMPLETE',\n};\n\nexport const generateOTP = async (\n payload: GenerateOtpPayloadType,\n props: PropType\n): Promise<any | ResponseType | ErrorResponseType> => {\n try {\n const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;\n const apiData = createApiData(\n payload,\n props,\n isCustomConfig\n ? props?.otpGeneration?.uri\n : `{baseURI}${ENDPOINTS.GENERATE_OTP_ENDPOINT}`,\n 'POST',\n null,\n isCustomConfig ? props.otpGeneration : undefined\n );\n\n const apiResponse = await getAxiosApiResponse(apiData);\n\n if (isCustomConfig && apiData.responseJsonLogic) {\n return jsonLogic.apply(\n <jsonLogic.RulesLogic>apiData.responseJsonLogic,\n apiResponse.data\n );\n }\n\n return apiResponse.data;\n } catch (error: any) {\n Logger.getInstance().logEvent(\n '~ generateOTP',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n console.error('error: ', JSON.stringify(error));\n return error?.response?.data ?? false;\n }\n};\n\nexport const verifyOTP = async (\n payload: any,\n props: PropType\n): Promise<any | ResponseType | ErrorResponseType> => {\n try {\n const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;\n const apiData = createApiData(\n payload,\n props,\n isCustomConfig\n ? props?.validationApi?.uri\n : `{baseURI}${ENDPOINTS.VERIFY_OTP_ENDPOINT}`,\n 'POST',\n null,\n isCustomConfig ? props.validationApi : undefined\n );\n\n const apiResponse = await getAxiosApiResponse(apiData);\n\n if (isCustomConfig && apiData.responseJsonLogic) {\n return jsonLogic.apply(\n <jsonLogic.RulesLogic>apiData.responseJsonLogic,\n apiResponse.data\n );\n }\n\n return apiResponse.data;\n } catch (error: any) {\n Logger.getInstance().logEvent(\n '~ verifyOTP',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n console.error('error: ', JSON.stringify(error));\n return error?.response?.data ?? false;\n }\n};\n\nexport const resendOTP = async (\n payload: ResendOTPPayloadType,\n props: PropType\n): Promise<any | ResponseType | ErrorResponseType> => {\n try {\n const isCustomConfig = props.otpConfig === OTP_CONFIG.CUSTOM;\n const apiData = createApiData(\n payload,\n props,\n isCustomConfig\n ? props?.resendApi?.uri\n : `{baseURI}${ENDPOINTS.RESEND_OTP_ENDPOINT}`,\n 'POST',\n null,\n isCustomConfig ? props.resendApi : undefined\n );\n\n const apiResponse = await getAxiosApiResponse(apiData);\n\n if (isCustomConfig && apiData.responseJsonLogic) {\n return jsonLogic.apply(\n <jsonLogic.RulesLogic>apiData.responseJsonLogic,\n apiResponse.data\n );\n }\n\n return apiResponse.data;\n } catch (error: any) {\n Logger.getInstance().logEvent(\n '~ resendOTP',\n error.message,\n LOG_TYPE.SDK_ERROR\n );\n console.error('error: ', JSON.stringify(error));\n return error?.response?.data ?? false;\n }\n};\n\nexport const parseResendConfig = (\n inputResendConfig: ResendOTPConfigType | undefined\n): ResendOTPConfigType => {\n const resendConfig: ResendOTPConfigType = DEFAULT_RETRY_CONFIG;\n if (inputResendConfig) {\n if (inputResendConfig.buttonTitle) {\n resendConfig.buttonTitle = inputResendConfig.buttonTitle;\n }\n if (inputResendConfig.enableDelay) {\n resendConfig.enableDelay = inputResendConfig.enableDelay;\n }\n if (inputResendConfig.maxResends) {\n resendConfig.maxResends = inputResendConfig.maxResends;\n }\n }\n return resendConfig;\n};\n\nexport function maskContactId(contactId: string) {\n const idString = String(contactId);\n\n // Check if it's an email based on the presence of '@'\n if (idString.includes('@')) {\n // Split email into username and domain parts\n const [username, domain] = idString.split('@');\n\n // Show first 3 characters and replace the rest with asterisks\n const visibleUsername =\n username.slice(0, 3) + '*'.repeat(username.length - 3);\n\n return `${visibleUsername}@${domain}`;\n } else {\n // For non-email contact ID, show first 5 characters as asterisks and last 4 digits\n const lastFourDigits = idString.slice(-4);\n return `***** *${lastFourDigits}`;\n }\n}\n\nexport const truncateOrderId = (shipmentId: string) => {\n let displayShipmentId = '';\n if (shipmentId?.length >= 16) {\n const startingTen = shipmentId.slice(0, 5);\n const lastTen = shipmentId.slice(-5);\n displayShipmentId = `${startingTen}...${lastTen}`;\n } else {\n displayShipmentId = shipmentId;\n }\n return displayShipmentId;\n};\n\nexport const isNotNullOrEmpty = (value: any): boolean => {\n if (value === null || value === undefined) {\n return false;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return false;\n }\n if (Array.isArray(value) && value.length === 0) {\n return false;\n }\n return true;\n};\n\nexport function generateContactList(\n response: EmailAndPhoneResponse,\n orderId?: string\n): ContactType[] {\n // Initialize an array to store the transformed contact list\n const contactList: ContactType[] = [];\n\n // Handle the primary phone number\n if (response.phone?.number) {\n contactList.push({\n id: response.id, // Unique identifier\n mode: 'PHONE',\n type: 'PRIMARY',\n index: 0,\n value: response.phone.number, // Actual phone number\n orderId,\n });\n }\n\n // Handle additional phone numbers\n if (response.additionalPhone?.length) {\n response.additionalPhone.forEach((phone, idx) => {\n if (phone?.number) {\n contactList.push({\n id: response.id, // Unique identifier\n mode: 'PHONE',\n type: 'SECONDARY',\n index: idx,\n value: phone.number, // Actual phone number\n orderId,\n });\n }\n });\n }\n\n // Handle the primary email\n if (response.email) {\n contactList.push({\n id: response.id, // Unique identifier\n mode: 'EMAIL',\n type: 'PRIMARY',\n index: 0,\n value: response.email, // Actual email address\n orderId,\n });\n }\n\n // Handle additional emails\n if (response.additionalEmail?.length) {\n response.additionalEmail.forEach((email, idx) => {\n if (email?.id) {\n contactList.push({\n id: response.id, // Unique identifier\n mode: 'EMAIL',\n type: 'SECONDARY',\n index: idx,\n value: email.id, // Actual email address\n orderId,\n });\n }\n });\n }\n\n return contactList;\n}\n\nexport const getUniqueRefId = (\n moId: string,\n progressGroupId?: string | null,\n attemptCount?: number | null\n) => {\n const refId = `${moId}${progressGroupId ? '::' + progressGroupId : ''}${\n attemptCount ? '::' + attemptCount : ''\n }`;\n const _hashedRefId = getUuidByString(refId?.toString()?.trim());\n return _hashedRefId;\n};\n\nexport const updateRetryCount = async (retryCount: number) => {\n let storage = Storage.getInstance();\n\n await storage.setSharedItem(\n SHARED_PREFERENCE_RETRY_COUNT,\n JSON.stringify(retryCount)\n );\n};\n\nexport const updateResendCount = async (retryCount: number) => {\n let storage = Storage.getInstance();\n\n await storage.setSharedItem(\n SHARED_PREFERENCE_RESEND_COUNT,\n JSON.stringify(retryCount)\n );\n};\n\nexport const getCount = async (type: countType): Promise<number> => {\n const storage = Storage.getInstance();\n let count: any = 0;\n\n if (type === countType.RESEND) {\n count = await storage.getSharedItem(SHARED_PREFERENCE_RESEND_COUNT);\n } else if (type === countType.RETRY) {\n count = await storage.getSharedItem(SHARED_PREFERENCE_RETRY_COUNT);\n }\n\n // Parse and validate the count\n if (count) {\n try {\n const parsedCount = JSON.parse(count);\n if (typeof parsedCount === 'number') {\n return parsedCount;\n }\n } catch (error) {\n console.warn('Invalid count value:', count);\n }\n }\n\n // Default to 0 if count is invalid\n return 0;\n};\n\nexport const resetCount = async () => {\n let storage = Storage.getInstance();\n\n await storage.setSharedItem(\n SHARED_PREFERENCE_RESEND_COUNT,\n JSON.stringify(0)\n );\n\n await storage.setSharedItem(SHARED_PREFERENCE_RETRY_COUNT, JSON.stringify(0));\n};\n"],"mappings":"AAAA;AACA,OAAO,KAAKA,SAAS,MAAM,eAAe;AAC1C,OAAOC,MAAM,IAAIC,QAAQ,QAAQ,uBAAuB;AACxD,SAASC,aAAa,EAAEC,mBAAmB,QAAQ,yBAAyB;AAC5E,SAASC,oBAAoB,QAAQ,aAAa;AAWlD,OAAOC,OAAO,MAAM,wBAAwB;AAC5C,SACEC,8BAA8B,EAC9BC,6BAA6B,QACxB,wCAAwC;AAC/C,SAASC,SAAS,QAAQ,iCAAiC;AAC3D,OAAOC,eAAe,MAAM,gBAAgB;AAE5C,WAAYC,UAAU,0BAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAOtB,WAAYC,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAKrB,OAAO,MAAMC,oBAAoB,GAAG;EAClCC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AK,CAACL,KAAK,CAAC;MACrC,IAAI,OAAOI,WAAW,KAAK,QAAQ,EAAE;QACnC,OAAOA,WAAW;MACpB;IACF,CAAC,CAAC,OAAOrF,KAAK,EAAE;MACdM,OAAO,CAACiF,IAAI,CAAC,sBAAsB,EAAEN,KAAK,CAAC;IAC7C;EACF;;EAEA;EACA,OAAO,CAAC;AACV,CAAC;AAED,OAAO,MAAMO,UAAU,GAAG,MAAAA,CAAA,KAAY;EACpC,IAAIX,OAAO,GAAGxG,OAAO,CAAC6B,WAAW,CAAC,CAAC;EAEnC,MAAM2E,OAAO,CAACC,aAAa,CACzBxG,8BAA8B,EAC9BiC,IAAI,CAACC,SAAS,CAAC,CAAC,CAClB,CAAC;EAED,MAAMqE,OAAO,CAACC,aAAa,CAACvG,6BAA6B,EAAEgC,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import { Dimensions } from 'react-native';
2
+ const {
3
+ width,
4
+ height
5
+ } = Dimensions.get('window');
6
+
7
+ //Guideline sizes are based on standard ~5" screen mobile device
8
+ const guidelineBaseWidth = 350;
9
+ const guidelineBaseHeight = 680;
10
+ const sWidth = size => width / guidelineBaseWidth * size;
11
+ const sHeight = size => height / guidelineBaseHeight * size;
12
+ const sCorner = (size, factor = 0.5) => size + (sWidth(size) - size) * factor;
13
+ export { sWidth, sHeight, sCorner };
14
+ //# sourceMappingURL=Scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Dimensions","width","height","get","guidelineBaseWidth","guidelineBaseHeight","sWidth","size","sHeight","sCorner","factor"],"sources":["Scale.ts"],"sourcesContent":["import { Dimensions } from 'react-native';\nconst { width, height } = Dimensions.get('window');\n\n//Guideline sizes are based on standard ~5\" screen mobile device\nconst guidelineBaseWidth = 350;\nconst guidelineBaseHeight = 680;\n\nconst sWidth = (size: number) => (width / guidelineBaseWidth) * size;\nconst sHeight = (size: number) => (height / guidelineBaseHeight) * size;\nconst sCorner = (size: number, factor = 0.5) =>\n size + (sWidth(size) - size) * factor;\n\nexport { sWidth, sHeight, sCorner };\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,MAAM;EAAEC,KAAK;EAAEC;AAAO,CAAC,GAAGF,UAAU,CAACG,GAAG,CAAC,QAAQ,CAAC;;AAElD;AACA,MAAMC,kBAAkB,GAAG,GAAG;AAC9B,MAAMC,mBAAmB,GAAG,GAAG;AAE/B,MAAMC,MAAM,GAAIC,IAAY,IAAMN,KAAK,GAAGG,kBAAkB,GAAIG,IAAI;AACpE,MAAMC,OAAO,GAAID,IAAY,IAAML,MAAM,GAAGG,mBAAmB,GAAIE,IAAI;AACvE,MAAME,OAAO,GAAGA,CAACF,IAAY,EAAEG,MAAM,GAAG,GAAG,KACzCH,IAAI,GAAG,CAACD,MAAM,CAACC,IAAI,CAAC,GAAGA,IAAI,IAAIG,MAAM;AAEvC,SAASJ,MAAM,EAAEE,OAAO,EAAEC,OAAO","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import ModalWidget from './ModalWidget';
3
+ import { StyleSheet } from 'react-native';
4
+ const ConfirmCancelModal = props => {
5
+ return /*#__PURE__*/React.createElement(ModalWidget, {
6
+ dismissable: true,
7
+ showModal: props.showModal,
8
+ title: {
9
+ label: 'Are you sure you want to cancel orders?'
10
+ },
11
+ primaryButton: {
12
+ label: 'Yes',
13
+ onPress: props.onSuccess,
14
+ styles: modalStyles.primaryButtonStyles
15
+ },
16
+ secondaryButton: {
17
+ label: 'No',
18
+ onPress: props.onFailure,
19
+ styles: modalStyles.secondaryButtonStyles
20
+ }
21
+ });
22
+ };
23
+ export default ConfirmCancelModal;
24
+ const modalStyles = StyleSheet.create({
25
+ primaryButtonStyles: {
26
+ marginTop: 16,
27
+ height: 40,
28
+ borderRadius: 6,
29
+ justifyContent: 'center',
30
+ alignItems: 'center'
31
+ },
32
+ secondaryButtonStyles: {
33
+ marginVertical: 16,
34
+ height: 40,
35
+ borderRadius: 6,
36
+ justifyContent: 'center',
37
+ alignItems: 'center'
38
+ }
39
+ });
40
+ //# sourceMappingURL=ConfirmCancelModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","ModalWidget","StyleSheet","ConfirmCancelModal","props","createElement","dismissable","showModal","title","label","primaryButton","onPress","onSuccess","styles","modalStyles","primaryButtonStyles","secondaryButton","onFailure","secondaryButtonStyles","create","marginTop","height","borderRadius","justifyContent","alignItems","marginVertical"],"sources":["ConfirmCancelModal.tsx"],"sourcesContent":["import React from 'react';\nimport ModalWidget from './ModalWidget';\nimport { StyleSheet } from 'react-native';\n\ninterface ConfirmCancelProps {\n showModal: boolean;\n setShowModal: React.Dispatch<React.SetStateAction<boolean>>;\n onSuccess: () => any;\n onFailure: () => any;\n}\n\nconst ConfirmCancelModal = (props: ConfirmCancelProps) => {\n return (\n <ModalWidget\n dismissable={true}\n showModal={props.showModal}\n title={{ label: 'Are you sure you want to cancel orders?' }}\n primaryButton={{\n label: 'Yes',\n onPress: props.onSuccess,\n styles: modalStyles.primaryButtonStyles,\n }}\n secondaryButton={{\n label: 'No',\n onPress: props.onFailure,\n styles: modalStyles.secondaryButtonStyles,\n }}\n />\n );\n};\n\nexport default ConfirmCancelModal;\n\nconst modalStyles = StyleSheet.create({\n primaryButtonStyles: {\n marginTop: 16,\n height: 40,\n borderRadius: 6,\n justifyContent: 'center',\n alignItems: 'center',\n },\n secondaryButtonStyles: {\n marginVertical: 16,\n height: 40,\n borderRadius: 6,\n justifyContent: 'center',\n alignItems: 'center',\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,UAAU,QAAQ,cAAc;AASzC,MAAMC,kBAAkB,GAAIC,KAAyB,IAAK;EACxD,oBACEJ,KAAA,CAAAK,aAAA,CAACJ,WAAW;IACVK,WAAW,EAAE,IAAK;IAClBC,SAAS,EAAEH,KAAK,CAACG,SAAU;IAC3BC,KAAK,EAAE;MAAEC,KAAK,EAAE;IAA0C,CAAE;IAC5DC,aAAa,EAAE;MACbD,KAAK,EAAE,KAAK;MACZE,OAAO,EAAEP,KAAK,CAACQ,SAAS;MACxBC,MAAM,EAAEC,WAAW,CAACC;IACtB,CAAE;IACFC,eAAe,EAAE;MACfP,KAAK,EAAE,IAAI;MACXE,OAAO,EAAEP,KAAK,CAACa,SAAS;MACxBJ,MAAM,EAAEC,WAAW,CAACI;IACtB;EAAE,CACH,CAAC;AAEN,CAAC;AAED,eAAef,kBAAkB;AAEjC,MAAMW,WAAW,GAAGZ,UAAU,CAACiB,MAAM,CAAC;EACpCJ,mBAAmB,EAAE;IACnBK,SAAS,EAAE,EAAE;IACbC,MAAM,EAAE,EAAE;IACVC,YAAY,EAAE,CAAC;IACfC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd,CAAC;EACDN,qBAAqB,EAAE;IACrBO,cAAc,EAAE,EAAE;IAClBJ,MAAM,EAAE,EAAE;IACVC,YAAY,EAAE,CAAC;IACfC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
@@ -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 { Animated, Platform, SafeAreaView, StyleSheet, Text, View } from 'react-native';
@@ -6,12 +7,14 @@ import { AntDesign } from '@expo/vector-icons';
6
7
  import { Fonts } from '../../styles/executionTasks/CommonStyles';
7
8
  import { ScreenNameSdkConstants, SentryEventNameSdkConstants, SeverityLevelValue } from '../../analytics/sentry/SentrySdkConstants';
8
9
  import { fireEventWithScreenName } from '../../analytics/sentry/SentryAnalyticsUtils';
9
- const DURATION_MEDIUM = 3000;
10
+ const DURATION_MEDIUM = 4500;
10
11
  export let SnackBarType = /*#__PURE__*/function (SnackBarType) {
11
12
  SnackBarType[SnackBarType["SUCCESS"] = 0] = "SUCCESS";
12
13
  SnackBarType[SnackBarType["FAILURE"] = 1] = "FAILURE";
13
14
  SnackBarType[SnackBarType["WARNING"] = 2] = "WARNING";
14
15
  SnackBarType[SnackBarType["PAYMENT_WARNING"] = 3] = "PAYMENT_WARNING";
16
+ SnackBarType[SnackBarType["OTP_SUCCESS"] = 4] = "OTP_SUCCESS";
17
+ SnackBarType[SnackBarType["OTP_FAILED"] = 5] = "OTP_FAILED";
15
18
  return SnackBarType;
16
19
  }({});
17
20
  const SnackbarCustom = ({
@@ -32,6 +35,7 @@ const SnackbarCustom = ({
32
35
  const {
33
36
  scale
34
37
  } = theme.animation;
38
+ const isDarkColorType = type === SnackBarType.PAYMENT_WARNING || type === SnackBarType.OTP_FAILED || type === SnackBarType.OTP_SUCCESS;
35
39
  React.useEffect(() => {
36
40
  return () => {
37
41
  if (hideTimeout.current) clearTimeout(hideTimeout.current);
@@ -87,7 +91,7 @@ const SnackbarCustom = ({
87
91
  pointerEvents: "box-none",
88
92
  accessibilityLiveRegion: "polite",
89
93
  style: [styles.container, {
90
- borderRadius: roundness,
94
+ borderRadius: roundness ? roundness : 8,
91
95
  opacity: opacity,
92
96
  transform: [{
93
97
  scale: visible ? opacity.interpolate({
@@ -99,7 +103,7 @@ const SnackbarCustom = ({
99
103
  // { backgroundColor: colors.onSurface },
100
104
  ]
101
105
  }, /*#__PURE__*/React.createElement(View, {
102
- style: type && type === SnackBarType.FAILURE ? styles.fail : type && type === SnackBarType.WARNING ? styles.warn : type && type === SnackBarType.PAYMENT_WARNING ? styles.paymentWarn : styles.main
106
+ style: type && type === SnackBarType.FAILURE ? styles.fail : type && type === SnackBarType.WARNING ? styles.warn : type && type === SnackBarType.PAYMENT_WARNING ? styles.paymentWarn : type && type === SnackBarType.OTP_SUCCESS ? styles.otpSuccess : type && type === SnackBarType.OTP_FAILED ? styles.otpFailed : styles.main
103
107
  }, type && type === SnackBarType.FAILURE ? /*#__PURE__*/React.createElement(AntDesign, {
104
108
  name: "exclamationcircleo",
105
109
  size: 20,
@@ -108,6 +112,14 @@ const SnackbarCustom = ({
108
112
  name: "infocirlceo",
109
113
  size: 20,
110
114
  color: "#D97706"
115
+ }) : type && type === SnackBarType.OTP_SUCCESS ? /*#__PURE__*/React.createElement(AntDesign, {
116
+ name: "checkcircleo",
117
+ size: 20,
118
+ color: "#059669"
119
+ }) : type && type === SnackBarType.OTP_FAILED ? /*#__PURE__*/React.createElement(AntDesign, {
120
+ name: "closecircleo",
121
+ size: 20,
122
+ color: "#DC2626"
111
123
  }) : /*#__PURE__*/React.createElement(AntDesign, {
112
124
  name: "checkcircleo",
113
125
  size: 20,
@@ -115,11 +127,15 @@ const SnackbarCustom = ({
115
127
  }), /*#__PURE__*/React.createElement(Text, {
116
128
  style: [styles.messageStyle, type === SnackBarType.PAYMENT_WARNING && {
117
129
  color: '#B45309'
130
+ }, type === SnackBarType.OTP_SUCCESS && {
131
+ color: '#059669'
132
+ }, type === SnackBarType.OTP_FAILED && {
133
+ color: '#DC2626'
118
134
  }]
119
135
  }, message), /*#__PURE__*/React.createElement(AntDesign, {
120
136
  name: "close",
121
137
  size: 20,
122
- color: type && type === SnackBarType.PAYMENT_WARNING ? '#3D445C' : 'white',
138
+ color: isDarkColorType ? '#3D445C' : 'white',
123
139
  onPress: () => {
124
140
  setHidden(true);
125
141
  onDismiss();
@@ -180,6 +196,22 @@ const styles = StyleSheet.create({
180
196
  flex: 1,
181
197
  borderRadius: 8
182
198
  },
199
+ otpSuccess: {
200
+ padding: 12,
201
+ flexDirection: 'row',
202
+ alignItems: 'center',
203
+ backgroundColor: '#ECFDF5',
204
+ flex: 1,
205
+ borderRadius: 8
206
+ },
207
+ otpFailed: {
208
+ padding: 12,
209
+ flexDirection: 'row',
210
+ alignItems: 'center',
211
+ backgroundColor: '#FEF2F2',
212
+ flex: 1,
213
+ borderRadius: 8
214
+ },
183
215
  messageStyle: {
184
216
  fontSize: 14,
185
217
  marginStart: 8,