@tap-payments/auth-jsconnect 1.0.61 → 1.0.65

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 (38) hide show
  1. package/build/@types/redux.d.ts +1 -0
  2. package/build/api/lead.d.ts +4 -1
  3. package/build/assets/locales/ar.json +5 -3
  4. package/build/assets/locales/en.json +7 -5
  5. package/build/constants/assets.d.ts +19 -7
  6. package/build/constants/assets.js +19 -7
  7. package/build/features/Landing/screens/VerifyAndRedirect/VerifyAndRedirect.js +1 -1
  8. package/build/features/app/bank/bankStore.js +4 -0
  9. package/build/features/app/business/businessStore.d.ts +9 -2
  10. package/build/features/app/business/businessStore.js +133 -73
  11. package/build/features/app/connect/connectStore.js +18 -5
  12. package/build/features/app/individual/individualStore.js +4 -0
  13. package/build/features/app/password/passwordStore.js +6 -0
  14. package/build/features/app/tax/taxStore.js +6 -0
  15. package/build/features/business/Business.js +3 -2
  16. package/build/features/business/screens/Activities/Activities.js +4 -0
  17. package/build/features/business/screens/Activities/ActivitiesList.js +5 -6
  18. package/build/features/business/screens/Activities/SalesChannels.js +4 -5
  19. package/build/features/business/screens/BusinessType/BusinessType.js +1 -6
  20. package/build/features/business/screens/BusinessType/LicenseList.js +17 -12
  21. package/build/features/business/screens/BusinessType/LicenseNumber.js +3 -3
  22. package/build/features/business/screens/BusinessType/validation.d.ts +3 -3
  23. package/build/features/business/screens/BusinessType/validation.js +14 -7
  24. package/build/features/business/screens/Customers/Customers.js +0 -1
  25. package/build/features/business/screens/Customers/ExpectedSalesRange.js +0 -5
  26. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +39 -35
  27. package/build/features/business/screens/Verify/Verify.js +1 -1
  28. package/build/features/password/screens/CreatePassword/CreatePassword.js +0 -1
  29. package/build/features/shared/Button/AbsherButton.js +23 -19
  30. package/build/features/shared/Button/Button.js +1 -1
  31. package/build/features/shared/Button/EmailProvidersButtons.js +7 -2
  32. package/build/features/shared/Button/FlowsButtons.d.ts +4 -3
  33. package/build/features/shared/Button/FlowsButtons.js +37 -20
  34. package/build/features/shared/Button/MobileButton.js +14 -11
  35. package/build/features/shared/SuccessScreen/SuccessScreen.js +1 -1
  36. package/build/utils/string.d.ts +1 -0
  37. package/build/utils/string.js +4 -0
  38. package/package.json +1 -1
@@ -60,7 +60,7 @@ import moment from 'moment';
60
60
  import API from '../../../api';
61
61
  import { BusinessType } from '../../../@types';
62
62
  import { BUSINESS_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
63
- import { convertNumbers2English, getClientEmailUrl, removeRequestHeaders } from '../../../utils';
63
+ import { convertNumbers2English, getFlowUrl, removeRequestHeaders } from '../../../utils';
64
64
  import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
65
65
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
66
  var settings, countriesBody, businessCountry;
@@ -79,9 +79,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
79
79
  });
80
80
  }); });
81
81
  export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
82
- var payload, data, leadResponse;
83
- return __generator(this, function (_a) {
84
- switch (_a.label) {
82
+ var payload, data, leadResponse, number;
83
+ var _a;
84
+ return __generator(this, function (_b) {
85
+ switch (_b.label) {
85
86
  case 0:
86
87
  payload = {
87
88
  service_name: 'tap_email',
@@ -89,25 +90,29 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
89
90
  };
90
91
  return [4, API.leadService.verifyLeadToken(payload)];
91
92
  case 1:
92
- data = (_a.sent()).data;
93
+ data = (_b.sent()).data;
93
94
  leadResponse = undefined;
94
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
95
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 4];
95
96
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
96
97
  case 2:
97
- leadResponse = _a.sent();
98
+ leadResponse = _b.sent();
99
+ number = (((_a = leadResponse.data.entity) === null || _a === void 0 ? void 0 : _a.license) || {}).number;
100
+ return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id, licenseNumber: number }))];
101
+ case 3:
102
+ _b.sent();
98
103
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
99
104
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
100
105
  }
101
106
  if (data.step_name === 'business_info') {
102
107
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
103
108
  }
104
- _a.label = 3;
105
- case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
109
+ _b.label = 4;
110
+ case 4: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
106
111
  }
107
112
  });
108
113
  }); });
109
114
  export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
110
- var _a, business, settings, isNID, responseBody, payload, data, steps, hasBusinessCompleted;
115
+ var _a, business, settings, isNID, responseBody, stepName, payload, data, steps, hasBusinessCompleted;
111
116
  var _b, _c, _d;
112
117
  return __generator(this, function (_e) {
113
118
  switch (_e.label) {
@@ -115,17 +120,19 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
115
120
  _a = thunkApi.getState(), business = _a.business, settings = _a.settings;
116
121
  isNID = business.data.otpData.isNID;
117
122
  responseBody = (isNID ? business.data.nidData : business.data.verify).responseBody;
123
+ stepName = isNID ? BUSINESS_STEP_NAMES.IDENTITY_VERIFY_AUTH : BUSINESS_STEP_NAMES.PHONE_AUTH;
118
124
  payload = {
119
125
  data: params.otp,
120
126
  service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
121
127
  verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
122
- step_name: isNID ? BUSINESS_STEP_NAMES.IDENTITY_VERIFY_AUTH : BUSINESS_STEP_NAMES.PHONE_AUTH,
128
+ step_name: stepName,
123
129
  encryption_contract: ['data']
124
130
  };
125
131
  return [4, API.leadService.verifyLeadOTP(payload)];
126
132
  case 1:
127
133
  data = (_e.sent()).data;
128
134
  if (!data.errors) {
135
+ thunkApi.dispatch(updateStepName(stepName));
129
136
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
130
137
  steps = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.steps) || [];
131
138
  hasBusinessCompleted = Object.keys(steps).find(function (key) { return key === BUSINESS_STEP_NAMES.BUSINESS_SUCCESS; });
@@ -149,13 +156,14 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
149
156
  });
150
157
  }); });
151
158
  export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
152
- var _a, settings, business, identification_id_type, headers, requestBody, data;
159
+ var _a, settings, business, identification_id_type, stepName, headers, requestBody, data;
153
160
  var _b, _c, _d, _e, _f;
154
161
  return __generator(this, function (_g) {
155
162
  switch (_g.label) {
156
163
  case 0:
157
164
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
158
165
  identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
166
+ stepName = BUSINESS_STEP_NAMES.IDENTITY_AUTH;
159
167
  headers = {
160
168
  lead_id: ((_b = business.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
161
169
  device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
@@ -165,13 +173,14 @@ export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function
165
173
  identification_id_type: identification_id_type,
166
174
  date_of_birth: params.dob,
167
175
  country_code: business.data.businessCountry.iso2,
168
- step_name: BUSINESS_STEP_NAMES.IDENTITY_AUTH,
176
+ step_name: stepName,
169
177
  encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
170
178
  };
171
179
  return [4, API.leadService.updateLeadIdentity(requestBody, { headers: headers })];
172
180
  case 1:
173
181
  data = (_g.sent()).data;
174
182
  if (!data.errors && !params.isResend) {
183
+ thunkApi.dispatch(updateStepName(stepName));
175
184
  thunkApi.dispatch(handleNextScreenStep());
176
185
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
177
186
  }
@@ -180,17 +189,13 @@ export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function
180
189
  });
181
190
  }); });
182
191
  export var retrieveEntityList = createAsyncThunk('retrieveEntityList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
183
- var business, leadId, data;
184
- var _a;
185
- return __generator(this, function (_b) {
186
- switch (_b.label) {
187
- case 0:
188
- business = thunkApi.getState().business;
189
- leadId = (_a = business.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.id;
190
- return [4, API.leadService.retrieveEntityList(leadId)];
192
+ var data;
193
+ return __generator(this, function (_a) {
194
+ switch (_a.label) {
195
+ case 0: return [4, API.leadService.retrieveEntityList(params.leadId)];
191
196
  case 1:
192
- data = (_b.sent()).data;
193
- return [2, { data: data }];
197
+ data = (_a.sent()).data;
198
+ return [2, { data: data, licenseNumber: params.licenseNumber }];
194
199
  }
195
200
  });
196
201
  }); });
@@ -212,11 +217,13 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
212
217
  return [4, API.leadService.updateLead(payload)];
213
218
  case 1:
214
219
  data = (_g.sent()).data;
215
- if (!data.errors) {
216
- thunkApi.dispatch(createAccount());
217
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
218
- }
219
- return [2, { data: data, formData: params }];
220
+ if (!!data.errors) return [3, 3];
221
+ return [4, thunkApi.dispatch(createAccount())];
222
+ case 2:
223
+ _g.sent();
224
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
225
+ _g.label = 3;
226
+ case 3: return [2, { data: data, formData: params }];
220
227
  }
221
228
  });
222
229
  }); });
@@ -253,7 +260,7 @@ export var createAccount = createAsyncThunk('createAccount', function (params, t
253
260
  });
254
261
  }); });
255
262
  export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
256
- var _a, settings, business, channel, activities, requestBody, headers, data;
263
+ var _a, settings, business, channel, activities, stepName, id, requestBody, headers, data;
257
264
  var _b, _c, _d, _e;
258
265
  return __generator(this, function (_f) {
259
266
  switch (_f.label) {
@@ -267,17 +274,20 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
267
274
  var en = _a.en;
268
275
  return en;
269
276
  });
277
+ stepName = BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES;
278
+ id = (_c = business.data.businessTypeData.responseBody) === null || _c === void 0 ? void 0 : _c.entity_id;
270
279
  requestBody = {
271
280
  activities: activities,
272
281
  channel_services: channel,
273
282
  business_operation_start_at: params.operationStartDate,
274
- step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES
283
+ step_name: stepName
275
284
  };
276
- headers = { entity_id: (_c = business.data.businessTypeData.responseBody) === null || _c === void 0 ? void 0 : _c.entity_id };
285
+ headers = { entity_id: id };
277
286
  return [4, API.entityService.createEntityInfo(requestBody, { headers: headers })];
278
287
  case 1:
279
288
  data = (_f.sent()).data;
280
289
  if (!!data.errors) return [3, 3];
290
+ thunkApi.dispatch(updateStepName(stepName));
281
291
  return [4, thunkApi.dispatch(retrieveDataList())];
282
292
  case 2:
283
293
  _f.sent();
@@ -308,7 +318,7 @@ export var retrieveDataList = createAsyncThunk('retrieveDataList', function () {
308
318
  });
309
319
  }); });
310
320
  export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
311
- var _a, settings, business, customerBase, requestBody, data;
321
+ var _a, settings, business, customerBase, stepName, requestBody, data;
312
322
  var _b, _c, _d, _e, _f;
313
323
  return __generator(this, function (_g) {
314
324
  switch (_g.label) {
@@ -318,6 +328,7 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
318
328
  var title = _a.title;
319
329
  return title;
320
330
  });
331
+ stepName = BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS;
321
332
  requestBody = {
322
333
  customers_base: customerBase,
323
334
  id: (_b = business.data.businessTypeData.responseBody) === null || _b === void 0 ? void 0 : _b.entity_id,
@@ -325,12 +336,13 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
325
336
  yearly_sales_range: ((_d = params.expectedSalesRange) === null || _d === void 0 ? void 0 : _d.title) || '',
326
337
  agree_refund: params.refundPolicy,
327
338
  agree_chargeback: params.transactionPolicy,
328
- step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
339
+ step_name: stepName
329
340
  };
330
341
  return [4, API.entityService.updateEntityInfo(requestBody)];
331
342
  case 1:
332
343
  data = (_g.sent()).data;
333
344
  if (!data.errors) {
345
+ thunkApi.dispatch(updateStepName(stepName));
334
346
  thunkApi.dispatch(handleNextScreenStep());
335
347
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
336
348
  }
@@ -339,33 +351,71 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
339
351
  });
340
352
  }); });
341
353
  export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
342
- var _a, settings, business, response, payload;
343
- var _b, _c, _d, _e, _f, _g;
344
- return __generator(this, function (_h) {
345
- switch (_h.label) {
354
+ var _a, settings, business, _b, steps, id, flowCompleted, payload, data;
355
+ var _c, _d, _e, _f;
356
+ return __generator(this, function (_g) {
357
+ switch (_g.label) {
346
358
  case 0:
347
359
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
348
- response = undefined;
349
- if (!!!((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id)) return [3, 2];
360
+ _b = business.data.verify.responseBody || {}, steps = _b.steps, id = _b.id;
361
+ flowCompleted = Object.keys(steps).find(function (key) { return key === BUSINESS_STEP_NAMES.BUSINESS_SUCCESS; });
362
+ if (flowCompleted)
363
+ return [2];
350
364
  payload = {
351
365
  step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
352
- id: ((_c = business.data.otpData.responseBody) === null || _c === void 0 ? void 0 : _c.id) || '',
353
- email_url: getClientEmailUrl(),
366
+ id: id,
367
+ flows: [
368
+ {
369
+ name: 'tax',
370
+ url: getFlowUrl('/tax')
371
+ },
372
+ {
373
+ name: 'bank',
374
+ url: getFlowUrl('/bank')
375
+ },
376
+ {
377
+ name: 'individual',
378
+ url: getFlowUrl('/individual')
379
+ },
380
+ {
381
+ name: 'password',
382
+ url: getFlowUrl('/password')
383
+ }
384
+ ],
385
+ encryption_contract: []
386
+ };
387
+ return [4, API.leadService.updateLead(payload)];
388
+ case 1:
389
+ data = (_g.sent()).data;
390
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
391
+ (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
392
+ return [2, { response: data, formData: params }];
393
+ }
394
+ });
395
+ }); });
396
+ export var updateStepName = createAsyncThunk('updateStepName', function (stepName, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
397
+ var business, payload, data;
398
+ var _a;
399
+ return __generator(this, function (_b) {
400
+ switch (_b.label) {
401
+ case 0:
402
+ business = thunkApi.getState().business;
403
+ payload = {
404
+ step_name: stepName,
405
+ id: ((_a = business.data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.id) || '',
354
406
  encryption_contract: []
355
407
  };
356
408
  return [4, API.leadService.updateLead(payload)];
357
409
  case 1:
358
- response = _h.sent();
359
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, params);
360
- (_g = (_f = settings.data.appConfig).onFlowCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, { data: response === null || response === void 0 ? void 0 : response.data });
361
- _h.label = 2;
362
- case 2: return [2, { response: response === null || response === void 0 ? void 0 : response.data, formData: params }];
410
+ data = (_b.sent()).data;
411
+ return [2, { response: data }];
363
412
  }
364
413
  });
365
414
  }); });
366
415
  var initialState = {
367
416
  error: null,
368
417
  loading: false,
418
+ customLoading: false,
369
419
  data: {
370
420
  businessCountry: defaultCountry,
371
421
  countries: [],
@@ -416,23 +466,28 @@ export var businessSlice = createSlice({
416
466
  builder
417
467
  .addCase(getCountries.fulfilled, function (state, action) {
418
468
  state.error = null;
469
+ state.customLoading = false;
419
470
  var _a = action.payload, businessCountry = _a.businessCountry, countries = _a.countries;
420
471
  state.data.countries = countries;
421
472
  state.data.businessCountry = businessCountry || defaultCountry;
422
473
  })
423
474
  .addCase(getCountries.pending, function (state) {
424
475
  state.error = null;
476
+ state.customLoading = true;
425
477
  })
426
478
  .addCase(getCountries.rejected, function (state, action) {
427
479
  state.error = action.error.message;
480
+ state.customLoading = false;
428
481
  })
429
482
  .addCase(verifyLeadToken.pending, function (state) {
430
483
  state.error = null;
484
+ state.customLoading = true;
431
485
  })
432
486
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
433
- var _a, _b, _c, _d, _e;
487
+ var _a;
434
488
  state.error = null;
435
- var _f = action.payload, data = _f.data, token = _f.token, leadData = _f.leadData;
489
+ state.customLoading = false;
490
+ var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
436
491
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
437
492
  if (description) {
438
493
  state.error = description;
@@ -441,16 +496,10 @@ export var businessSlice = createSlice({
441
496
  state.data.verify.responseBody = __assign(__assign({}, data), leadData);
442
497
  state.data.verify.token = token;
443
498
  state.data.otpData.isNID = false;
444
- if (!!((_c = (_b = leadData === null || leadData === void 0 ? void 0 : leadData.entity) === null || _b === void 0 ? void 0 : _b.license) === null || _c === void 0 ? void 0 : _c.issuing_date)) {
445
- state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_e = (_d = leadData === null || leadData === void 0 ? void 0 : leadData.entity) === null || _d === void 0 ? void 0 : _d.license) === null || _e === void 0 ? void 0 : _e.issuing_date).format('YYYY-MM-DD'));
446
- }
447
- var activities = (leadData === null || leadData === void 0 ? void 0 : leadData.entity_activities) || [];
448
- var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
449
- if (!!selectedActivity)
450
- state.data.activitiesData.activities = [selectedActivity];
451
499
  })
452
500
  .addCase(verifyLeadToken.rejected, function (state, action) {
453
501
  state.error = action.error.message;
502
+ state.customLoading = false;
454
503
  })
455
504
  .addCase(verifyLeadOTP.pending, function (state) {
456
505
  state.loading = true;
@@ -474,13 +523,17 @@ export var businessSlice = createSlice({
474
523
  state.error = action.error.message;
475
524
  })
476
525
  .addCase(updateLeadIdentity.pending, function (state, action) {
477
- var _a;
478
- state.loading = ((_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.isResend) ? false : true;
526
+ var _a, _b;
527
+ if ((_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.isResend)
528
+ state.customLoading = true;
529
+ if ((_b = action.meta.arg) === null || _b === void 0 ? void 0 : _b.isResend)
530
+ state.loading = true;
479
531
  state.error = null;
480
532
  })
481
533
  .addCase(updateLeadIdentity.fulfilled, function (state, action) {
482
534
  var _a;
483
535
  state.loading = false;
536
+ state.customLoading = false;
484
537
  state.error = null;
485
538
  var _b = action.payload, data = _b.data, formData = _b.formData;
486
539
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
@@ -495,15 +548,18 @@ export var businessSlice = createSlice({
495
548
  })
496
549
  .addCase(updateLeadIdentity.rejected, function (state, action) {
497
550
  state.loading = false;
551
+ state.customLoading = false;
498
552
  state.error = action.error.message;
499
553
  })
500
554
  .addCase(retrieveEntityList.pending, function (state) {
501
555
  state.error = null;
556
+ state.customLoading = true;
502
557
  })
503
558
  .addCase(retrieveEntityList.fulfilled, function (state, action) {
504
- var _a, _b;
559
+ var _a, _b, _c, _d, _e;
505
560
  state.error = null;
506
- var data = action.payload.data;
561
+ state.customLoading = false;
562
+ var _f = action.payload, data = _f.data, licenseNumber = _f.licenseNumber;
507
563
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
508
564
  var licenseList = [];
509
565
  if (!description) {
@@ -522,37 +578,40 @@ export var businessSlice = createSlice({
522
578
  }
523
579
  licenseList = __spreadArray(__spreadArray([], licenseList, true), [OTHER_CR_LICENSE, OTHER_FL_LICENSE], false);
524
580
  state.data.businessTypeData.responseBody = { licenseList: licenseList };
525
- var selectedLicense = licenseList === null || licenseList === void 0 ? void 0 : licenseList[0];
581
+ var selectedLicense = ((_b = licenseList === null || licenseList === void 0 ? void 0 : licenseList.find) === null || _b === void 0 ? void 0 : _b.call(licenseList, function (item) { var _a; return ((_a = item.license) === null || _a === void 0 ? void 0 : _a.number) === licenseNumber; })) || (licenseList === null || licenseList === void 0 ? void 0 : licenseList[0]);
526
582
  state.data.businessTypeData.selectedLicense = selectedLicense;
527
- state.data.businessTypeData.licenseNumber = (_b = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _b === void 0 ? void 0 : _b.number;
583
+ var isOtherLicense = ((_c = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _c === void 0 ? void 0 : _c.number) === 'other_fl' || ((_d = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _d === void 0 ? void 0 : _d.number) === 'other_cr';
584
+ if (!isOtherLicense)
585
+ state.data.businessTypeData.licenseNumber = (_e = selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.license) === null || _e === void 0 ? void 0 : _e.number;
528
586
  })
529
587
  .addCase(retrieveEntityList.rejected, function (state, action) {
530
588
  state.error = action.error.message;
589
+ state.customLoading = false;
531
590
  })
532
591
  .addCase(updateLeadBusinessType.pending, function (state) {
533
592
  state.loading = true;
534
593
  state.error = null;
535
594
  })
536
595
  .addCase(updateLeadBusinessType.fulfilled, function (state, action) {
537
- var _a, _b, _c, _d, _e;
538
- state.loading = true;
596
+ var _a, _b, _c, _d;
597
+ state.loading = false;
539
598
  state.error = null;
540
- var _f = action.payload, data = _f.data, formData = _f.formData;
599
+ var _e = action.payload, data = _e.data, formData = _e.formData;
541
600
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
542
601
  if (description) {
543
602
  state.error = description;
544
603
  return;
545
604
  }
546
605
  state.data.businessTypeData = __assign(__assign({}, state.data.businessTypeData), formData);
547
- if (!!((_c = (_b = data === null || data === void 0 ? void 0 : data.entity) === null || _b === void 0 ? void 0 : _b.license) === null || _c === void 0 ? void 0 : _c.issuing_date)) {
548
- state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_e = (_d = data === null || data === void 0 ? void 0 : data.entity) === null || _d === void 0 ? void 0 : _d.license) === null || _e === void 0 ? void 0 : _e.issuing_date).format('YYYY-MM-DD'));
606
+ var entity = data.entity, entity_activities = data.entity_activities;
607
+ if (!!((_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date)) {
608
+ state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_d = (_c = data === null || data === void 0 ? void 0 : data.entity) === null || _c === void 0 ? void 0 : _c.license) === null || _d === void 0 ? void 0 : _d.issuing_date).format('YYYY-MM-DD'));
549
609
  }
550
- var activities = (data === null || data === void 0 ? void 0 : data.entity_activities) || [];
610
+ var activities = entity_activities || [];
551
611
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
552
612
  if (!!selectedActivity)
553
613
  state.data.activitiesData.activities = [selectedActivity];
554
- var licenseList = (state.data.businessTypeData.responseBody || { licenseList: [] }).licenseList;
555
- state.data.businessTypeData.responseBody = __assign(__assign({ licenseList: licenseList }, data), { activities: activities });
614
+ state.data.businessTypeData.responseBody = __assign(__assign(__assign({}, data), state.data.businessTypeData.responseBody), { activities: activities });
556
615
  })
557
616
  .addCase(updateLeadBusinessType.rejected, function (state, action) {
558
617
  state.loading = false;
@@ -576,9 +635,9 @@ export var businessSlice = createSlice({
576
635
  state.error = 'signup_user_exists_error';
577
636
  return;
578
637
  }
579
- var licenseList = (state.data.businessTypeData.responseBody || { licenseList: [] }).licenseList;
580
- state.data.businessTypeData.responseBody = __assign(__assign({ licenseList: licenseList }, data), { channelList: channelsData || [] });
581
- var selectedChannel = channelsData === null || channelsData === void 0 ? void 0 : channelsData[0];
638
+ var channels = channelsData || [];
639
+ state.data.businessTypeData.responseBody = __assign(__assign(__assign({}, data), state.data.businessTypeData.responseBody), { channelList: channels });
640
+ var selectedChannel = channels === null || channels === void 0 ? void 0 : channels[0];
582
641
  if (!!selectedChannel)
583
642
  state.data.activitiesData.salesChannels = [selectedChannel];
584
643
  })
@@ -656,12 +715,13 @@ export var businessSlice = createSlice({
656
715
  var _a;
657
716
  state.loading = false;
658
717
  state.error = null;
659
- var response = action.payload.response;
718
+ var response = (action.payload || {}).response;
660
719
  var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
661
720
  if (description) {
662
721
  state.error = description;
663
722
  return;
664
723
  }
724
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: response.flows });
665
725
  removeRequestHeaders();
666
726
  })
667
727
  .addCase(updateLeadSuccess.pending, function (state) {
@@ -60,7 +60,7 @@ import { handleNextScreenStep } from '../../../app/settings';
60
60
  import API from '../../../api';
61
61
  import { BRAND_LIST, CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, OTHER_BRAND, TWITTER_URL } from '../../../constants';
62
62
  import { defaultCountry } from '../../../constants';
63
- import { getIndividualName, getClientEmailUrl, capitalizeTheFirstLetterOfEachWord, removeRequestHeaders } from '../../../utils';
63
+ import { getIndividualName, getFlowUrl, capitalizeTheFirstLetterOfEachWord, removeRequestHeaders } from '../../../utils';
64
64
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
65
65
  var settings, countriesBody, businessCountry;
66
66
  return __generator(this, function (_a) {
@@ -284,7 +284,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
284
284
  id: (isExistingUser ? (_h = brandData.responseBody) === null || _h === void 0 ? void 0 : _h.lead_id : (_j = otpData.responseBody) === null || _j === void 0 ? void 0 : _j.lead_id) || '',
285
285
  terms_conditions_accepted: params.termAndConditionChecked,
286
286
  step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
287
- encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh', 'social[0]', 'social[1]']
287
+ encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh']
288
288
  };
289
289
  return [4, API.leadService.updateLead(payload)];
290
290
  case 1:
@@ -352,7 +352,12 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
352
352
  isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) === false;
353
353
  payload = {
354
354
  step_name: CONNECT_STEP_NAMES.CONNECT_SUCCESS,
355
- email_url: getClientEmailUrl(),
355
+ flows: [
356
+ {
357
+ name: 'business',
358
+ url: getFlowUrl('/business')
359
+ }
360
+ ],
356
361
  id: (isExistingUser ? (_c = brandData.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id : (_d = otpData.responseBody) === null || _d === void 0 ? void 0 : _d.lead_id) || '',
357
362
  encryption_contract: []
358
363
  };
@@ -368,6 +373,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
368
373
  var initialState = {
369
374
  error: null,
370
375
  loading: false,
376
+ customLoading: false,
371
377
  data: {
372
378
  businessCountry: defaultCountry,
373
379
  countries: [],
@@ -432,6 +438,7 @@ export var connectSlice = createSlice({
432
438
  builder
433
439
  .addCase(getCountries.fulfilled, function (state, action) {
434
440
  state.error = null;
441
+ state.customLoading = false;
435
442
  var _a = action.payload, countries = _a.countries, businessCountry = _a.businessCountry;
436
443
  state.data.countries = countries;
437
444
  state.data.businessCountry = businessCountry || defaultCountry;
@@ -439,13 +446,16 @@ export var connectSlice = createSlice({
439
446
  })
440
447
  .addCase(getCountries.pending, function (state) {
441
448
  state.error = null;
449
+ state.customLoading = true;
442
450
  })
443
451
  .addCase(getCountries.rejected, function (state, action) {
444
452
  state.error = action.error.message;
453
+ state.customLoading = false;
445
454
  })
446
455
  .addCase(createMobileAuth.fulfilled, function (state, action) {
447
456
  var _a;
448
457
  state.loading = false;
458
+ state.customLoading = false;
449
459
  state.error = null;
450
460
  var _b = action.payload, formData = _b.formData, response = _b.response;
451
461
  var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
@@ -458,12 +468,15 @@ export var connectSlice = createSlice({
458
468
  state.data.otpData.isAbsher = false;
459
469
  })
460
470
  .addCase(createMobileAuth.pending, function (state, action) {
461
- var _a;
462
- state.loading = ((_a = action.meta.arg) === null || _a === void 0 ? void 0 : _a.isResend) ? false : true;
471
+ if (action.meta.arg.isResend)
472
+ state.customLoading = true;
473
+ if (!action.meta.arg.isResend)
474
+ state.loading = true;
463
475
  state.error = null;
464
476
  })
465
477
  .addCase(createMobileAuth.rejected, function (state, action) {
466
478
  state.loading = false;
479
+ state.customLoading = false;
467
480
  state.error = action.error.message;
468
481
  })
469
482
  .addCase(createNIDAuth.fulfilled, function (state, action) {
@@ -164,6 +164,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
164
164
  var initialState = {
165
165
  error: null,
166
166
  loading: false,
167
+ customLoading: false,
167
168
  data: {
168
169
  verify: {
169
170
  token: ''
@@ -199,10 +200,12 @@ export var individualSlice = createSlice({
199
200
  builder
200
201
  .addCase(verifyLeadToken.pending, function (state) {
201
202
  state.error = null;
203
+ state.customLoading = true;
202
204
  })
203
205
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
204
206
  var _a;
205
207
  state.error = null;
208
+ state.customLoading = false;
206
209
  var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
207
210
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
208
211
  if (description) {
@@ -214,6 +217,7 @@ export var individualSlice = createSlice({
214
217
  })
215
218
  .addCase(verifyLeadToken.rejected, function (state, action) {
216
219
  state.error = action.error.message;
220
+ state.customLoading = false;
217
221
  })
218
222
  .addCase(verifyLeadOTP.pending, function (state) {
219
223
  state.loading = true;
@@ -158,6 +158,7 @@ export var passwordSlice = createSlice({
158
158
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
159
159
  var _a;
160
160
  state.error = null;
161
+ state.customLoading = false;
161
162
  var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
162
163
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
163
164
  if (description) {
@@ -166,9 +167,14 @@ export var passwordSlice = createSlice({
166
167
  }
167
168
  state.data.verify.responseBody = __assign(__assign({}, data), leadData);
168
169
  state.data.verify.token = token;
170
+ })
171
+ .addCase(verifyLeadToken.pending, function (state, action) {
172
+ state.customLoading = true;
173
+ state.error = null;
169
174
  })
170
175
  .addCase(verifyLeadToken.rejected, function (state, action) {
171
176
  state.error = action.error.message;
177
+ state.customLoading = false;
172
178
  })
173
179
  .addCase(verifyPasswordLeadOTP.pending, function (state) {
174
180
  state.loading = true;
@@ -190,6 +190,7 @@ export var taxSlice = createSlice({
190
190
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
191
191
  var _a;
192
192
  state.error = null;
193
+ state.customLoading = false;
193
194
  var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
194
195
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
195
196
  if (description) {
@@ -198,9 +199,14 @@ export var taxSlice = createSlice({
198
199
  }
199
200
  state.data.verify.responseBody = __assign(__assign({}, data), leadData);
200
201
  state.data.verify.token = token;
202
+ })
203
+ .addCase(verifyLeadToken.pending, function (state, action) {
204
+ state.error = null;
205
+ state.customLoading = true;
201
206
  })
202
207
  .addCase(verifyLeadToken.rejected, function (state, action) {
203
208
  state.error = action.error.message;
209
+ state.customLoading = false;
204
210
  })
205
211
  .addCase(verifyTaxLeadOTP.pending, function (state) {
206
212
  state.loading = true;