@tap-payments/auth-jsconnect 1.0.33 → 1.0.36

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 (37) hide show
  1. package/build/@types/form.d.ts +8 -1
  2. package/build/api/account.d.ts +15 -0
  3. package/build/api/account.js +9 -0
  4. package/build/api/data.d.ts +6 -0
  5. package/build/api/data.js +17 -0
  6. package/build/api/entity.d.ts +4 -4
  7. package/build/api/index.d.ts +10 -1
  8. package/build/api/index.js +5 -1
  9. package/build/components/AnimationFlow/BottomSheet.js +1 -1
  10. package/build/components/Input/Input.js +1 -1
  11. package/build/constants/api.d.ts +4 -0
  12. package/build/constants/api.js +9 -1
  13. package/build/constants/app.d.ts +5 -1
  14. package/build/constants/app.js +5 -1
  15. package/build/features/app/business/businessStore.d.ts +26 -5
  16. package/build/features/app/business/businessStore.js +221 -40
  17. package/build/features/app/connect/connectStore.d.ts +8 -2
  18. package/build/features/app/connect/connectStore.js +19 -1
  19. package/build/features/business/screens/Activities/Activities.js +12 -12
  20. package/build/features/business/screens/Activities/ActivitiesList.js +14 -4
  21. package/build/features/business/screens/Activities/SalesChannels.js +11 -2
  22. package/build/features/business/screens/Confirm/Confirm.js +3 -3
  23. package/build/features/business/screens/Customers/Customers.js +3 -2
  24. package/build/features/business/screens/IDBOD/IDBOD.js +1 -1
  25. package/build/features/business/screens/IDBOD/validation.js +2 -3
  26. package/build/features/business/screens/Success/Success.js +6 -0
  27. package/build/features/business/screens/Verify/Verify.js +2 -1
  28. package/build/features/connect/screens/Individual/Individual.js +6 -1
  29. package/build/features/connect/screens/Merchant/Merchant.js +6 -1
  30. package/build/features/connect/screens/Mobile/Mobile.js +6 -1
  31. package/build/features/connect/screens/NID/NID.js +6 -1
  32. package/build/features/connect/screens/OTP/OTP.js +6 -1
  33. package/build/features/connect/screens/OTP/OTPInput.js +0 -3
  34. package/build/features/connect/screens/Password/Password.js +6 -1
  35. package/build/features/shared/Button/Button.js +16 -11
  36. package/build/utils/string.js +2 -1
  37. package/package.json +1 -1
@@ -47,10 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import moment from 'moment';
50
51
  import API from '../../../api';
51
52
  import { BusinessType } from '../../../@types';
52
53
  import { BUSINESS_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE } from '../../../constants';
53
- import { handleNextScreenStep } from '../../../app/settings';
54
+ import i18n from '../../../i18n';
55
+ import { convertNumbers2English, removeRequestHeaders } from '../../../utils';
56
+ import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
54
57
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
55
58
  var settings, countriesBody, list, businessCountry;
56
59
  return __generator(this, function (_a) {
@@ -82,14 +85,14 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
82
85
  data = (_a.sent()).data;
83
86
  leadResponse = undefined;
84
87
  if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
85
- return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.lead_id)];
88
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
86
89
  case 2:
87
90
  leadResponse = _a.sent();
88
91
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
89
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
92
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_IDBOD_STEP'));
90
93
  }
91
- else {
92
- thunkApi.dispatch(handleNextScreenStep('BUSINESS_VERIFY_STEP'));
94
+ if (data.step_name === 'business_info') {
95
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_BUSINESS_TYPE_STEP'));
93
96
  }
94
97
  _a.label = 3;
95
98
  case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
@@ -97,14 +100,14 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
97
100
  });
98
101
  }); });
99
102
  export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
100
- var _a, business, settings, responseBody, isNID, payload, data;
103
+ var _a, business, settings, isNID, responseBody, payload, data;
101
104
  var _b, _c, _d;
102
105
  return __generator(this, function (_e) {
103
106
  switch (_e.label) {
104
107
  case 0:
105
108
  _a = thunkApi.getState(), business = _a.business, settings = _a.settings;
106
- responseBody = business.data.verify.responseBody;
107
- isNID = settings.data.activeScreen.name === 'BUSINESS_IDBOD_STEP';
109
+ isNID = business.data.otpData.isNID;
110
+ responseBody = (isNID ? business.data.nidData : business.data.verify).responseBody;
108
111
  payload = {
109
112
  data: params.otp,
110
113
  service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
@@ -136,13 +139,17 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
136
139
  });
137
140
  }); });
138
141
  export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
139
- var _a, settings, business, identification_id_type, requestBody, data;
140
- var _b, _c;
141
- return __generator(this, function (_d) {
142
- switch (_d.label) {
142
+ var _a, settings, business, identification_id_type, headers, requestBody, data;
143
+ var _b, _c, _d, _e, _f;
144
+ return __generator(this, function (_g) {
145
+ switch (_g.label) {
143
146
  case 0:
144
147
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
145
148
  identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
149
+ headers = {
150
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
151
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
152
+ };
146
153
  requestBody = {
147
154
  identification_id: params.nid,
148
155
  identification_id_type: identification_id_type,
@@ -151,12 +158,12 @@ export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function
151
158
  step_name: BUSINESS_STEP_NAMES.IDENTITY_AUTH,
152
159
  encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
153
160
  };
154
- return [4, API.leadService.updateLeadIdentity(requestBody)];
161
+ return [4, API.leadService.updateLeadIdentity(requestBody, { headers: headers })];
155
162
  case 1:
156
- data = (_d.sent()).data;
163
+ data = (_g.sent()).data;
157
164
  if (!data.errors && !params.isResend) {
158
165
  thunkApi.dispatch(handleNextScreenStep());
159
- (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
166
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
160
167
  }
161
168
  return [2, { data: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
162
169
  }
@@ -193,20 +200,21 @@ export var retrieveFLInfos = createAsyncThunk('retrieveFLInfos', function (_a, t
193
200
  });
194
201
  }); });
195
202
  export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
196
- var _a, settings, connect, headers, payload, data;
203
+ var _a, settings, business, headers, payload, data;
197
204
  var _b, _c, _d, _e, _f;
198
205
  return __generator(this, function (_g) {
199
206
  switch (_g.label) {
200
207
  case 0:
201
- _a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
208
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
202
209
  headers = {
203
- lead_id: ((_b = connect.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
210
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
204
211
  device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
205
212
  };
206
213
  payload = {
207
214
  freelancer_number: params.flNumber,
208
215
  business_type: params.businessType,
209
216
  cr_number: params.crNumber,
217
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_INFO,
210
218
  encryption_contract: ['freelancer_number', 'business_type', 'cr_number']
211
219
  };
212
220
  return [4, API.leadService.updateLead(payload, { headers: headers })];
@@ -220,31 +228,114 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
220
228
  }
221
229
  });
222
230
  }); });
223
- export var updateEntityInfo = createAsyncThunk('updateEntityInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
224
- var settings, requestBody, headers, data;
225
- var _a, _b;
226
- return __generator(this, function (_c) {
227
- switch (_c.label) {
231
+ export var createAccount = createAsyncThunk('createAccount', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
232
+ var _a, settings, business, requestBody, data, channels;
233
+ var _b, _c, _d;
234
+ return __generator(this, function (_e) {
235
+ switch (_e.label) {
228
236
  case 0:
229
- settings = thunkApi.getState().settings;
237
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
238
+ requestBody = {
239
+ lead_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id,
240
+ notify: {
241
+ email: false,
242
+ phone: false
243
+ },
244
+ skip_legacy: false,
245
+ is_acknowledged: true,
246
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM
247
+ };
248
+ return [4, API.accountService.createAccount(requestBody)];
249
+ case 1:
250
+ data = (_e.sent()).data;
251
+ channels = undefined;
252
+ if (!!data.errors) return [3, 3];
253
+ return [4, API.dataService.getChannelsOfServices()];
254
+ case 2:
255
+ channels = _e.sent();
256
+ thunkApi.dispatch(handleNextScreenStep());
257
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
258
+ _e.label = 3;
259
+ case 3: return [2, { data: data, channelsData: channels === null || channels === void 0 ? void 0 : channels.data }];
260
+ }
261
+ });
262
+ }); });
263
+ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
264
+ var _a, settings, business, requestBody, headers, data;
265
+ var _b, _c, _d;
266
+ return __generator(this, function (_e) {
267
+ switch (_e.label) {
268
+ case 0:
269
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
230
270
  requestBody = {
231
271
  activities: params.activities,
232
272
  channel_services: params.salesChannels,
233
273
  business_operation_start_at: params.operationStartDate,
234
- step_name: BUSINESS_STEP_NAMES.BUSINESS_INFO
274
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES
235
275
  };
236
- headers = { entity_id: '123456789' };
276
+ headers = { entity_id: (_b = business.data.businessInfo.responseBody) === null || _b === void 0 ? void 0 : _b.entity_id };
237
277
  return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
238
278
  case 1:
239
- data = (_c.sent()).data;
279
+ data = (_e.sent()).data;
280
+ if (!data.errors) {
281
+ thunkApi.dispatch(handleNextScreenStep());
282
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
283
+ }
284
+ return [2, { data: data, formData: __assign({}, params) }];
285
+ }
286
+ });
287
+ }); });
288
+ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
289
+ var _a, settings, business, requestBody, headers, data;
290
+ var _b, _c, _d;
291
+ return __generator(this, function (_e) {
292
+ switch (_e.label) {
293
+ case 0:
294
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
295
+ requestBody = {
296
+ customers_base: params.customerLocations,
297
+ customers_served_monthly: params.expectedCustomers,
298
+ yearly_sales_range: params.expectedSalesRange,
299
+ agree_refund: params.refundPolicy,
300
+ agree_chargeback: params.transactionPolicy,
301
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
302
+ };
303
+ headers = { entity_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id };
304
+ return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
305
+ case 1:
306
+ data = (_e.sent()).data;
240
307
  if (!data.errors && !params.isResend) {
241
308
  thunkApi.dispatch(handleNextScreenStep());
242
- (_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody);
309
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
243
310
  }
244
311
  return [2, { data: data, formData: __assign({}, params) }];
245
312
  }
246
313
  });
247
314
  }); });
315
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
316
+ var _a, settings, business, headers, payload, data;
317
+ var _b, _c, _d, _e, _f, _g, _h;
318
+ return __generator(this, function (_j) {
319
+ switch (_j.label) {
320
+ case 0:
321
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
322
+ headers = {
323
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
324
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
325
+ };
326
+ payload = {
327
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
328
+ encryption_contract: []
329
+ };
330
+ return [4, API.leadService.updateLead(payload, { headers: headers })];
331
+ case 1:
332
+ data = (_j.sent()).data;
333
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
334
+ (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
335
+ return [2, { response: data, formData: params }];
336
+ }
337
+ });
338
+ }); });
248
339
  var initialState = {
249
340
  error: null,
250
341
  loading: false,
@@ -255,7 +346,8 @@ var initialState = {
255
346
  token: ''
256
347
  },
257
348
  otpData: {
258
- otp: ''
349
+ otp: '',
350
+ isNID: false
259
351
  },
260
352
  nidData: {
261
353
  nid: '',
@@ -278,6 +370,13 @@ var initialState = {
278
370
  activities: [],
279
371
  salesChannels: [],
280
372
  operationStartDate: '1998-08-22'
373
+ },
374
+ customersData: {
375
+ customerLocations: [],
376
+ expectedCustomers: undefined,
377
+ expectedSalesRange: undefined,
378
+ refundPolicy: false,
379
+ transactionPolicy: false
281
380
  }
282
381
  }
283
382
  };
@@ -307,12 +406,10 @@ export var businessSlice = createSlice({
307
406
  state.error = action.error.message;
308
407
  })
309
408
  .addCase(verifyLeadToken.pending, function (state) {
310
- state.loading = true;
311
409
  state.error = null;
312
410
  })
313
411
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
314
412
  var _a;
315
- state.loading = false;
316
413
  state.error = null;
317
414
  var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
318
415
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
@@ -320,11 +417,11 @@ export var businessSlice = createSlice({
320
417
  state.error = description;
321
418
  return;
322
419
  }
323
- state.data.verify.responseBody = leadData;
420
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
324
421
  state.data.verify.token = token;
422
+ state.data.otpData.isNID = false;
325
423
  })
326
424
  .addCase(verifyLeadToken.rejected, function (state, action) {
327
- state.loading = false;
328
425
  state.error = action.error.message;
329
426
  })
330
427
  .addCase(verifyLeadOTP.pending, function (state) {
@@ -364,6 +461,8 @@ export var businessSlice = createSlice({
364
461
  }
365
462
  state.data.nidData = formData;
366
463
  state.data.nidData.responseBody = data;
464
+ state.data.otpData.otp = '';
465
+ state.data.otpData.isNID = true;
367
466
  })
368
467
  .addCase(updateLeadIdentity.rejected, function (state, action) {
369
468
  state.loading = false;
@@ -399,7 +498,7 @@ export var businessSlice = createSlice({
399
498
  var data = action.payload.data;
400
499
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
401
500
  if (!description) {
402
- state.data.flInfos = data;
501
+ state.data.flInfos = data === null || data === void 0 ? void 0 : data.licenses;
403
502
  state.data.businessTypeData.businessType = BusinessType.FL;
404
503
  }
405
504
  })
@@ -412,27 +511,68 @@ export var businessSlice = createSlice({
412
511
  state.error = null;
413
512
  })
414
513
  .addCase(updateLeadBusinessType.fulfilled, function (state, action) {
415
- var _a;
514
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
416
515
  state.loading = false;
417
516
  state.error = null;
418
- var _b = action.payload, data = _b.data, formData = _b.formData;
517
+ var _m = action.payload, data = _m.data, formData = _m.formData;
419
518
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
420
519
  if (description) {
421
520
  state.error = description;
422
521
  return;
423
522
  }
424
523
  state.data.businessTypeData = formData;
425
- state.data.businessTypeData.responseBody = data;
524
+ state.data.businessInfo.brandName = i18n.dir() === 'rtl' ? (_c = (_b = data === null || data === void 0 ? void 0 : data.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.ar : (_e = (_d = data === null || data === void 0 ? void 0 : data.brand) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.en;
525
+ state.data.businessInfo.licenseNumber = (data === null || data === void 0 ? void 0 : data.freelancer_number) || (data === null || data === void 0 ? void 0 : data.cr_number);
526
+ if (formData.businessType === BusinessType.CR) {
527
+ state.data.businessInfo.legalName = (_f = data === null || data === void 0 ? void 0 : data.license) === null || _f === void 0 ? void 0 : _f.crName;
528
+ state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_g = data === null || data === void 0 ? void 0 : data.license) === null || _g === void 0 ? void 0 : _g.issueDate, 'iYYYY/iMM/iDD').format('YYYY-MM-DD'));
529
+ var activities = (_j = (_h = data === null || data === void 0 ? void 0 : data.license) === null || _h === void 0 ? void 0 : _h.activities) === null || _j === void 0 ? void 0 : _j.isic;
530
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
531
+ if (!!selectedActivity)
532
+ state.data.activitiesData.activities = [selectedActivity];
533
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: activities || [] });
534
+ return;
535
+ }
536
+ var category = (_l = (_k = data === null || data === void 0 ? void 0 : data.license) === null || _k === void 0 ? void 0 : _k.License) === null || _l === void 0 ? void 0 : _l.Category;
537
+ if (!!category)
538
+ state.data.activitiesData.activities = [category];
539
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: [category] });
426
540
  })
427
541
  .addCase(updateLeadBusinessType.rejected, function (state, action) {
428
542
  state.loading = false;
429
543
  state.error = action.error.message;
430
544
  })
431
- .addCase(updateEntityInfo.pending, function (state) {
545
+ .addCase(createAccount.pending, function (state) {
546
+ state.loading = true;
547
+ state.error = null;
548
+ })
549
+ .addCase(createAccount.fulfilled, function (state, action) {
550
+ var _a, _b;
551
+ state.error = null;
552
+ var _c = action.payload, data = _c.data, channelsData = _c.channelsData;
553
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = channelsData === null || channelsData === void 0 ? void 0 : channelsData.errors) === null || _b === void 0 ? void 0 : _b[0]) || {}).description;
554
+ if (description) {
555
+ state.error = description;
556
+ return;
557
+ }
558
+ if ((data === null || data === void 0 ? void 0 : data.status) === 'ALREADY_TAKEN') {
559
+ state.error = 'signup_user_exists_error';
560
+ return;
561
+ }
562
+ state.data.businessInfo.responseBody = __assign(__assign({}, data), { channelList: channelsData || [] });
563
+ var selectedChannel = channelsData === null || channelsData === void 0 ? void 0 : channelsData[0];
564
+ if (!!selectedChannel)
565
+ state.data.activitiesData.salesChannels = [selectedChannel];
566
+ })
567
+ .addCase(createAccount.rejected, function (state, action) {
568
+ state.loading = false;
569
+ state.error = action.error.message;
570
+ })
571
+ .addCase(updateActivitiesInfo.pending, function (state) {
432
572
  state.loading = true;
433
573
  state.error = null;
434
574
  })
435
- .addCase(updateEntityInfo.fulfilled, function (state, action) {
575
+ .addCase(updateActivitiesInfo.fulfilled, function (state, action) {
436
576
  var _a;
437
577
  state.error = null;
438
578
  var _b = action.payload, data = _b.data, formData = _b.formData;
@@ -444,7 +584,48 @@ export var businessSlice = createSlice({
444
584
  state.data.activitiesData = formData;
445
585
  state.data.activitiesData.responseBody = data;
446
586
  })
447
- .addCase(updateEntityInfo.rejected, function (state, action) {
587
+ .addCase(updateActivitiesInfo.rejected, function (state, action) {
588
+ state.loading = false;
589
+ state.error = action.error.message;
590
+ })
591
+ .addCase(updateCustomersInfo.pending, function (state) {
592
+ state.loading = true;
593
+ state.error = null;
594
+ })
595
+ .addCase(updateCustomersInfo.fulfilled, function (state, action) {
596
+ var _a;
597
+ state.loading = false;
598
+ state.error = null;
599
+ var _b = action.payload, data = _b.data, formData = _b.formData;
600
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
601
+ if (description) {
602
+ state.error = description;
603
+ return;
604
+ }
605
+ state.data.customersData = formData;
606
+ state.data.customersData.responseBody = data;
607
+ })
608
+ .addCase(updateCustomersInfo.rejected, function (state, action) {
609
+ state.loading = false;
610
+ state.error = action.error.message;
611
+ })
612
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
613
+ var _a;
614
+ state.loading = false;
615
+ state.error = null;
616
+ var response = action.payload.response;
617
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
618
+ if (description) {
619
+ state.error = description;
620
+ return;
621
+ }
622
+ removeRequestHeaders();
623
+ })
624
+ .addCase(updateLeadSuccess.pending, function (state) {
625
+ state.loading = true;
626
+ state.error = null;
627
+ })
628
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
448
629
  state.loading = false;
449
630
  state.error = action.error.message;
450
631
  });
@@ -57,7 +57,7 @@ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
57
57
  export interface ConnectData {
58
58
  countries: Array<CountryCode>;
59
59
  businessCountry: CountryCode;
60
- mobileData: MobileFormValues & ResponseData;
60
+ mobileData: (MobileFormValues | undefined) & ResponseData;
61
61
  nidData: NIDFormValues & ResponseData & {
62
62
  type: string;
63
63
  };
@@ -73,8 +73,14 @@ export interface ConnectState extends SharedState<ConnectData> {
73
73
  export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectState, {
74
74
  clearError: (state: ConnectState) => void;
75
75
  stopLoader: (state: ConnectState) => void;
76
+ resetMobileScreen: (state: ConnectState) => void;
77
+ resetNIDScreen: (state: ConnectState) => void;
78
+ resetOTPScreen: (state: ConnectState) => void;
79
+ resetPasswordScreen: (state: ConnectState) => void;
80
+ resetIndividualScreen: (state: ConnectState) => void;
81
+ resetMerchantScreen: (state: ConnectState) => void;
76
82
  }, "connect/store">;
77
- export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
83
+ export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetOTPScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetIndividualScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetMerchantScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetPasswordScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
78
84
  declare const _default: import("redux").Reducer<ConnectState, import("redux").AnyAction>;
79
85
  export default _default;
80
86
  export declare const connectSelector: (state: RootState) => ConnectState;
@@ -435,6 +435,24 @@ export var connectSlice = createSlice({
435
435
  },
436
436
  stopLoader: function (state) {
437
437
  state.loading = false;
438
+ },
439
+ resetMobileScreen: function (state) {
440
+ state.data.mobileData = __assign(__assign({}, state.data.mobileData), initialState.data.mobileData);
441
+ },
442
+ resetNIDScreen: function (state) {
443
+ state.data.nidData = __assign(__assign({}, state.data.nidData), initialState.data.nidData);
444
+ },
445
+ resetOTPScreen: function (state) {
446
+ state.data.otpData = __assign(__assign(__assign({}, state.data.otpData), initialState.data.otpData), { isAbsher: state.data.otpData.isAbsher });
447
+ },
448
+ resetPasswordScreen: function (state) {
449
+ state.data.passwordData = initialState.data.passwordData;
450
+ },
451
+ resetIndividualScreen: function (state) {
452
+ state.data.individualData = initialState.data.individualData;
453
+ },
454
+ resetMerchantScreen: function (state) {
455
+ state.data.brandData = initialState.data.brandData;
438
456
  }
439
457
  },
440
458
  extraReducers: function (builder) {
@@ -643,6 +661,6 @@ export var connectSlice = createSlice({
643
661
  });
644
662
  }
645
663
  });
646
- export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader;
664
+ export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetMobileScreen = _a.resetMobileScreen, resetOTPScreen = _a.resetOTPScreen, resetIndividualScreen = _a.resetIndividualScreen, resetMerchantScreen = _a.resetMerchantScreen, resetNIDScreen = _a.resetNIDScreen, resetPasswordScreen = _a.resetPasswordScreen;
647
665
  export default connectSlice.reducer;
648
666
  export var connectSelector = function (state) { return state.connect; };
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from 'react';
14
+ import { useSelector } from 'react-redux';
14
15
  import { styled } from '@mui/material/styles';
15
16
  import ActivitiesList from './ActivitiesList';
16
17
  import { useForm, FormProvider } from 'react-hook-form';
@@ -18,36 +19,34 @@ import { useAppDispatch, useLanguage } from '../../../../hooks';
18
19
  import Form from '../../../../components/Form';
19
20
  import { yupResolver } from '@hookform/resolvers/yup';
20
21
  import { useTranslation } from 'react-i18next';
21
- import { ActivitiesValidationSchema } from './validation';
22
22
  import { handlePrevScreenStep } from '../../../../app/settings';
23
- import { ACTIVITIES, SALES_CHANNELS } from '../../../../constants';
24
23
  import Button from '../../../shared/Button';
25
24
  import SalesChannels from './SalesChannels';
26
25
  import { ScreenContainer } from '../../../shared/Containers';
27
26
  import Collapse from '../../../../components/Collapse';
28
27
  import OperationStartDate from './OperationStartDate';
29
- import { updateEntityInfo } from '../../../app/business/businessStore';
28
+ import { businessSelector, updateActivitiesInfo } from '../../../app/business/businessStore';
29
+ import { ActivitiesValidationSchema } from './validation';
30
30
  var FormStyled = styled(Form)(function () { return ({
31
31
  display: 'flex',
32
32
  flexDirection: 'column'
33
33
  }); });
34
34
  var Activities = function () {
35
- var _a = React.useState(false), anchorEl = _a[0], setAnchorEl = _a[1];
36
- var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
35
+ var _a;
36
+ var _b = React.useState(false), anchorEl = _b[0], setAnchorEl = _b[1];
37
+ var _c = React.useState(false), collapse = _c[0], setCollapse = _c[1];
37
38
  var dispatch = useAppDispatch();
38
39
  var isAr = useLanguage().isAr;
39
40
  var t = useTranslation().t;
41
+ var data = useSelector(businessSelector).data;
42
+ var response = data.businessInfo.responseBody;
40
43
  var methods = useForm({
41
44
  resolver: yupResolver(ActivitiesValidationSchema),
42
- defaultValues: {
43
- activities: [ACTIVITIES[0]],
44
- salesChannels: [SALES_CHANNELS[0]],
45
- operationStartDate: '2000-01-01'
46
- },
45
+ defaultValues: data.activitiesData,
47
46
  mode: 'onChange'
48
47
  });
49
48
  var onSubmit = function (data) {
50
- dispatch(updateEntityInfo(__assign(__assign({}, data), { isResend: false })));
49
+ dispatch(updateActivitiesInfo(__assign({}, data)));
51
50
  };
52
51
  var handleCollapseOpenClose = function (flag) {
53
52
  console.log('flag', flag);
@@ -59,6 +58,7 @@ var Activities = function () {
59
58
  var handleMenuClick = function () {
60
59
  anchorEl ? setAnchorEl(false) : setAnchorEl(true);
61
60
  };
62
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [!!ACTIVITIES && (_jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(SalesChannels, {}) }))] })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: !methods.formState.isValid }, { children: t('next') })) }))] })) })) }));
61
+ var activities_list = ((_a = response === null || response === void 0 ? void 0 : response.activities) === null || _a === void 0 ? void 0 : _a.length) > 0;
62
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse }, { children: [!!activities_list && (_jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(SalesChannels, {}) }))] })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: !methods.formState.isValid }, { children: t('next') })) }))] })) })) }));
63
63
  };
64
64
  export default Activities;
@@ -31,6 +31,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
31
  };
32
32
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
33
33
  import * as React from 'react';
34
+ import { useSelector } from 'react-redux';
34
35
  import Box from '@mui/material/Box';
35
36
  import { alpha, styled } from '@mui/material/styles';
36
37
  import Text from '../../../../components/Text';
@@ -38,12 +39,12 @@ import Input from '../../../../components/Input';
38
39
  import { useTranslation } from 'react-i18next';
39
40
  import { useController, useFormContext } from 'react-hook-form';
40
41
  import { useLanguage } from '../../../../hooks';
41
- import { ACTIVITIES } from '../../../../constants';
42
42
  import { BusinessType } from '../../../../@types';
43
43
  import Collapse from '../../../../components/Collapse';
44
44
  import SimpleList from '../../../../components/SimpleList';
45
45
  import ExpandIcon from '../../../../components/ExpandIcon';
46
46
  import { ScreenContainer } from '../../../shared/Containers';
47
+ import { businessSelector } from '../../../app/business/businessStore';
47
48
  import CheckIcon from '@mui/icons-material/Check';
48
49
  import { MandatoryStyled } from './SalesChannels';
49
50
  export var InputLabelStyled = styled(Text)(function (_a) {
@@ -76,15 +77,24 @@ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { r
76
77
  });
77
78
  var ActivitiesList = function (_a) {
78
79
  var rest = __rest(_a, []);
79
- var activitiesMenuList = React.useState(ACTIVITIES)[0];
80
- var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
80
+ var _b = React.useState([]), activitiesMenuList = _b[0], setActivitiesMenuList = _b[1];
81
+ var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
81
82
  var t = useTranslation().t;
82
83
  var isAr = useLanguage().isAr;
83
84
  var control = useFormContext().control;
84
85
  var activitiesControl = useController({ name: 'activities', control: control });
85
86
  var controlValue = activitiesControl.field.value;
86
- var businessType = BusinessType.CR;
87
+ var data = useSelector(businessSelector).data;
88
+ var businessTypeData = data.businessTypeData;
89
+ var response = businessTypeData.responseBody;
90
+ var businessType = businessTypeData.businessType;
87
91
  var isCR = businessType === BusinessType.CR;
92
+ React.useEffect(function () {
93
+ var _a;
94
+ if (((_a = response === null || response === void 0 ? void 0 : response.activities) === null || _a === void 0 ? void 0 : _a.length) > 0) {
95
+ setActivitiesMenuList(response === null || response === void 0 ? void 0 : response.activities);
96
+ }
97
+ }, [response === null || response === void 0 ? void 0 : response.activities]);
88
98
  var onOpenList = function (event) {
89
99
  var _a;
90
100
  setAnchorEl(event.currentTarget);
@@ -20,13 +20,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  };
21
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
22
  import * as React from 'react';
23
+ import { useSelector } from 'react-redux';
23
24
  import Box from '@mui/material/Box';
24
25
  import { alpha, styled } from '@mui/material/styles';
25
26
  import { useTranslation } from 'react-i18next';
26
27
  import { useController, useFormContext } from 'react-hook-form';
27
28
  import { useLanguage } from '../../../../hooks';
28
29
  import Text from '../../../../components/Text';
29
- import { SALES_CHANNELS } from '../../../../constants';
30
+ import { businessSelector } from '../../../app/business/businessStore';
30
31
  import CheckBox from '../../../../components/CheckBox';
31
32
  import Warning from '../../../../components/Warning';
32
33
  import Collapse from '../../../../components/Collapse';
@@ -75,13 +76,21 @@ export var CollapseStyled = styled(Collapse)(function (_a) {
75
76
  });
76
77
  var SalesChannels = function () {
77
78
  var _a;
78
- var channelsMenuList = React.useState(SALES_CHANNELS)[0];
79
+ var _b = React.useState([]), channelsMenuList = _b[0], setChannelsMenuList = _b[1];
79
80
  var t = useTranslation().t;
80
81
  var isAr = useLanguage().isAr;
81
82
  var control = useFormContext().control;
82
83
  var channelsControl = useController({ name: 'salesChannels', control: control });
83
84
  var channelsChecked = channelsControl.field.value;
84
85
  var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
86
+ var data = useSelector(businessSelector).data;
87
+ var response = data.businessInfo.responseBody;
88
+ React.useEffect(function () {
89
+ var _a;
90
+ if (((_a = response === null || response === void 0 ? void 0 : response.channelList) === null || _a === void 0 ? void 0 : _a.length) > 0) {
91
+ setChannelsMenuList(response === null || response === void 0 ? void 0 : response.channelList);
92
+ }
93
+ }, [response === null || response === void 0 ? void 0 : response.channelList]);
85
94
  var handleSalesChannelChange = function (event, checked) {
86
95
  var selected = channelsMenuList.find(function (channel) { return channel.id.toString() === event.target.id; });
87
96
  var isExists = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (selected === null || selected === void 0 ? void 0 : selected.id); });