@tap-payments/auth-jsconnect 2.0.43 → 2.0.44

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 (32) hide show
  1. package/build/features/app/business/businessStore.d.ts +2 -11
  2. package/build/features/app/business/businessStore.js +168 -156
  3. package/build/features/app/connect/connectStore.js +4 -4
  4. package/build/features/app/entity/entityStore.js +6 -4
  5. package/build/features/app/individual/individualStore.js +14 -0
  6. package/build/features/bank/screens/BankDetails/IBAN.js +1 -4
  7. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  8. package/build/features/business/screens/Activities/validation.js +1 -4
  9. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  10. package/build/features/connect/screens/Individual/Individual.js +4 -0
  11. package/build/features/connect/screens/Merchant/Merchant.js +4 -10
  12. package/build/features/connect/screens/Merchant/SalesChannels.d.ts +1 -2
  13. package/build/features/connect/screens/Merchant/SalesChannels.js +6 -4
  14. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +1 -3
  15. package/build/features/connect/screens/Merchant/SocialMedia.js +33 -7
  16. package/build/features/connect/screens/Merchant/validation.js +5 -3
  17. package/build/features/connect/screens/ThankYou/ThankYou.js +2 -8
  18. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  19. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  20. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  21. package/build/features/shared/Button/Button.js +0 -1
  22. package/build/features/shared/SuccessScreen/SuccessScreen.d.ts +1 -1
  23. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  24. package/build/utils/array.d.ts +0 -1
  25. package/build/utils/array.js +0 -8
  26. package/build/utils/index.d.ts +0 -1
  27. package/build/utils/index.js +0 -1
  28. package/build/utils/string.d.ts +0 -1
  29. package/build/utils/string.js +2 -14
  30. package/package.json +1 -1
  31. package/build/utils/date.d.ts +0 -1
  32. package/build/utils/date.js +0 -5
@@ -4,16 +4,8 @@ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  data: any;
5
5
  leadData: any;
6
6
  token: string;
7
- brandData: any;
7
+ brandInfo: any;
8
8
  boardId: any;
9
- isRequireOTP?: undefined;
10
- } | {
11
- data: any;
12
- isRequireOTP: boolean;
13
- leadData?: undefined;
14
- token?: undefined;
15
- brandData?: undefined;
16
- boardId?: undefined;
17
9
  }, string, {}>;
18
10
  export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<{
19
11
  data: any;
@@ -24,7 +16,7 @@ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
24
16
  isNID: boolean;
25
17
  otp: string;
26
18
  };
27
- brand: any;
19
+ brandInfo: any;
28
20
  leadData: any;
29
21
  }, OTPFormValues, {}>;
30
22
  interface verifyPACIParams {
@@ -76,7 +68,6 @@ export declare const retrieveDataList: import("@reduxjs/toolkit").AsyncThunk<{
76
68
  customerBases: any;
77
69
  expectedSales: any;
78
70
  expectedCustomerSales: any;
79
- countryISO2: string;
80
71
  }, void, {}>;
81
72
  export declare const updateCustomersInfo: import("@reduxjs/toolkit").AsyncThunk<{
82
73
  data: any;
@@ -60,13 +60,13 @@ import moment from 'moment';
60
60
  import API from '../../../api';
61
61
  import { BusinessType, FlowsTypes } from '../../../@types';
62
62
  import { BUSINESS_FLOW_SUCCESS, BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
63
- import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW, isSA, dateFormat } from '../../../utils';
63
+ import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW, isSA } from '../../../utils';
64
64
  import { handleNextScreenStep, handleSetCountryByIso2 } 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, countryIso2, boardData, brandData, leadData, entity_activities, steps, brand, board_id, board_info_id, brandID, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted, activityList;
67
- var _a;
68
- return __generator(this, function (_b) {
69
- switch (_b.label) {
66
+ var payload, data, leadResponse, brandInfo, boardResponse, countryIso2, steps, brandID, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted, entity_activities, data_1, board_id, board_info_id;
67
+ var _a, _b, _c, _d, _e, _f, _g;
68
+ return __generator(this, function (_h) {
69
+ switch (_h.label) {
70
70
  case 0:
71
71
  payload = {
72
72
  service_name: 'tap_email',
@@ -74,100 +74,101 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
74
74
  };
75
75
  return [4, API.leadService.verifyLeadToken(payload)];
76
76
  case 1:
77
- data = (_b.sent()).data;
78
- if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
79
- throw new Error(data.errors[0].description);
80
- if (data.mw_error)
81
- throw new Error(data.mw_error);
82
- countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
83
- if (countryIso2)
77
+ data = (_h.sent()).data;
78
+ leadResponse = undefined;
79
+ brandInfo = undefined;
80
+ boardResponse = undefined;
81
+ countryIso2 = undefined;
82
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 18];
83
+ if (data === null || data === void 0 ? void 0 : data.country_code) {
84
+ countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
84
85
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
85
- if (!(data.step_name !== BUSINESS_STEP_NAMES.PHONE_AUTH)) return [3, 20];
86
- boardData = undefined;
87
- brandData = undefined;
86
+ }
87
+ if (!(data.step_name !== BUSINESS_STEP_NAMES.PHONE_AUTH)) return [3, 18];
88
88
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
89
89
  case 2:
90
- leadData = (_b.sent()).data;
91
- countryIso2 = leadData === null || leadData === void 0 ? void 0 : leadData.country_code;
92
- if (!countryIso2)
93
- thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
90
+ leadResponse = _h.sent();
91
+ if (!countryIso2) {
92
+ countryIso2 = (_a = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _a === void 0 ? void 0 : _a.country_code;
93
+ if (countryIso2)
94
+ thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
95
+ }
94
96
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH && isKW(countryIso2)) {
95
97
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_CIVIL_ID_STEP'));
96
98
  }
97
99
  if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH && !isKW(countryIso2)) {
98
100
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
99
101
  }
100
- if (!(data.step_name === BUSINESS_STEP_NAMES.BUSINESS_INFO)) return [3, 19];
101
- entity_activities = leadData.entity_activities, steps = leadData.steps, brand = leadData.brand, board_id = leadData.board_id, board_info_id = leadData.board_info_id;
102
- brandID = brand === null || brand === void 0 ? void 0 : brand.id;
102
+ if (!(data.step_name === 'business_info')) return [3, 18];
103
+ steps = (_b = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _b === void 0 ? void 0 : _b.steps;
104
+ brandID = (_d = (_c = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _c === void 0 ? void 0 : _c.brand) === null || _d === void 0 ? void 0 : _d.id;
103
105
  hasBusinessCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_SUCCESS);
104
- hasBusinessCRInfoCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_INFO) && hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM);
106
+ hasBusinessCRInfoCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_INFO) &&
107
+ hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM);
105
108
  hasBusinessCRActivitiesCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES);
106
109
  hasBusinessCustomersCompleted = hasKey(steps, BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS);
110
+ entity_activities = leadResponse.data.entity_activities;
107
111
  if (!(!entity_activities && hasBusinessCRInfoCompleted)) return [3, 4];
108
112
  return [4, API.dataService.getActivities()];
109
113
  case 3:
110
- activityList = (_b.sent()).list;
111
- leadData = __assign(__assign({}, leadData), { entity_activities: activityList });
112
- _b.label = 4;
114
+ data_1 = _h.sent();
115
+ leadResponse.data = __assign(__assign({}, leadResponse.data), { entity_activities: data_1.list });
116
+ _h.label = 4;
113
117
  case 4:
114
- if (!hasBusinessCompleted) return [3, 9];
115
- if (!(board_id && board_info_id)) return [3, 6];
118
+ if (!hasBusinessCompleted) return [3, 8];
119
+ board_id = (_e = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _e === void 0 ? void 0 : _e.board_id;
120
+ board_info_id = (_f = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _f === void 0 ? void 0 : _f.board_info_id;
121
+ if (!(!!board_id && !!board_info_id)) return [3, 6];
116
122
  return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
117
123
  case 5:
118
- boardData = _b.sent();
119
- _b.label = 6;
120
- case 6:
121
- if (!board_id) return [3, 8];
122
- return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
124
+ boardResponse = _h.sent();
125
+ _h.label = 6;
126
+ case 6: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
123
127
  case 7:
124
- _b.sent();
125
- _b.label = 8;
126
- case 8:
128
+ _h.sent();
127
129
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
128
- return [3, 19];
129
- case 9:
130
- if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 10];
130
+ return [3, 18];
131
+ case 8:
132
+ if (!(data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH)) return [3, 9];
131
133
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
132
- return [3, 19];
133
- case 10:
134
- if (!hasBusinessCustomersCompleted) return [3, 11];
134
+ return [3, 18];
135
+ case 9:
136
+ if (!hasBusinessCustomersCompleted) return [3, 10];
135
137
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_SUCCESS_STEP'));
136
- return [3, 19];
137
- case 11:
138
- if (!hasBusinessCRActivitiesCompleted) return [3, 14];
138
+ return [3, 18];
139
+ case 10:
140
+ if (!hasBusinessCRActivitiesCompleted) return [3, 13];
139
141
  return [4, thunkApi.dispatch(retrieveDataList())];
140
- case 12:
141
- _b.sent();
142
+ case 11:
143
+ _h.sent();
142
144
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_CUSTOMERS_STEP'));
143
145
  return [4, API.brandService.retrieveBrand(brandID)];
146
+ case 12:
147
+ brandInfo = _h.sent();
148
+ return [3, 18];
144
149
  case 13:
145
- brandData = _b.sent();
146
- return [3, 19];
147
- case 14:
148
- if (!hasBusinessCRInfoCompleted) return [3, 16];
150
+ if (!hasBusinessCRInfoCompleted) return [3, 15];
149
151
  return [4, API.brandService.retrieveBrand(brandID)];
150
- case 15:
151
- brandData = _b.sent();
152
+ case 14:
153
+ brandInfo = _h.sent();
152
154
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_ACTIVITIES_STEP'));
153
- return [3, 19];
154
- case 16:
155
- if (!isSA(countryIso2)) return [3, 18];
155
+ return [3, 18];
156
+ case 15:
157
+ if (!isSA(countryIso2)) return [3, 17];
156
158
  return [4, thunkApi.dispatch(retrieveEntityList({ leadId: data === null || data === void 0 ? void 0 : data.id }))];
159
+ case 16:
160
+ _h.sent();
161
+ _h.label = 17;
157
162
  case 17:
158
- _b.sent();
159
- _b.label = 18;
160
- case 18:
161
163
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
162
- _b.label = 19;
163
- case 19: return [2, {
164
+ _h.label = 18;
165
+ case 18: return [2, {
164
166
  data: data,
165
- leadData: __assign(__assign({}, leadData), { flows: BUSINESS_FLOW_SUCCESS.concat((boardData === null || boardData === void 0 ? void 0 : boardData.info) || []) }),
167
+ leadData: __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat((boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) || []) }),
166
168
  token: token,
167
- brandData: brandData,
168
- boardId: leadData === null || leadData === void 0 ? void 0 : leadData.board_id
169
+ brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand,
170
+ boardId: (_g = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _g === void 0 ? void 0 : _g.board_id
169
171
  }];
170
- case 20: return [2, { data: data, isRequireOTP: true }];
171
172
  }
172
173
  });
173
174
  }); });
@@ -189,8 +190,8 @@ export var resendOTP = createAsyncThunk('resendOTPBusiness', function (params, t
189
190
  });
190
191
  }); });
191
192
  export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
192
- var _a, business, settings, isNID, responseBody, stepName, payload, data, brandData, leadData, brand, country_code, steps, board_id, board_info_id, brandID, countryIso2, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted, isIdentityAuthStep, entity_activities, activityList, boardResponse;
193
- var _b, _c, _d, _e, _f, _g, _h;
193
+ var _a, business, settings, isNID, responseBody, stepName, payload, data, brandInfo, leadResponse, _b, brand, country_code, steps, board_id, board_info_id, brandID, countryIso2, hasBusinessCompleted, hasBusinessCRInfoCompleted, hasBusinessCRActivitiesCompleted, hasBusinessCustomersCompleted, isIdentityAuthStep, entity_activities, data_2, boardResponse;
194
+ var _c, _d, _e, _f, _g, _h;
194
195
  return __generator(this, function (_j) {
195
196
  switch (_j.label) {
196
197
  case 0:
@@ -200,22 +201,22 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
200
201
  stepName = isNID ? BUSINESS_STEP_NAMES.IDENTITY_VERIFY_AUTH : BUSINESS_STEP_NAMES.PHONE_AUTH;
201
202
  payload = {
202
203
  data: params.otp,
203
- service_name: ((_c = (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_token) === null || _b === void 0 ? void 0 : _b.verification_by) === null || _c === void 0 ? void 0 : _c.service_name) || ((_d = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _d === void 0 ? void 0 : _d.service_name),
204
- verify_token: ((_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_token) === null || _e === void 0 ? void 0 : _e.verify_token) || (responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token),
204
+ service_name: ((_d = (_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_token) === null || _c === void 0 ? void 0 : _c.verification_by) === null || _d === void 0 ? void 0 : _d.service_name) || ((_e = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _e === void 0 ? void 0 : _e.service_name),
205
+ verify_token: ((_f = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_token) === null || _f === void 0 ? void 0 : _f.verify_token) || (responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token),
205
206
  step_name: stepName,
206
207
  encryption_contract: ['data']
207
208
  };
208
209
  return [4, API.leadService.verifyLeadOTP(payload)];
209
210
  case 1:
210
211
  data = (_j.sent()).data;
211
- if ((_f = data.errors) === null || _f === void 0 ? void 0 : _f.length)
212
- throw new Error(data.errors[0].description);
213
- brandData = undefined;
212
+ brandInfo = undefined;
213
+ leadResponse = undefined;
214
+ if (!!data.errors) return [3, 20];
214
215
  return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
215
216
  case 2:
216
- leadData = (_j.sent()).data;
217
+ leadResponse = _j.sent();
217
218
  thunkApi.dispatch(updateStepName(stepName));
218
- brand = leadData.brand, country_code = leadData.country_code, steps = leadData.steps, board_id = leadData.board_id, board_info_id = leadData.board_info_id;
219
+ _b = (leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) || {}, brand = _b.brand, country_code = _b.country_code, steps = _b.steps, board_id = _b.board_id, board_info_id = _b.board_info_id;
219
220
  brandID = brand === null || brand === void 0 ? void 0 : brand.id;
220
221
  countryIso2 = country_code;
221
222
  if (countryIso2)
@@ -232,12 +233,12 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
232
233
  _j.sent();
233
234
  _j.label = 4;
234
235
  case 4:
235
- entity_activities = leadData.entity_activities;
236
+ entity_activities = ((leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) || {}).entity_activities;
236
237
  if (!(!entity_activities && hasBusinessCRInfoCompleted)) return [3, 6];
237
238
  return [4, API.dataService.getActivities()];
238
239
  case 5:
239
- activityList = (_j.sent()).list;
240
- leadData = __assign(__assign({}, leadData), { entity_activities: activityList });
240
+ data_2 = _j.sent();
241
+ leadResponse.data = __assign(__assign({}, leadResponse.data), { entity_activities: data_2.list });
241
242
  _j.label = 6;
242
243
  case 6:
243
244
  if (!isNID) return [3, 7];
@@ -249,11 +250,11 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
249
250
  return [3, 20];
250
251
  case 8:
251
252
  if (!hasBusinessCompleted) return [3, 12];
252
- if (!(board_id && board_info_id)) return [3, 10];
253
+ if (!(!!board_id && !!board_info_id)) return [3, 10];
253
254
  return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
254
255
  case 9:
255
256
  boardResponse = _j.sent();
256
- leadData = __assign(__assign({}, leadData), { flows: BUSINESS_FLOW_SUCCESS.concat((boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) || []) });
257
+ leadResponse.data = __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat((boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) || []) });
257
258
  _j.label = 10;
258
259
  case 10: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
259
260
  case 11:
@@ -276,19 +277,19 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
276
277
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_CUSTOMERS_STEP'));
277
278
  return [4, API.brandService.retrieveBrand(brandID)];
278
279
  case 16:
279
- brandData = _j.sent();
280
+ brandInfo = _j.sent();
280
281
  return [3, 20];
281
282
  case 17:
282
283
  if (!hasBusinessCRInfoCompleted) return [3, 19];
283
284
  return [4, API.brandService.retrieveBrand(brandID)];
284
285
  case 18:
285
- brandData = _j.sent();
286
+ brandInfo = _j.sent();
286
287
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_ACTIVITIES_STEP'));
287
288
  return [3, 20];
288
289
  case 19:
289
290
  thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
290
291
  _j.label = 20;
291
- case 20: return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }), brand: brandData === null || brandData === void 0 ? void 0 : brandData.brand, leadData: leadData }];
292
+ case 20: return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }), brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data }];
292
293
  }
293
294
  });
294
295
  }); });
@@ -572,18 +573,17 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
572
573
  });
573
574
  }); });
574
575
  export var retrieveDataList = createAsyncThunk('businessRetrieveDataList', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
575
- var settings, countryISO2, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
576
+ var settings, dataBody, salesDataBody, _a, customerBases, expectedSales, expectedCustomerSales;
576
577
  return __generator(this, function (_b) {
577
578
  switch (_b.label) {
578
579
  case 0:
579
580
  settings = thunkApi.getState().settings;
580
- countryISO2 = settings.data.businessCountry.iso2;
581
581
  dataBody = {
582
582
  page: 0
583
583
  };
584
584
  salesDataBody = {
585
585
  page: 0,
586
- country_code: [countryISO2]
586
+ country_code: [settings.data.businessCountry.iso2]
587
587
  };
588
588
  return [4, Promise.all([
589
589
  API.dataService.getCustomerBases(dataBody),
@@ -591,12 +591,11 @@ export var retrieveDataList = createAsyncThunk('businessRetrieveDataList', funct
591
591
  API.dataService.getExpectedCustomerSales(dataBody)
592
592
  ])];
593
593
  case 1:
594
- _a = _b.sent(), customerBases = _a[0].list, expectedSales = _a[1].list, expectedCustomerSales = _a[2].list;
594
+ _a = _b.sent(), customerBases = _a[0], expectedSales = _a[1], expectedCustomerSales = _a[2];
595
595
  return [2, {
596
596
  customerBases: customerBases,
597
597
  expectedSales: expectedSales,
598
- expectedCustomerSales: expectedCustomerSales,
599
- countryISO2: countryISO2
598
+ expectedCustomerSales: expectedCustomerSales
600
599
  }];
601
600
  }
602
601
  });
@@ -724,7 +723,7 @@ var initialState = {
724
723
  },
725
724
  activitiesData: {
726
725
  activities: [],
727
- operationStartDate: moment(new Date()).format('YYYY-MM-DD')
726
+ operationStartDate: new Date().toString()
728
727
  },
729
728
  customersData: {
730
729
  customerLocations: [],
@@ -756,46 +755,49 @@ export var businessSlice = createSlice({
756
755
  state.customLoading = true;
757
756
  })
758
757
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
759
- var _a, _b;
758
+ var _a, _b, _c, _d;
760
759
  state.error = null;
761
760
  state.customLoading = false;
762
- var _c = action.payload, data = _c.data, boardId = _c.boardId, brandData = _c.brandData, leadData = _c.leadData, token = _c.token, isRequireOTP = _c.isRequireOTP;
763
- var responseBody = state.data.verify.responseBody;
764
- state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), leadData), responseBody), { board_id: boardId, lead_id: data === null || data === void 0 ? void 0 : data.id });
765
- if (token)
766
- state.data.verify.token = token;
767
- state.data.otpData.isNID = false;
768
- if (isRequireOTP)
761
+ var _e = action.payload, data = _e.data, token = _e.token, leadData = _e.leadData, brandInfo = _e.brandInfo, boardId = _e.boardId;
762
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
763
+ if (description) {
764
+ state.error = description;
769
765
  return;
770
- var _d = state.data.verify.responseBody || {}, entity = _d.entity, entity_activities = _d.entity_activities, business_type = _d.business_type, business_name = _d.business_name;
771
- var issuingDate = (brandData === null || brandData === void 0 ? void 0 : brandData.business_operation_start_at) || ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.issuing_date);
772
- if (issuingDate)
773
- state.data.activitiesData.operationStartDate = convertNumbers2English(dateFormat(issuingDate));
766
+ }
767
+ state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), leadData), state.data.verify.responseBody), { board_id: boardId, lead_id: data === null || data === void 0 ? void 0 : data.id });
768
+ state.data.verify.token = token;
769
+ state.data.otpData.isNID = false;
770
+ var _f = state.data.verify.responseBody || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type, business_name = _f.business_name;
771
+ var issuingDate = (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at)
772
+ ? brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at
773
+ : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
774
+ if (!!issuingDate) {
775
+ var formattedDate = moment(issuingDate).format('YYYY-MM-DD');
776
+ state.data.activitiesData.operationStartDate = convertNumbers2English(formattedDate);
777
+ }
774
778
  var activities = entity_activities || [];
775
779
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
776
- var activities = brandData.activities;
777
- return activities === null || activities === void 0 ? void 0 : activities.find(function (value) { return activity.id === value.id; });
780
+ var _a;
781
+ return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return activity.id === value.id; });
778
782
  });
779
- state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [];
783
+ var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities.length) ? [activities[0]] : [];
784
+ state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities;
780
785
  state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
781
786
  state.data.businessTypeData.entityLegalName = (business_name === null || business_name === void 0 ? void 0 : business_name.en) || '';
782
- var license = (entity || {}).license;
783
- if (license) {
784
- var number_1 = license.number;
785
- var _e = state.data.businessTypeData || {}, busResData = _e.responseBody, selectedLicense = _e.selectedLicense;
786
- var licenseList = (busResData || {}).licenseList;
787
+ if (!!(entity === null || entity === void 0 ? void 0 : entity.license)) {
788
+ var licenseNumber_1 = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.number;
789
+ var _g = state.data.businessTypeData || {}, responseBody = _g.responseBody, selectedLicense = _g.selectedLicense;
790
+ var licenseList = (responseBody || {}).licenseList;
787
791
  var selectedLicenseData = selectedLicense;
788
- if (number_1) {
789
- var findFL = (_b = licenseList === null || licenseList === void 0 ? void 0 : licenseList.find) === null || _b === void 0 ? void 0 : _b.call(licenseList, function (_a) {
790
- var license = _a.license;
791
- return (license === null || license === void 0 ? void 0 : license.number) === number_1;
792
- });
793
- if (findFL || business_type === BusinessType.FL) {
794
- selectedLicenseData = __assign(__assign({}, OTHER_FL_LICENSE), { license: { number: number_1 } });
795
- }
796
- else
797
- selectedLicenseData = __assign(__assign({}, OTHER_CR_LICENSE), { license: { number: number_1 } });
798
- state.data.businessTypeData.licenseNumber = number_1;
792
+ if (!!licenseNumber_1) {
793
+ selectedLicenseData =
794
+ ((_d = licenseList === null || licenseList === void 0 ? void 0 : licenseList.find) === null || _d === void 0 ? void 0 : _d.call(licenseList, function (_a) {
795
+ var license = _a.license;
796
+ return (license === null || license === void 0 ? void 0 : license.number) === licenseNumber_1;
797
+ })) ||
798
+ business_type === BusinessType.FL
799
+ ? __assign(__assign({}, OTHER_FL_LICENSE), { license: { number: licenseNumber_1 } }) : __assign(__assign({}, OTHER_CR_LICENSE), { license: { number: licenseNumber_1 } });
800
+ state.data.businessTypeData.licenseNumber = licenseNumber_1 || '';
799
801
  }
800
802
  state.data.businessTypeData.selectedLicense = __assign(__assign({}, selectedLicenseData), { type: business_type });
801
803
  }
@@ -826,42 +828,49 @@ export var businessSlice = createSlice({
826
828
  state.error = null;
827
829
  })
828
830
  .addCase(verifyLeadOTP.fulfilled, function (state, action) {
829
- var _a, _b;
831
+ var _a, _b, _c, _d;
830
832
  state.loading = false;
831
833
  state.error = null;
832
- var _c = action.payload, data = _c.data, formData = _c.formData, brand = _c.brand, leadData = _c.leadData;
834
+ var _e = action.payload, data = _e.data, formData = _e.formData, brandInfo = _e.brandInfo, leadData = _e.leadData;
835
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
836
+ if (description) {
837
+ state.error = description;
838
+ return;
839
+ }
833
840
  state.data.otpData = formData;
834
841
  state.data.otpData.responseBody = data;
835
- state.data.verify.responseBody = __assign(__assign(__assign({}, leadData), state.data.verify.responseBody), { flows: (leadData === null || leadData === void 0 ? void 0 : leadData.flows) || [] });
836
- var _d = leadData || {}, entity = _d.entity, entity_activities = _d.entity_activities, business_type = _d.business_type, business_name = _d.business_name;
837
- var issuingDate = (brand === null || brand === void 0 ? void 0 : brand.business_operation_start_at) || ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.issuing_date);
838
- if (issuingDate)
839
- state.data.activitiesData.operationStartDate = convertNumbers2English(dateFormat(issuingDate));
842
+ state.data.verify.responseBody = __assign(__assign(__assign({}, leadData), state.data.verify.responseBody), { flows: leadData === null || leadData === void 0 ? void 0 : leadData.flows });
843
+ var _f = leadData || {}, entity = _f.entity, entity_activities = _f.entity_activities, business_type = _f.business_type, business_name = _f.business_name;
844
+ var issuingDate = (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at)
845
+ ? brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.business_operation_start_at
846
+ : (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.issuing_date;
847
+ if (!!issuingDate) {
848
+ var formattedDate = moment(issuingDate).format('YYYY-MM-DD');
849
+ state.data.activitiesData.operationStartDate = convertNumbers2English(formattedDate);
850
+ }
840
851
  var activities = entity_activities || [];
841
852
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
842
- var activities = brand.activities;
843
- return activities === null || activities === void 0 ? void 0 : activities.find(function (value) { return value.id === activity.id; });
853
+ var _a;
854
+ return (_a = brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === activity.id; });
844
855
  });
845
- state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [];
856
+ var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities[0]) ? [activities === null || activities === void 0 ? void 0 : activities[0]] : [];
857
+ state.data.activitiesData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities;
846
858
  state.data.businessTypeData.responseBody = __assign(__assign({}, state.data.businessTypeData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities });
847
859
  state.data.businessTypeData.entityLegalName = (business_name === null || business_name === void 0 ? void 0 : business_name.en) || '';
848
- var license = (entity || {}).license;
849
- if (license) {
850
- var number_2 = license.number;
851
- var _e = state.data.businessTypeData || {}, busResData = _e.responseBody, selectedLicense = _e.selectedLicense;
852
- var licenseList = (busResData || {}).licenseList;
860
+ if (!!(entity === null || entity === void 0 ? void 0 : entity.license)) {
861
+ var licenseNumber_2 = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.number;
862
+ var _g = state.data.businessTypeData || {}, responseBody = _g.responseBody, selectedLicense = _g.selectedLicense;
863
+ var licenseList = (responseBody || {}).licenseList;
853
864
  var selectedLicenseData = selectedLicense;
854
- if (number_2) {
855
- var findFL = (_b = licenseList === null || licenseList === void 0 ? void 0 : licenseList.find) === null || _b === void 0 ? void 0 : _b.call(licenseList, function (_a) {
856
- var license = _a.license;
857
- return (license === null || license === void 0 ? void 0 : license.number) === number_2;
858
- });
859
- if (findFL || business_type === BusinessType.FL) {
860
- selectedLicenseData = __assign(__assign({}, OTHER_FL_LICENSE), { license: { number: number_2 } });
861
- }
862
- else
863
- selectedLicenseData = __assign(__assign({}, OTHER_CR_LICENSE), { license: { number: number_2 } });
864
- state.data.businessTypeData.licenseNumber = number_2;
865
+ if (!!licenseNumber_2) {
866
+ selectedLicenseData =
867
+ ((_d = licenseList === null || licenseList === void 0 ? void 0 : licenseList.find) === null || _d === void 0 ? void 0 : _d.call(licenseList, function (_a) {
868
+ var license = _a.license;
869
+ return (license === null || license === void 0 ? void 0 : license.number) === licenseNumber_2;
870
+ })) ||
871
+ business_type === BusinessType.FL
872
+ ? __assign(__assign({}, OTHER_FL_LICENSE), { license: { number: licenseNumber_2 } }) : __assign(__assign({}, OTHER_CR_LICENSE), { license: { number: licenseNumber_2 } });
873
+ state.data.businessTypeData.licenseNumber = licenseNumber_2 || '';
865
874
  }
866
875
  state.data.businessTypeData.selectedLicense = __assign(__assign({}, selectedLicenseData), { type: business_type });
867
876
  }
@@ -1020,6 +1029,9 @@ export var businessSlice = createSlice({
1020
1029
  state.data.activitiesData.operationStartDate = convertNumbers2English(formattedDate);
1021
1030
  }
1022
1031
  var activities = entity_activities || [];
1032
+ var selectedActivity = activities[0];
1033
+ if (!!selectedActivity)
1034
+ state.data.activitiesData.activities = [selectedActivity];
1023
1035
  state.data.businessTypeData.responseBody = __assign(__assign(__assign(__assign(__assign({}, data), state.data.businessTypeData.responseBody), { activities: activities }), accountData), documentData);
1024
1036
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { entity: entity });
1025
1037
  })
@@ -1061,19 +1073,19 @@ export var businessSlice = createSlice({
1061
1073
  state.error = null;
1062
1074
  })
1063
1075
  .addCase(retrieveDataList.fulfilled, function (state, action) {
1064
- var _a, _b;
1076
+ var _a, _b, _c, _d, _e;
1065
1077
  state.loading = false;
1066
1078
  state.error = null;
1067
- var _c = action.payload, customerBases = _c.customerBases, expectedSales = _c.expectedSales, expectedCustomerSales = _c.expectedCustomerSales, countryISO2 = _c.countryISO2;
1068
- var regional = customerBases.at(1);
1069
- var local = customerBases.at(0);
1070
- var expectedSale = (_b = (_a = expectedSales.at(0)) === null || _a === void 0 ? void 0 : _a.sub) === null || _b === void 0 ? void 0 : _b.at(4);
1071
- var expectedCustomerSale = expectedCustomerSales.at(3);
1079
+ var payload = action.payload;
1080
+ var customerBases = ((_a = payload.customerBases) === null || _a === void 0 ? void 0 : _a.list) || [];
1081
+ var customerBase = customerBases === null || customerBases === void 0 ? void 0 : customerBases[1];
1082
+ var expectedSales = ((_b = payload.expectedSales) === null || _b === void 0 ? void 0 : _b.list) || [];
1083
+ var expectedSale = (_d = (_c = expectedSales === null || expectedSales === void 0 ? void 0 : expectedSales[0]) === null || _c === void 0 ? void 0 : _c.sub) === null || _d === void 0 ? void 0 : _d[4];
1084
+ var expectedCustomerSales = ((_e = payload.expectedCustomerSales) === null || _e === void 0 ? void 0 : _e.list) || [];
1085
+ var expectedCustomerSale = expectedCustomerSales === null || expectedCustomerSales === void 0 ? void 0 : expectedCustomerSales[3];
1072
1086
  state.data.activitiesData.responseBody = __assign(__assign({}, state.data.activitiesData.responseBody), { customerBases: customerBases, expectedSales: expectedSales, expectedCustomerSales: expectedCustomerSales });
1073
- if (local && isKW(countryISO2))
1074
- state.data.customersData.customerLocations = [local];
1075
- if (regional && local && isSA(countryISO2))
1076
- state.data.customersData.customerLocations = [regional, local];
1087
+ if (!!customerBase)
1088
+ state.data.customersData.customerLocations = [customerBase, customerBases[0]];
1077
1089
  if (!!expectedSale)
1078
1090
  state.data.customersData.expectedSale = expectedSale;
1079
1091
  if (!!expectedCustomerSale)
@@ -226,7 +226,7 @@ export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thu
226
226
  });
227
227
  }); });
228
228
  export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
229
- var _a, connect, settings, startWithNID, _b, mobileData, nidData, responseBody, stepName, payload, data, lead_id, individual_id, leadBody, leadResponse, _c, isNewUser, channels, brands, err_1, countryCode, contact, name, _d, phone, email, userInfoMissed;
229
+ var _a, connect, settings, startWithNID, _b, mobileData, nidData, responseBody, stepName, payload, data, lead_id, individual_id, leadBody, leadResponse, _c, isNewUser, channels, brands, err_1, contact, name, _d, phone, email, userInfoMissed, countryCode;
230
230
  var _e, _f, _g, _h;
231
231
  return __generator(this, function (_j) {
232
232
  switch (_j.label) {
@@ -289,10 +289,10 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
289
289
  err_1 = _j.sent();
290
290
  return [3, 10];
291
291
  case 10:
292
- countryCode = settings.data.businessCountry;
293
292
  contact = leadResponse.contact, name = leadResponse.name;
294
293
  _d = contact || {}, phone = _d.phone, email = _d.email;
295
294
  userInfoMissed = (!phone || !email || !name) && !isNewUser;
295
+ countryCode = settings.data.businessCountry;
296
296
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
297
297
  countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
298
298
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
@@ -306,7 +306,7 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
306
306
  });
307
307
  }); });
308
308
  export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
309
- var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, individual_id, leadBody, leadResponse, _b, isNewUser, countryCode, contact, name_1, _c, phone, email, userInfoMissed, channels, brands, err_2;
309
+ var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, individual_id, leadBody, leadResponse, _b, isNewUser, contact, name_1, _c, phone, email, userInfoMissed, channels, brands, err_2, countryCode;
310
310
  var _d, _e, _f, _g, _h;
311
311
  return __generator(this, function (_j) {
312
312
  switch (_j.label) {
@@ -350,7 +350,6 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
350
350
  if ((_f = leadResponse.errors) === null || _f === void 0 ? void 0 : _f.length)
351
351
  throw new Error(leadResponse.errors[0].description);
352
352
  isNewUser = leadResponse.is_new_individual;
353
- countryCode = settings.data.businessCountry;
354
353
  contact = leadResponse.contact, name_1 = leadResponse.name;
355
354
  _c = contact || {}, phone = _c.phone, email = _c.email;
356
355
  userInfoMissed = (!phone || !email || !name_1) && !isNewUser;
@@ -371,6 +370,7 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
371
370
  err_2 = _j.sent();
372
371
  return [3, 12];
373
372
  case 12:
373
+ countryCode = settings.data.businessCountry;
374
374
  if (phone === null || phone === void 0 ? void 0 : phone.country_code)
375
375
  countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
376
376
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, {});