@tap-payments/auth-jsconnect 2.0.10 → 2.0.11

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 (45) hide show
  1. package/build/api/account.d.ts +1 -2
  2. package/build/api/account.js +7 -3
  3. package/build/api/board.d.ts +25 -0
  4. package/build/api/board.js +49 -0
  5. package/build/api/brand.d.ts +7 -0
  6. package/build/api/brand.js +40 -0
  7. package/build/api/entity.d.ts +0 -1
  8. package/build/api/entity.js +3 -10
  9. package/build/api/index.d.ts +19 -6
  10. package/build/api/index.js +7 -1
  11. package/build/api/individual.d.ts +25 -2
  12. package/build/api/individual.js +1 -5
  13. package/build/api/lead.d.ts +1 -5
  14. package/build/api/lead.js +10 -5
  15. package/build/api/user.d.ts +8 -0
  16. package/build/api/user.js +12 -0
  17. package/build/components/AnimationFlow/Loader.js +17 -9
  18. package/build/constants/api.d.ts +4 -1
  19. package/build/constants/api.js +14 -8
  20. package/build/constants/app.d.ts +1 -1
  21. package/build/constants/app.js +1 -1
  22. package/build/constants/validation.js +1 -1
  23. package/build/features/app/bank/bankStore.d.ts +2 -2
  24. package/build/features/app/bank/bankStore.js +45 -36
  25. package/build/features/app/business/businessStore.d.ts +2 -1
  26. package/build/features/app/business/businessStore.js +189 -123
  27. package/build/features/app/connect/connectStore.js +17 -26
  28. package/build/features/app/individual/individualStore.d.ts +2 -10
  29. package/build/features/app/individual/individualStore.js +69 -93
  30. package/build/features/app/password/passwordStore.d.ts +6 -5
  31. package/build/features/app/password/passwordStore.js +70 -54
  32. package/build/features/app/tax/taxStore.d.ts +1 -1
  33. package/build/features/app/tax/taxStore.js +44 -39
  34. package/build/features/bank/screens/Success/Success.js +2 -2
  35. package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
  36. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  37. package/build/features/connect/screens/Merchant/BrandName.js +2 -6
  38. package/build/features/individual/screens/Success/Success.js +2 -2
  39. package/build/features/password/Password.js +2 -2
  40. package/build/features/password/screens/Success/Success.js +2 -2
  41. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +1 -1
  42. package/build/index.css +140 -139
  43. package/build/utils/string.d.ts +2 -1
  44. package/build/utils/string.js +7 -2
  45. package/package.json +128 -128
@@ -60,12 +60,13 @@ import moment from 'moment';
60
60
  import API from '../../../api';
61
61
  import { BusinessType, FlowsTypes } from '../../../@types';
62
62
  import { BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
63
- import { convertNumbers2English, getFlowUrl, hasKey } from '../../../utils';
63
+ import { convertNumbers2English, getEighteenYearsAgo, hasKey } from '../../../utils';
64
64
  import { handleNextScreenStep } from '../../../app/settings';
65
65
  export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
- var payload, data, leadResponse;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
66
+ var payload, data, leadResponse, brandInfo, boardResponse, board_id, board_info_id, steps, entityID, brandID, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted;
67
+ var _a, _b, _c, _d, _e, _f, _g;
68
+ return __generator(this, function (_h) {
69
+ switch (_h.label) {
69
70
  case 0:
70
71
  payload = {
71
72
  service_name: 'tap_email',
@@ -73,20 +74,76 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
73
74
  };
74
75
  return [4, API.leadService.verifyLeadToken(payload)];
75
76
  case 1:
76
- data = (_a.sent()).data;
77
+ data = (_h.sent()).data;
77
78
  leadResponse = undefined;
78
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
79
+ brandInfo = undefined;
80
+ boardResponse = undefined;
81
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 17];
79
82
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
80
83
  case 2:
81
- leadResponse = _a.sent();
84
+ leadResponse = _h.sent();
85
+ board_id = (_a = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _a === void 0 ? void 0 : _a.board_id;
86
+ board_info_id = (_b = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _b === void 0 ? void 0 : _b.board_info_id;
87
+ if (!(!!board_id && !!board_info_id)) return [3, 4];
88
+ return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
89
+ case 3:
90
+ boardResponse = _h.sent();
91
+ _h.label = 4;
92
+ case 4:
82
93
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
83
94
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
84
95
  }
85
- if (data.step_name === 'business_info') {
86
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
87
- }
88
- _a.label = 3;
89
- case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
96
+ if (!(data.step_name === 'business_info')) return [3, 17];
97
+ steps = (_c = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _c === void 0 ? void 0 : _c.steps;
98
+ entityID = (_e = (_d = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _d === void 0 ? void 0 : _d.entity) === null || _e === void 0 ? void 0 : _e.id;
99
+ brandID = (_g = (_f = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _f === void 0 ? void 0 : _f.brand) === null || _g === void 0 ? void 0 : _g.id;
100
+ hasBusinessCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_SUCCESS);
101
+ hasBusinessCRInfoCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_INFO);
102
+ hasBusinessCRActivitiesCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES);
103
+ hasBusinessCustomersCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS);
104
+ if (!hasBusinessCompleted) return [3, 6];
105
+ return [4, thunkApi.dispatch(retrieveEntityInfo(entityID))];
106
+ case 5:
107
+ _h.sent();
108
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
109
+ return [3, 17];
110
+ case 6:
111
+ if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 7];
112
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
113
+ return [3, 17];
114
+ case 7:
115
+ if (!hasBusinessCustomersCompleted) return [3, 8];
116
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_STEP'));
117
+ return [3, 17];
118
+ case 8:
119
+ if (!hasBusinessCRActivitiesCompleted) return [3, 12];
120
+ return [4, thunkApi.dispatch(retrieveChannels())];
121
+ case 9:
122
+ _h.sent();
123
+ return [4, thunkApi.dispatch(retrieveDataList())];
124
+ case 10:
125
+ _h.sent();
126
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_CUSTOMERS_STEP'));
127
+ return [4, API.brandService.retrieveBrand(brandID)];
128
+ case 11:
129
+ brandInfo = _h.sent();
130
+ return [3, 17];
131
+ case 12:
132
+ if (!hasBusinessCRInfoCompleted) return [3, 15];
133
+ return [4, thunkApi.dispatch(retrieveChannels())];
134
+ case 13:
135
+ _h.sent();
136
+ return [4, API.brandService.retrieveBrand(brandID)];
137
+ case 14:
138
+ brandInfo = _h.sent();
139
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_ACTIVITIES_STEP'));
140
+ return [3, 17];
141
+ case 15: return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id }))];
142
+ case 16:
143
+ _h.sent();
144
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
145
+ _h.label = 17;
146
+ case 17: return [2, { data: data, leadData: __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info }), token: token, brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand }];
90
147
  }
91
148
  });
92
149
  }); });
@@ -108,7 +165,7 @@ export var resendOTP = createAsyncThunk('resendOTPBusiness', function (params, t
108
165
  });
109
166
  }); });
110
167
  export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
111
- var _a, business, settings, isNID, responseBody, verifyResponse, stepName, entityID, payload, data, steps, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted, entityInfo;
168
+ var _a, business, settings, isNID, responseBody, verifyResponse, stepName, brandID, payload, data, brandInfo, steps, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted;
112
169
  var _b, _c, _d, _e, _f, _g;
113
170
  return __generator(this, function (_h) {
114
171
  switch (_h.label) {
@@ -118,7 +175,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
118
175
  responseBody = (isNID ? business.data.nidData : business.data.verify).responseBody;
119
176
  verifyResponse = business.data.verify.responseBody;
120
177
  stepName = isNID ? BUSINESS_STEP_NAMES.IDENTITY_VERIFY_AUTH : BUSINESS_STEP_NAMES.PHONE_AUTH;
121
- entityID = (_c = (_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id;
178
+ brandID = (_c = (_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
122
179
  payload = {
123
180
  data: params.otp,
124
181
  service_name: (_d = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _d === void 0 ? void 0 : _d.service_name,
@@ -129,7 +186,8 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
129
186
  return [4, API.leadService.verifyLeadOTP(payload)];
130
187
  case 1:
131
188
  data = (_h.sent()).data;
132
- if (!!data.errors) return [3, 11];
189
+ brandInfo = undefined;
190
+ if (!!data.errors) return [3, 13];
133
191
  thunkApi.dispatch(updateStepName(stepName));
134
192
  return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id }))];
135
193
  case 2:
@@ -142,42 +200,45 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
142
200
  hasBusinessCustomersCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS);
143
201
  if (!isNID) return [3, 3];
144
202
  thunkApi.dispatch(handleNextScreenStep());
145
- return [3, 11];
203
+ return [3, 13];
146
204
  case 3:
147
205
  if (!hasBusinessCompleted) return [3, 5];
148
206
  return [4, thunkApi.dispatch(retrieveEntityInfo((_g = verifyResponse === null || verifyResponse === void 0 ? void 0 : verifyResponse.entity) === null || _g === void 0 ? void 0 : _g.id))];
149
207
  case 4:
150
208
  _h.sent();
151
209
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
152
- return [3, 11];
210
+ return [3, 13];
153
211
  case 5:
154
212
  if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 6];
155
213
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
156
- return [3, 11];
214
+ return [3, 13];
157
215
  case 6:
158
216
  if (!hasBusinessCustomersCompleted) return [3, 7];
159
217
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_STEP'));
160
- return [3, 11];
218
+ return [3, 13];
161
219
  case 7:
162
- if (!hasBusinessCRActivitiesCompleted) return [3, 8];
220
+ if (!hasBusinessCRActivitiesCompleted) return [3, 9];
163
221
  thunkApi.dispatch(retrieveChannels());
164
222
  thunkApi.dispatch(retrieveDataList());
165
223
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_CUSTOMERS_STEP'));
166
- return [3, 11];
224
+ return [4, API.brandService.retrieveBrand(brandID)];
167
225
  case 8:
168
- if (!hasBusinessCRInfoCompleted) return [3, 10];
169
- return [4, thunkApi.dispatch(retrieveChannels())];
226
+ brandInfo = _h.sent();
227
+ return [3, 13];
170
228
  case 9:
229
+ if (!hasBusinessCRInfoCompleted) return [3, 12];
230
+ return [4, thunkApi.dispatch(retrieveChannels())];
231
+ case 10:
171
232
  _h.sent();
233
+ return [4, API.brandService.retrieveBrand(brandID)];
234
+ case 11:
235
+ brandInfo = _h.sent();
172
236
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_ACTIVITIES_STEP'));
173
- return [3, 11];
174
- case 10:
175
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
176
- _h.label = 11;
177
- case 11: return [4, API.entityService.retrieveBusinessInfo(entityID)];
237
+ return [3, 13];
178
238
  case 12:
179
- entityInfo = _h.sent();
180
- return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }), entityInfo: entityInfo }];
239
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
240
+ _h.label = 13;
241
+ case 13: return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }), brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand }];
181
242
  }
182
243
  });
183
244
  }); });
@@ -289,14 +350,12 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
289
350
  };
290
351
  return [4, API.leadService.updateLead(payload)];
291
352
  case 1:
292
- data = (_g.sent()).data;
293
- if (!!data.errors) return [3, 3];
353
+ data = _g.sent();
294
354
  return [4, thunkApi.dispatch(createAccount())];
295
355
  case 2:
296
356
  _g.sent();
297
357
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
298
- _g.label = 3;
299
- case 3: return [2, { data: data, formData: params }];
358
+ return [2, { data: data, formData: params }];
300
359
  }
301
360
  });
302
361
  }); });
@@ -319,7 +378,7 @@ export var createAccount = createAsyncThunk('createAccount', function (params, t
319
378
  };
320
379
  return [4, API.accountService.createAccount(requestBody)];
321
380
  case 1:
322
- data = (_e.sent()).data;
381
+ data = _e.sent();
323
382
  if (!!data.errors) return [3, 3];
324
383
  return [4, thunkApi.dispatch(retrieveChannels())];
325
384
  case 2:
@@ -333,9 +392,9 @@ export var createAccount = createAsyncThunk('createAccount', function (params, t
333
392
  }); });
334
393
  export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
335
394
  var _a, settings, business, channel, activities, stepName, id, requestBody, data;
336
- var _b, _c, _d, _e;
337
- return __generator(this, function (_f) {
338
- switch (_f.label) {
395
+ var _b, _c, _d, _e, _f;
396
+ return __generator(this, function (_g) {
397
+ switch (_g.label) {
339
398
  case 0:
340
399
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
341
400
  channel = params.salesChannels.map(function (_a) {
@@ -347,25 +406,25 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
347
406
  return en;
348
407
  });
349
408
  stepName = BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES;
350
- id = (_c = business.data.businessTypeData.responseBody) === null || _c === void 0 ? void 0 : _c.entity_id;
409
+ id = (_d = (_c = business.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.brand) === null || _d === void 0 ? void 0 : _d.id;
351
410
  requestBody = {
352
411
  id: id,
353
- activities: activities,
354
- channel_services: channel,
355
- business_operation_start_at: params.operationStartDate,
412
+ brand: {
413
+ activities: activities,
414
+ channel_services: channel,
415
+ business_operation_start_at: params.operationStartDate
416
+ },
356
417
  step_name: stepName,
357
- encryption_contract: ['business_operation_start_at']
418
+ encryption_contract: ['brand.business_operation_start_at']
358
419
  };
359
- return [4, API.entityService.createEntityInfo(requestBody)];
420
+ return [4, API.brandService.updateBrandInfo(requestBody)];
360
421
  case 1:
361
- data = (_f.sent()).data;
422
+ data = _g.sent();
362
423
  thunkApi.dispatch(retrieveDataList());
363
- if (!data.errors) {
364
- thunkApi.dispatch(updateStepName(stepName));
365
- thunkApi.dispatch(handleNextScreenStep());
366
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, requestBody);
367
- }
368
- return [2, { data: data, formData: __assign({}, params) }];
424
+ thunkApi.dispatch(updateStepName(stepName));
425
+ thunkApi.dispatch(handleNextScreenStep());
426
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
427
+ return [2, { data: data === null || data === void 0 ? void 0 : data.brand, formData: __assign({}, params) }];
369
428
  }
370
429
  });
371
430
  }); });
@@ -390,41 +449,41 @@ export var retrieveDataList = createAsyncThunk('bankRetrieveDataList', function
390
449
  }); });
391
450
  export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
392
451
  var _a, settings, business, id, customerBase, stepName, requestBody, data;
393
- var _b, _c, _d, _e, _f;
394
- return __generator(this, function (_g) {
395
- switch (_g.label) {
452
+ var _b, _c, _d, _e, _f, _g;
453
+ return __generator(this, function (_h) {
454
+ switch (_h.label) {
396
455
  case 0:
397
456
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
398
- id = (_b = business.data.businessTypeData.responseBody) === null || _b === void 0 ? void 0 : _b.entity_id;
457
+ id = (_c = (_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.id;
399
458
  customerBase = params.customerLocations.map(function (_a) {
400
459
  var id = _a.id;
401
460
  return id;
402
461
  });
403
462
  stepName = BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS;
404
463
  requestBody = {
405
- customers_base: customerBase,
464
+ brand: {
465
+ customers_base: customerBase,
466
+ customers_served_monthly: parseInt(((_d = params.expectedCustomer) === null || _d === void 0 ? void 0 : _d.id) || '0'),
467
+ monthly_sales_range: ((_e = params.expectedSale) === null || _e === void 0 ? void 0 : _e.id) || '',
468
+ agree_refund: params.refundPolicy,
469
+ agree_chargeback: params.transactionPolicy
470
+ },
406
471
  id: id,
407
- customers_served_monthly: parseInt(((_c = params.expectedCustomer) === null || _c === void 0 ? void 0 : _c.id) || '0'),
408
- monthly_sales_range: ((_d = params.expectedSale) === null || _d === void 0 ? void 0 : _d.id) || '',
409
- agree_refund: params.refundPolicy,
410
- agree_chargeback: params.transactionPolicy,
411
472
  step_name: stepName,
412
- encryption_contract: ['customers_served_monthly', 'monthly_sales_range']
473
+ encryption_contract: ['brand.customers_served_monthly', 'brand.monthly_sales_range']
413
474
  };
414
- return [4, API.entityService.updateEntityInfo(requestBody)];
475
+ return [4, API.brandService.updateBrandInfo(requestBody)];
415
476
  case 1:
416
- data = (_g.sent()).data;
417
- if (!data.errors) {
418
- thunkApi.dispatch(updateStepName(stepName));
419
- thunkApi.dispatch(handleNextScreenStep());
420
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
421
- }
422
- return [2, { data: data, formData: params }];
477
+ data = _h.sent();
478
+ thunkApi.dispatch(updateStepName(stepName));
479
+ thunkApi.dispatch(handleNextScreenStep());
480
+ (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, requestBody);
481
+ return [2, { data: data === null || data === void 0 ? void 0 : data.brand, formData: params }];
423
482
  }
424
483
  });
425
484
  }); });
426
485
  export var updateLeadSuccess = createAsyncThunk('businessUpdateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
427
- var _a, settings, business, _b, steps, id, flowCompleted, payload, data;
486
+ var _a, settings, business, _b, steps, id, flowCompleted, boardResponse, payload, data, board_id, board_info_id;
428
487
  var _c, _d, _e, _f, _g;
429
488
  return __generator(this, function (_h) {
430
489
  switch (_h.label) {
@@ -434,42 +493,31 @@ export var updateLeadSuccess = createAsyncThunk('businessUpdateLeadSuccess', fun
434
493
  flowCompleted = Object.keys(steps).find(function (key) { return key === BUSINESS_STEP_NAMES.BUSINESS_SUCCESS; });
435
494
  if (flowCompleted || !id)
436
495
  return [2];
496
+ boardResponse = undefined;
437
497
  payload = {
438
498
  lang: settings.data.language,
439
499
  step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
440
500
  id: id,
441
- flows: [
442
- {
443
- name: 'tax',
444
- url: getFlowUrl('/tax', settings.data.language)
445
- },
446
- {
447
- name: 'bank',
448
- url: getFlowUrl('/bank', settings.data.language)
449
- },
450
- {
451
- name: 'individual',
452
- url: getFlowUrl('/individual', settings.data.language)
453
- },
454
- {
455
- name: 'password',
456
- url: getFlowUrl('/password', settings.data.language)
457
- }
458
- ],
459
501
  encryption_contract: []
460
502
  };
461
503
  return [4, API.leadService.updateLead(payload)];
462
504
  case 1:
463
- data = (_h.sent()).data;
464
- if (!!data.errors) return [3, 3];
505
+ data = _h.sent();
506
+ board_id = data === null || data === void 0 ? void 0 : data.board_id;
507
+ board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
508
+ if (!(!!board_id && !!board_info_id)) return [3, 3];
509
+ return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
510
+ case 2:
511
+ boardResponse = _h.sent();
512
+ _h.label = 3;
513
+ case 3:
465
514
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
466
515
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
467
516
  return [4, thunkApi.dispatch(retrieveEntityInfo((_g = data.entity) === null || _g === void 0 ? void 0 : _g.id))];
468
- case 2:
517
+ case 4:
469
518
  _h.sent();
470
519
  thunkApi.dispatch(handleNextScreenStep());
471
- _h.label = 3;
472
- case 3: return [2, { response: data, formData: params }];
520
+ return [2, { response: __assign(__assign({}, data), { flows: boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info }), formData: params }];
473
521
  }
474
522
  });
475
523
  }); });
@@ -487,7 +535,7 @@ export var updateStepName = createAsyncThunk('updateStepName', function (stepNam
487
535
  };
488
536
  return [4, API.leadService.updateLead(payload)];
489
537
  case 1:
490
- data = (_b.sent()).data;
538
+ data = _b.sent();
491
539
  return [2, { response: data }];
492
540
  }
493
541
  });
@@ -507,7 +555,7 @@ var initialState = {
507
555
  },
508
556
  nidData: {
509
557
  nid: '',
510
- dob: '1998-08-22',
558
+ dob: getEighteenYearsAgo(),
511
559
  type: ''
512
560
  },
513
561
  businessTypeData: {
@@ -548,10 +596,10 @@ export var businessSlice = createSlice({
548
596
  state.customLoading = true;
549
597
  })
550
598
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
551
- var _a;
599
+ var _a, _b, _c, _d;
552
600
  state.error = null;
553
601
  state.customLoading = false;
554
- var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
602
+ var _e = action.payload, data = _e.data, token = _e.token, leadData = _e.leadData, brandInfo = _e.brandInfo;
555
603
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
556
604
  if (description) {
557
605
  state.error = description;
@@ -560,6 +608,34 @@ export var businessSlice = createSlice({
560
608
  state.data.verify.responseBody = __assign(__assign({}, data), leadData);
561
609
  state.data.verify.token = token;
562
610
  state.data.otpData.isNID = false;
611
+ var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type;
612
+ var issuingDate = (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at)
613
+ ? brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at
614
+ : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
615
+ if (!!issuingDate) {
616
+ var formattedDate = moment(issuingDate).format('YYYY-MM-DD');
617
+ state.data.activitiesData.operationStartDate = convertNumbers2English(formattedDate);
618
+ }
619
+ var channels = (_c = state.data.businessTypeData.responseBody) === null || _c === void 0 ? void 0 : _c.channelList;
620
+ var selectedChannels = channels === null || channels === void 0 ? void 0 : channels.filter(function (channel) {
621
+ var _a;
622
+ return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.channel_services) === null || _a === void 0 ? void 0 : _a.find(function (storedChannel) { return channel.name_en.toLowerCase() === storedChannel.toLowerCase(); });
623
+ });
624
+ state.data.activitiesData.salesChannels = (selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) > 0 ? selectedChannels : [channels === null || channels === void 0 ? void 0 : channels[0]];
625
+ var activities = entity_activities || [];
626
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
627
+ var _a;
628
+ return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { var _a; return ((_a = activity.en) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === value.toLowerCase(); });
629
+ });
630
+ state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
631
+ state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
632
+ if (!!(entity === null || entity === void 0 ? void 0 : entity.license)) {
633
+ state.data.businessTypeData.selectedLicense = {
634
+ legal_name: entity === null || entity === void 0 ? void 0 : entity.legal_name,
635
+ license: { number: (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.number },
636
+ type: business_type
637
+ };
638
+ }
563
639
  })
564
640
  .addCase(verifyLeadToken.rejected, function (state, action) {
565
641
  state.error = action.error.message;
@@ -590,7 +666,7 @@ export var businessSlice = createSlice({
590
666
  var _a, _b, _c, _d;
591
667
  state.loading = false;
592
668
  state.error = null;
593
- var _e = action.payload, data = _e.data, formData = _e.formData, entityInfo = _e.entityInfo;
669
+ var _e = action.payload, data = _e.data, formData = _e.formData, brandInfo = _e.brandInfo;
594
670
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
595
671
  if (description) {
596
672
  state.error = description;
@@ -599,23 +675,25 @@ export var businessSlice = createSlice({
599
675
  state.data.otpData = formData;
600
676
  state.data.otpData.responseBody = data;
601
677
  var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type;
602
- var issuingDate = entityInfo ? entityInfo.business_operation_start_at : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
678
+ var issuingDate = (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at)
679
+ ? brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at
680
+ : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
603
681
  if (!!issuingDate) {
604
682
  var formattedDate = moment(issuingDate).format('YYYY-MM-DD');
605
683
  state.data.activitiesData.operationStartDate = convertNumbers2English(formattedDate);
606
684
  }
607
685
  var channels = (_c = state.data.businessTypeData.responseBody) === null || _c === void 0 ? void 0 : _c.channelList;
608
- var selectedChannels = (channels === null || channels === void 0 ? void 0 : channels.filter(function (channel) {
609
- return entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.channel_services.find(function (storedChannel) { return channel.name_en.toLowerCase() === storedChannel.toLowerCase(); });
610
- })) || [channels === null || channels === void 0 ? void 0 : channels[0]];
611
- if ((selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) > 0)
612
- state.data.activitiesData.salesChannels = selectedChannels;
686
+ var selectedChannels = channels === null || channels === void 0 ? void 0 : channels.filter(function (channel) {
687
+ var _a;
688
+ return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.channel_services) === null || _a === void 0 ? void 0 : _a.find(function (storedChannel) { return channel.name_en.toLowerCase() === storedChannel.toLowerCase(); });
689
+ });
690
+ state.data.activitiesData.salesChannels = (selectedChannels === null || selectedChannels === void 0 ? void 0 : selectedChannels.length) > 0 ? selectedChannels : [channels === null || channels === void 0 ? void 0 : channels[0]];
613
691
  var activities = entity_activities || [];
614
- var selectedActivity = (activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
615
- return entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.activities.find(function (value) { var _a; return ((_a = activity.en) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === value.toLowerCase(); });
616
- })) || [activities === null || activities === void 0 ? void 0 : activities[0]];
617
- if ((selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0)
618
- state.data.activitiesData.activities = selectedActivity;
692
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
693
+ var _a;
694
+ return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { var _a; return ((_a = activity.en) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === value.toLowerCase(); });
695
+ });
696
+ state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
619
697
  state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
620
698
  if (!!(entity === null || entity === void 0 ? void 0 : entity.license)) {
621
699
  state.data.businessTypeData.selectedLicense = {
@@ -817,15 +895,9 @@ export var businessSlice = createSlice({
817
895
  state.error = null;
818
896
  })
819
897
  .addCase(updateActivitiesInfo.fulfilled, function (state, action) {
820
- var _a;
821
898
  state.loading = false;
822
899
  state.error = null;
823
- var _b = action.payload, data = _b.data, formData = _b.formData;
824
- var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
825
- if (description) {
826
- state.error = description;
827
- return;
828
- }
900
+ var _a = action.payload, data = _a.data, formData = _a.formData;
829
901
  state.data.activitiesData = formData;
830
902
  console.log('updateActivitiesInfo', state.data.activitiesData.responseBody);
831
903
  console.log('updateActivitiesInfo', data);
@@ -868,15 +940,9 @@ export var businessSlice = createSlice({
868
940
  state.error = null;
869
941
  })
870
942
  .addCase(updateCustomersInfo.fulfilled, function (state, action) {
871
- var _a;
872
943
  state.loading = false;
873
944
  state.error = null;
874
- var _b = action.payload, data = _b.data, formData = _b.formData;
875
- var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
876
- if (description) {
877
- state.error = description;
878
- return;
879
- }
945
+ var _a = action.payload, data = _a.data, formData = _a.formData;
880
946
  state.data.customersData = formData;
881
947
  state.data.customersData.responseBody = data;
882
948
  })
@@ -61,7 +61,7 @@ import { FlowsTypes } from '../../../@types';
61
61
  import API from '../../../api';
62
62
  import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, OTHER_BRAND, TWITTER_URL } from '../../../constants';
63
63
  import { defaultCountry } from '../../../constants';
64
- import { getIndividualName, getFlowUrl, capitalizeTheFirstLetterOfEachWord } from '../../../utils';
64
+ import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo } from '../../../utils';
65
65
  export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var settings, requestBody, data;
67
67
  var _a, _b;
@@ -275,29 +275,30 @@ export var retrieveBrandList = createAsyncThunk('retrieveBrandList', function (i
275
275
  brandPayload = {
276
276
  individual_id: individualId
277
277
  };
278
- return [4, API.individualService.getBrandList(brandPayload)];
278
+ return [4, API.brandService.getBrandList(brandPayload)];
279
279
  case 1:
280
- data = (_a.sent()).data;
280
+ data = _a.sent();
281
281
  return [2, data];
282
282
  }
283
283
  });
284
284
  }); });
285
285
  export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
286
286
  var _a, settings, connect, isAbsher, payload, data;
287
- var _b, _c, _d, _e, _f;
288
- return __generator(this, function (_g) {
289
- switch (_g.label) {
287
+ var _b, _c, _d, _e, _f, _g;
288
+ return __generator(this, function (_h) {
289
+ switch (_h.label) {
290
290
  case 0:
291
291
  _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
292
292
  isAbsher = connect.data.otpData.isAbsher;
293
293
  payload = {
294
294
  name: getIndividualName(params.name),
295
295
  id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.lead_id) || '',
296
+ country_code: (_c = settings.data.businessCountry) === null || _c === void 0 ? void 0 : _c.iso2,
296
297
  contact: {
297
298
  email: params.email,
298
299
  phone: isAbsher
299
300
  ? {
300
- country_code: (_d = (_c = params.countryCode) === null || _c === void 0 ? void 0 : _c.idd_prefix) === null || _d === void 0 ? void 0 : _d.toString(),
301
+ country_code: (_e = (_d = params.countryCode) === null || _d === void 0 ? void 0 : _d.idd_prefix) === null || _e === void 0 ? void 0 : _e.toString(),
301
302
  number: params.mobile || ''
302
303
  }
303
304
  : undefined
@@ -314,11 +315,9 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
314
315
  };
315
316
  return [4, API.leadService.updateLead(payload)];
316
317
  case 1:
317
- data = (_g.sent()).data;
318
- if (!data.errors) {
319
- thunkApi.dispatch(handleNextScreenStep());
320
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
321
- }
318
+ data = _h.sent();
319
+ thunkApi.dispatch(handleNextScreenStep());
320
+ (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, params);
322
321
  return [2, { response: data, formData: params }];
323
322
  }
324
323
  });
@@ -350,7 +349,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
350
349
  brand: brand,
351
350
  id: (isExistingUser ? (_l = brandData.responseBody) === null || _l === void 0 ? void 0 : _l.lead_id : (_m = otpData.responseBody) === null || _m === void 0 ? void 0 : _m.lead_id) || '',
352
351
  terms_conditions_accepted: isExistingUser && !isOther ? undefined : params.termAndConditionChecked,
353
- step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
352
+ step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_BRAND,
354
353
  encryption_contract: [
355
354
  'brand.name.en',
356
355
  'brand.name.ar',
@@ -362,11 +361,9 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
362
361
  };
363
362
  return [4, API.leadService.updateLead(payload)];
364
363
  case 1:
365
- data = (_q.sent()).data;
366
- if (!data.errors) {
367
- thunkApi.dispatch(handleNextScreenStep());
368
- (_p = (_o = settings.data.appConfig).onStepCompleted) === null || _p === void 0 ? void 0 : _p.call(_o, settings.data.activeScreen.name, params);
369
- }
364
+ data = _q.sent();
365
+ thunkApi.dispatch(handleNextScreenStep());
366
+ (_p = (_o = settings.data.appConfig).onStepCompleted) === null || _p === void 0 ? void 0 : _p.call(_o, settings.data.activeScreen.name, params);
370
367
  return [2, { response: data, formData: params }];
371
368
  }
372
369
  });
@@ -430,18 +427,12 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
430
427
  payload = {
431
428
  lang: settings.data.language,
432
429
  step_name: CONNECT_STEP_NAMES.CONNECT_SUCCESS,
433
- flows: [
434
- {
435
- name: 'business',
436
- url: getFlowUrl('/business', settings.data.language)
437
- }
438
- ],
439
430
  id: leadId,
440
431
  encryption_contract: []
441
432
  };
442
433
  return [4, API.leadService.updateLead(payload)];
443
434
  case 1:
444
- data = (_j.sent()).data;
435
+ data = _j.sent();
445
436
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
446
437
  (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
447
438
  return [2, { response: data, formData: params }];
@@ -460,7 +451,7 @@ var initialState = {
460
451
  },
461
452
  nidData: {
462
453
  nid: '',
463
- dob: '1998-08-22',
454
+ dob: getEighteenYearsAgo(),
464
455
  type: ''
465
456
  },
466
457
  otpData: {