@tap-payments/auth-jsconnect 1.0.51 → 1.0.54

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 (105) hide show
  1. package/build/@types/app.d.ts +3 -3
  2. package/build/@types/form.d.ts +23 -3
  3. package/build/api/data.d.ts +1 -1
  4. package/build/api/data.js +2 -2
  5. package/build/api/entity.d.ts +5 -2
  6. package/build/api/index.d.ts +4 -4
  7. package/build/api/lead.d.ts +1 -1
  8. package/build/app/rootReducer.d.ts +4 -0
  9. package/build/app/rootReducer.js +9 -1
  10. package/build/app/store.d.ts +8 -0
  11. package/build/assets/locales/ar.json +2 -1
  12. package/build/assets/locales/en.json +3 -2
  13. package/build/components/AnimationFlow/AnimationFlow.d.ts +3 -1
  14. package/build/components/AnimationFlow/AnimationFlow.js +9 -1
  15. package/build/components/AnimationFlow/Error.d.ts +6 -0
  16. package/build/components/AnimationFlow/Error.js +32 -0
  17. package/build/components/AnimationFlow/Loader.d.ts +2 -0
  18. package/build/components/AnimationFlow/Loader.js +16 -0
  19. package/build/components/Loader/Loader.d.ts +1 -0
  20. package/build/components/Loader/Loader.js +1 -1
  21. package/build/components/SimpleList/SimpleList.js +1 -0
  22. package/build/constants/app.d.ts +24 -0
  23. package/build/constants/app.js +61 -19
  24. package/build/constants/dummy.d.ts +2 -0
  25. package/build/constants/dummy.js +12 -6
  26. package/build/features/app/bank/bankStore.d.ts +36 -0
  27. package/build/features/app/bank/bankStore.js +218 -0
  28. package/build/features/app/business/businessStore.d.ts +2 -3
  29. package/build/features/app/business/businessStore.js +79 -85
  30. package/build/features/app/connect/connectStore.js +31 -30
  31. package/build/features/app/individual/individualStore.d.ts +36 -0
  32. package/build/features/app/individual/individualStore.js +222 -0
  33. package/build/features/app/password/passwordStore.d.ts +36 -0
  34. package/build/features/app/password/passwordStore.js +218 -0
  35. package/build/features/app/tax/taxStore.d.ts +38 -0
  36. package/build/features/app/tax/taxStore.js +271 -0
  37. package/build/features/bank/Bank.d.ts +2 -1
  38. package/build/features/bank/Bank.js +17 -7
  39. package/build/features/bank/screens/BankDetails/BankDetails.js +1 -2
  40. package/build/features/bank/screens/Verify/OTPInput.d.ts +5 -0
  41. package/build/features/bank/screens/Verify/OTPInput.js +42 -0
  42. package/build/features/bank/screens/Verify/Verify.d.ts +5 -0
  43. package/build/features/bank/screens/Verify/Verify.js +78 -0
  44. package/build/features/bank/screens/Verify/index.d.ts +2 -0
  45. package/build/features/bank/screens/Verify/index.js +2 -0
  46. package/build/features/bank/screens/Verify/validation.d.ts +8 -0
  47. package/build/features/bank/screens/Verify/validation.js +4 -0
  48. package/build/features/business/Business.js +2 -2
  49. package/build/features/business/screens/Activities/Activities.js +8 -8
  50. package/build/features/business/screens/Activities/ActivitiesList.js +7 -7
  51. package/build/features/business/screens/Activities/SalesChannels.js +1 -1
  52. package/build/features/business/screens/BusinessType/CRNumber.d.ts +2 -1
  53. package/build/features/business/screens/BusinessType/CRNumber.js +2 -2
  54. package/build/features/business/screens/BusinessType/CompanyLicense.js +2 -1
  55. package/build/features/business/screens/BusinessType/FLNumber.d.ts +2 -1
  56. package/build/features/business/screens/BusinessType/FLNumber.js +2 -2
  57. package/build/features/business/screens/BusinessType/FreelanceLicense.js +2 -1
  58. package/build/features/business/screens/Confirm/Confirm.js +1 -1
  59. package/build/features/business/screens/Customers/Customers.js +3 -3
  60. package/build/features/business/screens/Customers/ExpectedCustomers.js +3 -3
  61. package/build/features/connect/Connect.js +2 -2
  62. package/build/features/connect/screens/Merchant/BrandList.d.ts +0 -2
  63. package/build/features/connect/screens/Merchant/BrandList.js +16 -40
  64. package/build/features/connect/screens/Merchant/Merchant.js +42 -23
  65. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +2 -1
  66. package/build/features/connect/screens/Merchant/SocialMedia.js +30 -3
  67. package/build/features/connect/screens/Merchant/validation.d.ts +6 -1
  68. package/build/features/connect/screens/Merchant/validation.js +67 -7
  69. package/build/features/connect/screens/Mobile/MobileNumber.js +1 -1
  70. package/build/features/featuresScreens.js +20 -10
  71. package/build/features/individual/Individual.d.ts +2 -1
  72. package/build/features/individual/Individual.js +17 -9
  73. package/build/features/individual/screens/Verify/OTPInput.d.ts +5 -0
  74. package/build/features/individual/screens/Verify/OTPInput.js +42 -0
  75. package/build/features/individual/screens/Verify/Verify.d.ts +5 -0
  76. package/build/features/individual/screens/Verify/Verify.js +78 -0
  77. package/build/features/individual/screens/Verify/index.d.ts +2 -0
  78. package/build/features/individual/screens/Verify/index.js +2 -0
  79. package/build/features/individual/screens/Verify/validation.d.ts +8 -0
  80. package/build/features/individual/screens/Verify/validation.js +4 -0
  81. package/build/features/password/Password.d.ts +2 -1
  82. package/build/features/password/Password.js +17 -9
  83. package/build/features/password/screens/Verify/OTPInput.d.ts +5 -0
  84. package/build/features/password/screens/Verify/OTPInput.js +42 -0
  85. package/build/features/password/screens/Verify/Verify.d.ts +5 -0
  86. package/build/features/password/screens/Verify/Verify.js +78 -0
  87. package/build/features/password/screens/Verify/index.d.ts +2 -0
  88. package/build/features/password/screens/Verify/index.js +2 -0
  89. package/build/features/password/screens/Verify/validation.d.ts +8 -0
  90. package/build/features/password/screens/Verify/validation.js +4 -0
  91. package/build/features/tax/Tax.d.ts +2 -1
  92. package/build/features/tax/Tax.js +17 -9
  93. package/build/features/tax/screens/Success/Success.js +6 -0
  94. package/build/features/tax/screens/TaxDetails/TaxDetails.js +6 -7
  95. package/build/features/tax/screens/Verify/OTPInput.d.ts +5 -0
  96. package/build/features/tax/screens/Verify/OTPInput.js +42 -0
  97. package/build/features/tax/screens/Verify/Verify.d.ts +5 -0
  98. package/build/features/tax/screens/Verify/Verify.js +78 -0
  99. package/build/features/tax/screens/Verify/index.d.ts +2 -0
  100. package/build/features/tax/screens/Verify/index.js +2 -0
  101. package/build/features/tax/screens/Verify/validation.d.ts +8 -0
  102. package/build/features/tax/screens/Verify/validation.js +4 -0
  103. package/build/hooks/useAppDispatch.d.ts +4 -0
  104. package/build/utils/string.js +0 -1
  105. package/package.json +1 -1
@@ -45,11 +45,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
+ if (ar || !(i in from)) {
51
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
+ ar[i] = from[i];
53
+ }
54
+ }
55
+ return to.concat(ar || Array.prototype.slice.call(from));
56
+ };
48
57
  var _a;
49
58
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
59
  import { handleNextScreenStep } from '../../../app/settings';
51
60
  import API from '../../../api';
52
- import { BRAND_LIST, CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, TWITTER_URL } from '../../../constants';
61
+ import { BRAND_LIST, CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, OTHER_BRAND, TWITTER_URL } from '../../../constants';
53
62
  import { defaultCountry } from '../../../constants';
54
63
  import { getIndividualName, getClientEmailUrl, capitalizeTheFirstLetterOfEachWord, removeRequestHeaders } from '../../../utils';
55
64
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
@@ -218,7 +227,7 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
218
227
  isAbsher = connect.data.otpData.isAbsher;
219
228
  payload = {
220
229
  name: getIndividualName(params.name),
221
- lead_id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
230
+ id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
222
231
  contact: {
223
232
  email: params.email,
224
233
  phone: isAbsher
@@ -268,7 +277,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
268
277
  website: (_f = params.links) === null || _f === void 0 ? void 0 : _f.website,
269
278
  social: [twitter, instagram]
270
279
  },
271
- lead_id: ((_g = connect.data.otpData.responseBody) === null || _g === void 0 ? void 0 : _g.lead_id) || '',
280
+ id: ((_g = connect.data.otpData.responseBody) === null || _g === void 0 ? void 0 : _g.lead_id) || '',
272
281
  terms_conditions_accepted: params.termAndConditionChecked,
273
282
  step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
274
283
  encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh', 'social[0]', 'social[1]']
@@ -284,25 +293,19 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
284
293
  }
285
294
  });
286
295
  }); });
287
- export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (_a, thunkApi) {
296
+ export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', function (_a) {
288
297
  var email = _a.email, cancelToken = _a.cancelToken, onSuccess = _a.onSuccess;
289
298
  return __awaiter(void 0, void 0, void 0, function () {
290
- var _b, settings, connect, headers, requestBody, data;
291
- var _c, _d, _e;
292
- return __generator(this, function (_f) {
293
- switch (_f.label) {
299
+ var requestBody, data;
300
+ return __generator(this, function (_b) {
301
+ switch (_b.label) {
294
302
  case 0:
295
- _b = thunkApi.getState(), settings = _b.settings, connect = _b.connect;
296
- headers = {
297
- lead_id: (_c = connect.data.otpData.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id,
298
- device_identifier: (_e = (_d = settings.data.deviceInfo) === null || _d === void 0 ? void 0 : _d.browser) === null || _e === void 0 ? void 0 : _e.browser_id
299
- };
300
303
  requestBody = {
301
304
  email: email
302
305
  };
303
- return [4, API.availabilityServices.checkEmail(requestBody, { headers: headers, cancelToken: cancelToken })];
306
+ return [4, API.availabilityServices.checkEmail(requestBody, { cancelToken: cancelToken })];
304
307
  case 1:
305
- data = (_f.sent()).data;
308
+ data = (_b.sent()).data;
306
309
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
307
310
  if (!data.errors)
308
311
  return [2, { response: data, formData: email }];
@@ -311,25 +314,19 @@ export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', f
311
314
  });
312
315
  });
313
316
  });
314
- export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (_a, thunkApi) {
317
+ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (_a) {
315
318
  var cancelToken = _a.cancelToken, name = _a.name, onSuccess = _a.onSuccess;
316
319
  return __awaiter(void 0, void 0, void 0, function () {
317
- var _b, settings, connect, headers, requestBody, data;
318
- var _c, _d, _e;
319
- return __generator(this, function (_f) {
320
- switch (_f.label) {
320
+ var requestBody, data;
321
+ return __generator(this, function (_b) {
322
+ switch (_b.label) {
321
323
  case 0:
322
- _b = thunkApi.getState(), settings = _b.settings, connect = _b.connect;
323
- headers = {
324
- lead_id: ((_c = connect.data.otpData.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id) || '',
325
- device_identifier: (_e = (_d = settings.data.deviceInfo) === null || _d === void 0 ? void 0 : _d.browser) === null || _e === void 0 ? void 0 : _e.browser_id
326
- };
327
324
  requestBody = {
328
325
  profile_name: name
329
326
  };
330
- return [4, API.availabilityServices.checkBrand(requestBody, { headers: headers, cancelToken: cancelToken })];
327
+ return [4, API.availabilityServices.checkBrand(requestBody, { cancelToken: cancelToken })];
331
328
  case 1:
332
- data = (_f.sent()).data;
329
+ data = (_b.sent()).data;
333
330
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
334
331
  if (!data.errors)
335
332
  return [2, { response: data, formData: { name: name } }];
@@ -348,7 +345,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
348
345
  payload = {
349
346
  step_name: CONNECT_STEP_NAMES.CONNECT_SUCCESS,
350
347
  email_url: getClientEmailUrl(),
351
- lead_id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
348
+ id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
352
349
  encryption_contract: []
353
350
  };
354
351
  return [4, API.leadService.updateLead(payload)];
@@ -392,6 +389,10 @@ var initialState = {
392
389
  website: '',
393
390
  twitter: '',
394
391
  instagram: ''
392
+ },
393
+ selectedBrandItem: {},
394
+ responseBody: {
395
+ brands: []
395
396
  }
396
397
  }
397
398
  }
@@ -537,8 +538,8 @@ export var connectSlice = createSlice({
537
538
  var response = action.payload.response;
538
539
  var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
539
540
  if (!!response && !description) {
540
- state.data.brandData.brandList = BRAND_LIST;
541
- state.data.otpData.responseBody = response;
541
+ state.data.brandData.selectedBrandItem = BRAND_LIST[0];
542
+ state.data.brandData.responseBody = __assign({ brands: __spreadArray(__spreadArray([], BRAND_LIST, true), [OTHER_BRAND], false) }, response);
542
543
  }
543
544
  })
544
545
  .addCase(createLead.pending, function (state) {
@@ -0,0 +1,36 @@
1
+ import { RootState } from '../../../app/store';
2
+ import { IndividualExtraFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
+ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
+ data: any;
5
+ leadData: any;
6
+ token: string;
7
+ }, string, {}>;
8
+ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
9
+ data: any;
10
+ formData: {
11
+ otp: string;
12
+ };
13
+ }, OTPFormValues, {}>;
14
+ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
15
+ response: any;
16
+ formData: void;
17
+ }, void, {}>;
18
+ declare type VerifyData = {
19
+ token: string;
20
+ };
21
+ export interface IndividualData {
22
+ verify: ResponseData & VerifyData;
23
+ otpData: OTPFormValues & ResponseData;
24
+ individualData: IndividualExtraFormValues & ResponseData;
25
+ }
26
+ export interface IndividualState extends SharedState<IndividualData> {
27
+ }
28
+ export declare const individualSlice: import("@reduxjs/toolkit").Slice<IndividualState, {
29
+ clearError: (state: IndividualState) => void;
30
+ stopLoader: (state: IndividualState) => void;
31
+ resetOTPScreen: (state: IndividualState) => void;
32
+ }, "individual/store">;
33
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
34
+ declare const _default: import("redux").Reducer<IndividualState, import("redux").AnyAction>;
35
+ export default _default;
36
+ export declare const individualSelector: (state: RootState) => IndividualState;
@@ -0,0 +1,222 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var _a;
49
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import API from '../../../api';
51
+ import { removeRequestHeaders } from '../../../utils';
52
+ import { handleNextScreenStep } from '../../../app/settings';
53
+ import { defaultCountry, INDIVIDUAl_STEP_NAMES, SOURCE_OF_INCOME } from '../../../constants';
54
+ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
+ var payload, data, leadResponse;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ payload = {
60
+ service_name: 'tap_email',
61
+ verify_token: token
62
+ };
63
+ return [4, API.leadService.verifyLeadToken(payload)];
64
+ case 1:
65
+ data = (_a.sent()).data;
66
+ leadResponse = undefined;
67
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
68
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
69
+ case 2:
70
+ leadResponse = _a.sent();
71
+ if (data.step_name === INDIVIDUAl_STEP_NAMES.IDENTITY_AUTH) {
72
+ thunkApi.dispatch(handleNextScreenStep());
73
+ }
74
+ _a.label = 3;
75
+ case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
76
+ }
77
+ });
78
+ }); });
79
+ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
80
+ var _a, individual, settings, responseBody, payload, data;
81
+ var _b, _c, _d;
82
+ return __generator(this, function (_e) {
83
+ switch (_e.label) {
84
+ case 0:
85
+ _a = thunkApi.getState(), individual = _a.individual, settings = _a.settings;
86
+ responseBody = individual.data.verify.responseBody;
87
+ payload = {
88
+ data: params.otp,
89
+ service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
90
+ verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
91
+ step_name: INDIVIDUAl_STEP_NAMES.PHONE_AUTH,
92
+ encryption_contract: ['data']
93
+ };
94
+ return [4, API.leadService.verifyLeadOTP(payload)];
95
+ case 1:
96
+ data = (_e.sent()).data;
97
+ if (!data.errors) {
98
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
99
+ thunkApi.dispatch(handleNextScreenStep());
100
+ }
101
+ return [2, { data: data, formData: __assign({}, params) }];
102
+ }
103
+ });
104
+ }); });
105
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
106
+ var _a, settings, individual, payload, data;
107
+ var _b, _c, _d, _e, _f;
108
+ return __generator(this, function (_g) {
109
+ switch (_g.label) {
110
+ case 0:
111
+ _a = thunkApi.getState(), settings = _a.settings, individual = _a.individual;
112
+ payload = {
113
+ step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_SUCCESS,
114
+ id: ((_b = individual.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
115
+ encryption_contract: []
116
+ };
117
+ return [4, API.leadService.updateLead(payload)];
118
+ case 1:
119
+ data = (_g.sent()).data;
120
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
121
+ (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
122
+ return [2, { response: data, formData: params }];
123
+ }
124
+ });
125
+ }); });
126
+ var initialState = {
127
+ error: null,
128
+ loading: false,
129
+ data: {
130
+ verify: {
131
+ token: ''
132
+ },
133
+ otpData: {
134
+ otp: ''
135
+ },
136
+ individualData: {
137
+ sourceIncome: SOURCE_OF_INCOME[0],
138
+ monthlyIncome: '',
139
+ employerName: '',
140
+ employerLocation: defaultCountry,
141
+ isPEP: null,
142
+ isInfluencer: null
143
+ }
144
+ }
145
+ };
146
+ export var individualSlice = createSlice({
147
+ name: 'individual/store',
148
+ initialState: initialState,
149
+ reducers: {
150
+ clearError: function (state) {
151
+ state.error = null;
152
+ },
153
+ stopLoader: function (state) {
154
+ state.loading = false;
155
+ },
156
+ resetOTPScreen: function (state) {
157
+ state.data.otpData.otp = '';
158
+ }
159
+ },
160
+ extraReducers: function (builder) {
161
+ builder
162
+ .addCase(verifyLeadToken.fulfilled, function (state, action) {
163
+ var _a;
164
+ state.error = null;
165
+ var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
166
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
167
+ if (description) {
168
+ state.error = description;
169
+ return;
170
+ }
171
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
172
+ state.data.verify.token = token;
173
+ })
174
+ .addCase(verifyLeadToken.rejected, function (state, action) {
175
+ state.error = action.error.message;
176
+ })
177
+ .addCase(verifyLeadOTP.pending, function (state) {
178
+ state.loading = true;
179
+ state.error = null;
180
+ })
181
+ .addCase(verifyLeadOTP.fulfilled, function (state, action) {
182
+ var _a;
183
+ state.loading = false;
184
+ state.error = null;
185
+ var _b = action.payload, data = _b.data, formData = _b.formData;
186
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
187
+ if (description) {
188
+ state.error = description;
189
+ return;
190
+ }
191
+ state.data.otpData = formData;
192
+ state.data.otpData.responseBody = data;
193
+ })
194
+ .addCase(verifyLeadOTP.rejected, function (state, action) {
195
+ state.loading = false;
196
+ state.error = action.error.message;
197
+ })
198
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
199
+ var _a;
200
+ state.loading = false;
201
+ state.error = null;
202
+ var response = action.payload.response;
203
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
204
+ if (description) {
205
+ state.error = description;
206
+ return;
207
+ }
208
+ removeRequestHeaders();
209
+ })
210
+ .addCase(updateLeadSuccess.pending, function (state) {
211
+ state.loading = true;
212
+ state.error = null;
213
+ })
214
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
215
+ state.loading = false;
216
+ state.error = action.error.message;
217
+ });
218
+ }
219
+ });
220
+ export var clearError = (_a = individualSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen;
221
+ export default individualSlice.reducer;
222
+ export var individualSelector = function (state) { return state.individual; };
@@ -0,0 +1,36 @@
1
+ import { RootState } from '../../../app/store';
2
+ import { OTPFormValues, PasswordCreateFormValues, ResponseData, SharedState } from '../../../@types';
3
+ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
+ data: any;
5
+ leadData: any;
6
+ token: string;
7
+ }, string, {}>;
8
+ export declare const verifyPasswordLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
9
+ data: any;
10
+ formData: {
11
+ otp: string;
12
+ };
13
+ }, OTPFormValues, {}>;
14
+ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
15
+ response: any;
16
+ formData: void;
17
+ }, void, {}>;
18
+ declare type VerifyData = {
19
+ token: string;
20
+ };
21
+ export interface PasswordData {
22
+ verify: ResponseData & VerifyData;
23
+ otpData: OTPFormValues & ResponseData;
24
+ passwordData: PasswordCreateFormValues & ResponseData;
25
+ }
26
+ export interface PasswordState extends SharedState<PasswordData> {
27
+ }
28
+ export declare const passwordSlice: import("@reduxjs/toolkit").Slice<PasswordState, {
29
+ clearError: (state: PasswordState) => void;
30
+ stopLoader: (state: PasswordState) => void;
31
+ resetOTPScreen: (state: PasswordState) => void;
32
+ }, "password/store">;
33
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
34
+ declare const _default: import("redux").Reducer<PasswordState, import("redux").AnyAction>;
35
+ export default _default;
36
+ export declare const passwordSelector: (state: RootState) => PasswordState;
@@ -0,0 +1,218 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var _a;
49
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import API from '../../../api';
51
+ import { removeRequestHeaders } from '../../../utils';
52
+ import { handleNextScreenStep } from '../../../app/settings';
53
+ import { PASSWORD_STEP_NAMES } from '../../../constants';
54
+ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
+ var payload, data, leadResponse;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ payload = {
60
+ service_name: 'tap_email',
61
+ verify_token: token
62
+ };
63
+ return [4, API.leadService.verifyLeadToken(payload)];
64
+ case 1:
65
+ data = (_a.sent()).data;
66
+ leadResponse = undefined;
67
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
68
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
69
+ case 2:
70
+ leadResponse = _a.sent();
71
+ if (data.step_name === PASSWORD_STEP_NAMES.IDENTITY_AUTH) {
72
+ thunkApi.dispatch(handleNextScreenStep());
73
+ }
74
+ _a.label = 3;
75
+ case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
76
+ }
77
+ });
78
+ }); });
79
+ export var verifyPasswordLeadOTP = createAsyncThunk('verifyPasswordLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
80
+ var _a, password, settings, responseBody, payload, data;
81
+ var _b, _c, _d;
82
+ return __generator(this, function (_e) {
83
+ switch (_e.label) {
84
+ case 0:
85
+ _a = thunkApi.getState(), password = _a.password, settings = _a.settings;
86
+ responseBody = password.data.verify.responseBody;
87
+ payload = {
88
+ data: params.otp,
89
+ service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
90
+ verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
91
+ step_name: PASSWORD_STEP_NAMES.PHONE_AUTH,
92
+ encryption_contract: ['data']
93
+ };
94
+ return [4, API.leadService.verifyLeadOTP(payload)];
95
+ case 1:
96
+ data = (_e.sent()).data;
97
+ if (!data.errors) {
98
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
99
+ thunkApi.dispatch(handleNextScreenStep());
100
+ }
101
+ return [2, { data: data, formData: __assign({}, params) }];
102
+ }
103
+ });
104
+ }); });
105
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
106
+ var _a, settings, password, payload, data;
107
+ var _b, _c, _d, _e, _f;
108
+ return __generator(this, function (_g) {
109
+ switch (_g.label) {
110
+ case 0:
111
+ _a = thunkApi.getState(), settings = _a.settings, password = _a.password;
112
+ payload = {
113
+ step_name: PASSWORD_STEP_NAMES.PASSWORD_SUCCESS,
114
+ id: ((_b = password.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
115
+ encryption_contract: []
116
+ };
117
+ return [4, API.leadService.updateLead(payload)];
118
+ case 1:
119
+ data = (_g.sent()).data;
120
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
121
+ (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
122
+ return [2, { response: data, formData: params }];
123
+ }
124
+ });
125
+ }); });
126
+ var initialState = {
127
+ error: null,
128
+ loading: false,
129
+ data: {
130
+ verify: {
131
+ token: ''
132
+ },
133
+ otpData: {
134
+ otp: ''
135
+ },
136
+ passwordData: {
137
+ password: '',
138
+ confirmPassword: ''
139
+ }
140
+ }
141
+ };
142
+ export var passwordSlice = createSlice({
143
+ name: 'password/store',
144
+ initialState: initialState,
145
+ reducers: {
146
+ clearError: function (state) {
147
+ state.error = null;
148
+ },
149
+ stopLoader: function (state) {
150
+ state.loading = false;
151
+ },
152
+ resetOTPScreen: function (state) {
153
+ state.data.otpData.otp = '';
154
+ }
155
+ },
156
+ extraReducers: function (builder) {
157
+ builder
158
+ .addCase(verifyLeadToken.fulfilled, function (state, action) {
159
+ var _a;
160
+ state.error = null;
161
+ var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
162
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
163
+ if (description) {
164
+ state.error = description;
165
+ return;
166
+ }
167
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
168
+ state.data.verify.token = token;
169
+ })
170
+ .addCase(verifyLeadToken.rejected, function (state, action) {
171
+ state.error = action.error.message;
172
+ })
173
+ .addCase(verifyPasswordLeadOTP.pending, function (state) {
174
+ state.loading = true;
175
+ state.error = null;
176
+ })
177
+ .addCase(verifyPasswordLeadOTP.fulfilled, function (state, action) {
178
+ var _a;
179
+ state.loading = false;
180
+ state.error = null;
181
+ var _b = action.payload, data = _b.data, formData = _b.formData;
182
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
183
+ if (description) {
184
+ state.error = description;
185
+ return;
186
+ }
187
+ state.data.otpData = formData;
188
+ state.data.otpData.responseBody = data;
189
+ })
190
+ .addCase(verifyPasswordLeadOTP.rejected, function (state, action) {
191
+ state.loading = false;
192
+ state.error = action.error.message;
193
+ })
194
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
195
+ var _a;
196
+ state.loading = false;
197
+ state.error = null;
198
+ var response = action.payload.response;
199
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
200
+ if (description) {
201
+ state.error = description;
202
+ return;
203
+ }
204
+ removeRequestHeaders();
205
+ })
206
+ .addCase(updateLeadSuccess.pending, function (state) {
207
+ state.loading = true;
208
+ state.error = null;
209
+ })
210
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
211
+ state.loading = false;
212
+ state.error = action.error.message;
213
+ });
214
+ }
215
+ });
216
+ export var clearError = (_a = passwordSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen;
217
+ export default passwordSlice.reducer;
218
+ export var passwordSelector = function (state) { return state.password; };