@tap-payments/auth-jsconnect 1.0.31 → 1.0.34

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 (70) hide show
  1. package/build/@types/app.d.ts +5 -1
  2. package/build/@types/form.d.ts +23 -1
  3. package/build/api/account.d.ts +15 -0
  4. package/build/api/account.js +9 -0
  5. package/build/api/axios.d.ts +2 -0
  6. package/build/api/axios.js +10 -0
  7. package/build/api/data.d.ts +6 -0
  8. package/build/api/data.js +17 -0
  9. package/build/api/entity.d.ts +20 -0
  10. package/build/api/entity.js +9 -0
  11. package/build/api/index.d.ts +22 -2
  12. package/build/api/index.js +9 -1
  13. package/build/api/lead.d.ts +22 -0
  14. package/build/api/lead.js +21 -1
  15. package/build/app/settings.js +12 -18
  16. package/build/components/Input/Input.d.ts +1 -1
  17. package/build/components/Input/Input.js +3 -2
  18. package/build/components/Slide/Slide.d.ts +1 -1
  19. package/build/components/Warning/Warning.d.ts +1 -1
  20. package/build/components/Warning/Warning.js +13 -2
  21. package/build/constants/api.d.ts +8 -0
  22. package/build/constants/api.js +17 -1
  23. package/build/constants/app.d.ts +11 -1
  24. package/build/constants/app.js +11 -1
  25. package/build/constants/assets.js +1 -1
  26. package/build/constants/validation.d.ts +1 -0
  27. package/build/constants/validation.js +1 -0
  28. package/build/features/app/business/businessStore.d.ts +73 -4
  29. package/build/features/app/business/businessStore.js +500 -7
  30. package/build/features/app/connect/connectStore.d.ts +11 -3
  31. package/build/features/app/connect/connectStore.js +88 -43
  32. package/build/features/bank/screens/BankDetails/validation.js +2 -1
  33. package/build/features/business/Business.js +7 -3
  34. package/build/features/business/screens/Activities/Activities.js +13 -13
  35. package/build/features/business/screens/Activities/ActivitiesList.d.ts +2 -2
  36. package/build/features/business/screens/Activities/ActivitiesList.js +14 -4
  37. package/build/features/business/screens/Activities/OperationStartDate.js +1 -1
  38. package/build/features/business/screens/Activities/SalesChannels.js +11 -2
  39. package/build/features/business/screens/BusinessType/BusinessType.d.ts +1 -8
  40. package/build/features/business/screens/BusinessType/BusinessType.js +25 -27
  41. package/build/features/business/screens/Confirm/Confirm.js +10 -11
  42. package/build/features/business/screens/Customers/CustomerLocations.d.ts +3 -3
  43. package/build/features/business/screens/Customers/Customers.js +3 -2
  44. package/build/features/business/screens/IDBOD/DOB.js +1 -1
  45. package/build/features/business/screens/IDBOD/IDBOD.js +19 -12
  46. package/build/features/business/screens/OTP/OTP.d.ts +2 -5
  47. package/build/features/business/screens/OTP/OTP.js +18 -15
  48. package/build/features/business/screens/OTP/OTPInput.js +20 -5
  49. package/build/features/business/screens/Success/Success.js +6 -0
  50. package/build/features/business/screens/Verify/OTPInput.js +7 -3
  51. package/build/features/business/screens/Verify/Verify.d.ts +1 -9
  52. package/build/features/business/screens/Verify/Verify.js +16 -17
  53. package/build/features/business/screens/Verify/index.d.ts +1 -2
  54. package/build/features/connect/screens/Individual/Individual.js +6 -1
  55. package/build/features/connect/screens/Individual/Name.js +10 -1
  56. package/build/features/connect/screens/Individual/validation.js +3 -2
  57. package/build/features/connect/screens/Merchant/Merchant.js +6 -1
  58. package/build/features/connect/screens/Mobile/Mobile.js +6 -1
  59. package/build/features/connect/screens/NID/NID.js +6 -1
  60. package/build/features/connect/screens/OTP/OTP.js +6 -1
  61. package/build/features/connect/screens/Password/Password.js +7 -2
  62. package/build/features/featuresScreens.js +3 -3
  63. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +2 -4
  64. package/build/features/shared/Button/AbsherButton.js +1 -1
  65. package/build/features/shared/Input/Input.d.ts +1 -1
  66. package/build/hooks/useAppConfig.js +99 -24
  67. package/build/theme/palette.js +4 -0
  68. package/build/utils/string.d.ts +25 -0
  69. package/build/utils/string.js +56 -0
  70. package/package.json +1 -1
@@ -1,19 +1,88 @@
1
1
  import { RootState } from '../../../app/store';
2
- import { CountryCode, ResponseData, SharedState } from '../../../@types';
2
+ import { ActivitiesFormValues, BusinessInfoFormValues, CustomersFormValues, BusinessTypeFormValues, CountryCode, CRLicense, FLLicense, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
3
3
  export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
4
4
  businessCountry: any;
5
5
  countries: any;
6
6
  }, void, {}>;
7
7
  export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
8
8
  data: any;
9
+ leadData: any;
9
10
  token: string;
10
11
  }, string, {}>;
11
- export interface BusinessData {
12
- verify: ResponseData & {
13
- token: string;
12
+ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
13
+ data: any;
14
+ formData: {
15
+ isNID: boolean;
16
+ otp: string;
14
17
  };
18
+ }, OTPFormValues, {}>;
19
+ export declare const updateLeadIdentity: import("@reduxjs/toolkit").AsyncThunk<{
20
+ data: any;
21
+ formData: {
22
+ type: string;
23
+ nid: string;
24
+ dob: string;
25
+ isResend: boolean;
26
+ };
27
+ }, NIDFormValues & {
28
+ isResend: boolean;
29
+ }, {}>;
30
+ export declare const retrieveCRInfos: import("@reduxjs/toolkit").AsyncThunk<{
31
+ data: any;
32
+ }, void, {}>;
33
+ export declare const retrieveFLInfos: import("@reduxjs/toolkit").AsyncThunk<{
34
+ data: any;
35
+ }, void, {}>;
36
+ export declare const updateLeadBusinessType: import("@reduxjs/toolkit").AsyncThunk<{
37
+ data: any;
38
+ formData: BusinessTypeFormValues;
39
+ }, BusinessTypeFormValues, {}>;
40
+ export declare const createAccount: import("@reduxjs/toolkit").AsyncThunk<{
41
+ data: any;
42
+ channelsData: any;
43
+ }, void, {}>;
44
+ export declare const updateActivitiesInfo: import("@reduxjs/toolkit").AsyncThunk<{
45
+ data: any;
46
+ formData: {
47
+ activities: import("../../../@types").Activity[] | undefined;
48
+ salesChannels: import("../../../@types").SalesChannel[];
49
+ operationStartDate: string;
50
+ };
51
+ }, ActivitiesFormValues, {}>;
52
+ export declare const updateCustomersInfo: import("@reduxjs/toolkit").AsyncThunk<{
53
+ data: any;
54
+ formData: {
55
+ customerLocations: import("../../../@types").CustomerLocation[];
56
+ expectedCustomers: import("../../../@types").ExpectedCustomer | undefined;
57
+ expectedSalesRange: import("../../../@types").ExpectedSaleRange | undefined;
58
+ refundPolicy: boolean;
59
+ transactionPolicy: boolean;
60
+ isResend: boolean;
61
+ };
62
+ }, CustomersFormValues & {
63
+ isResend: boolean;
64
+ }, {}>;
65
+ export declare const updateLeadSuccess: import("@reduxjs/toolkit").AsyncThunk<{
66
+ response: any;
67
+ formData: void;
68
+ }, void, {}>;
69
+ declare type VerifyData = {
70
+ token: string;
71
+ };
72
+ export interface BusinessData {
73
+ verify: ResponseData & VerifyData;
15
74
  businessCountry: CountryCode;
16
75
  countries: CountryCode[];
76
+ otpData: OTPFormValues & ResponseData;
77
+ nidData: NIDFormValues & ResponseData & {
78
+ type: string;
79
+ };
80
+ businessTypeData: BusinessTypeFormValues & ResponseData;
81
+ crInfos: Array<CRLicense>;
82
+ flInfos: Array<FLLicense>;
83
+ businessInfo: BusinessInfoFormValues & ResponseData;
84
+ activitiesData: ActivitiesFormValues & ResponseData;
85
+ customersData: CustomersFormValues & ResponseData;
17
86
  }
18
87
  export interface BusinessState extends SharedState<BusinessData> {
19
88
  }
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,8 +47,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
47
  };
37
48
  var _a;
38
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
+ import moment from 'moment';
39
51
  import API from '../../../api';
40
- import { defaultCountry } from '../../../constants';
52
+ import { BusinessType } from '../../../@types';
53
+ import { BUSINESS_STEP_NAMES, defaultCountry, IDENTIFICATION_TYPE } from '../../../constants';
54
+ import i18n from '../../../i18n';
55
+ import { convertNumbers2English, removeRequestHeaders } from '../../../utils';
56
+ import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
41
57
  export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
42
58
  var settings, countriesBody, list, businessCountry;
43
59
  return __generator(this, function (_a) {
@@ -56,7 +72,7 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
56
72
  });
57
73
  }); });
58
74
  export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
59
- var payload, data;
75
+ var payload, data, leadResponse;
60
76
  return __generator(this, function (_a) {
61
77
  switch (_a.label) {
62
78
  case 0:
@@ -67,7 +83,252 @@ export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token
67
83
  return [4, API.leadService.verifyLeadToken(payload)];
68
84
  case 1:
69
85
  data = (_a.sent()).data;
70
- return [2, { data: data, token: token }];
86
+ leadResponse = undefined;
87
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 3];
88
+ return [4, API.leadService.retrieveLead(data === null || data === void 0 ? void 0 : data.id)];
89
+ case 2:
90
+ leadResponse = _a.sent();
91
+ if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
92
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_IDBOD_STEP'));
93
+ }
94
+ if (data.step_name === 'business_info') {
95
+ thunkApi.dispatch(handleCurrentActiveScreen('BUSINESS_BUSINESS_TYPE_STEP'));
96
+ }
97
+ _a.label = 3;
98
+ case 3: return [2, { data: data, leadData: leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data, token: token }];
99
+ }
100
+ });
101
+ }); });
102
+ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
103
+ var _a, business, settings, responseBody, isNID, payload, data;
104
+ var _b, _c, _d;
105
+ return __generator(this, function (_e) {
106
+ switch (_e.label) {
107
+ case 0:
108
+ _a = thunkApi.getState(), business = _a.business, settings = _a.settings;
109
+ responseBody = business.data.verify.responseBody;
110
+ isNID = settings.data.activeScreen.name === 'BUSINESS_IDBOD_STEP';
111
+ payload = {
112
+ data: params.otp,
113
+ service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
114
+ verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
115
+ step_name: isNID ? BUSINESS_STEP_NAMES.IDENTITY_VERIFY_AUTH : BUSINESS_STEP_NAMES.PHONE_AUTH,
116
+ encryption_contract: ['data']
117
+ };
118
+ return [4, API.leadService.verifyLeadOTP(payload)];
119
+ case 1:
120
+ data = (_e.sent()).data;
121
+ if (!data.errors) {
122
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
123
+ if (isNID) {
124
+ thunkApi.dispatch(retrieveFLInfos());
125
+ thunkApi.dispatch(retrieveCRInfos());
126
+ thunkApi.dispatch(handleNextScreenStep());
127
+ }
128
+ else {
129
+ if (data.step_name === BUSINESS_STEP_NAMES.IDENTITY_AUTH) {
130
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_IDBOD_STEP'));
131
+ }
132
+ else {
133
+ thunkApi.dispatch(handleNextScreenStep('BUSINESS_BUSINESS_TYPE_STEP'));
134
+ }
135
+ }
136
+ }
137
+ return [2, { data: data, formData: __assign(__assign({}, params), { isNID: isNID }) }];
138
+ }
139
+ });
140
+ }); });
141
+ export var updateLeadIdentity = createAsyncThunk('updateLeadIdentity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
142
+ var _a, settings, business, identification_id_type, requestBody, data;
143
+ var _b, _c;
144
+ return __generator(this, function (_d) {
145
+ switch (_d.label) {
146
+ case 0:
147
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
148
+ identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
149
+ requestBody = {
150
+ identification_id: params.nid,
151
+ identification_id_type: identification_id_type,
152
+ date_of_birth: params.dob,
153
+ country_code: business.data.businessCountry.iso2,
154
+ step_name: BUSINESS_STEP_NAMES.IDENTITY_AUTH,
155
+ encryption_contract: ['country_code', 'identification_id', 'identification_id_type', 'date_of_birth']
156
+ };
157
+ return [4, API.leadService.updateLeadIdentity(requestBody)];
158
+ case 1:
159
+ data = (_d.sent()).data;
160
+ if (!data.errors && !params.isResend) {
161
+ thunkApi.dispatch(handleNextScreenStep());
162
+ (_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody);
163
+ }
164
+ return [2, { data: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
165
+ }
166
+ });
167
+ }); });
168
+ export var retrieveCRInfos = createAsyncThunk('retrieveCRInfos', function (_a, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
169
+ var business, leadId, data;
170
+ var _b;
171
+ return __generator(this, function (_c) {
172
+ switch (_c.label) {
173
+ case 0:
174
+ business = thunkApi.getState().business;
175
+ leadId = (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id;
176
+ return [4, API.leadService.retrieveCRInfos(leadId)];
177
+ case 1:
178
+ data = (_c.sent()).data;
179
+ return [2, { data: data }];
180
+ }
181
+ });
182
+ }); });
183
+ export var retrieveFLInfos = createAsyncThunk('retrieveFLInfos', function (_a, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
184
+ var business, leadId, data;
185
+ var _b;
186
+ return __generator(this, function (_c) {
187
+ switch (_c.label) {
188
+ case 0:
189
+ business = thunkApi.getState().business;
190
+ leadId = (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id;
191
+ return [4, API.leadService.retrieveFLInfos(leadId)];
192
+ case 1:
193
+ data = (_c.sent()).data;
194
+ return [2, { data: data }];
195
+ }
196
+ });
197
+ }); });
198
+ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
199
+ var _a, settings, business, headers, payload, data;
200
+ var _b, _c, _d, _e, _f;
201
+ return __generator(this, function (_g) {
202
+ switch (_g.label) {
203
+ case 0:
204
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
205
+ headers = {
206
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
207
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
208
+ };
209
+ payload = {
210
+ freelancer_number: params.flNumber,
211
+ business_type: params.businessType,
212
+ cr_number: params.crNumber,
213
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_INFO,
214
+ encryption_contract: ['freelancer_number', 'business_type', 'cr_number']
215
+ };
216
+ return [4, API.leadService.updateLead(payload, { headers: headers })];
217
+ case 1:
218
+ data = (_g.sent()).data;
219
+ if (!data.errors) {
220
+ thunkApi.dispatch(handleNextScreenStep());
221
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
222
+ }
223
+ return [2, { data: data, formData: params }];
224
+ }
225
+ });
226
+ }); });
227
+ export var createAccount = createAsyncThunk('createAccount', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
228
+ var _a, settings, business, requestBody, data, channels;
229
+ var _b, _c, _d;
230
+ return __generator(this, function (_e) {
231
+ switch (_e.label) {
232
+ case 0:
233
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
234
+ requestBody = {
235
+ lead_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id,
236
+ notify: {
237
+ email: false,
238
+ phone: false
239
+ },
240
+ skip_legacy: false,
241
+ is_acknowledged: true,
242
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_INFO_CONFIRM
243
+ };
244
+ return [4, API.accountService.createAccount(requestBody)];
245
+ case 1:
246
+ data = (_e.sent()).data;
247
+ channels = undefined;
248
+ if (!!data.errors) return [3, 3];
249
+ return [4, API.dataService.getChannelsOfServices()];
250
+ case 2:
251
+ channels = _e.sent();
252
+ thunkApi.dispatch(handleNextScreenStep());
253
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
254
+ _e.label = 3;
255
+ case 3: return [2, { data: data, channelsData: channels === null || channels === void 0 ? void 0 : channels.data }];
256
+ }
257
+ });
258
+ }); });
259
+ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
260
+ var _a, settings, business, requestBody, headers, data;
261
+ var _b, _c, _d;
262
+ return __generator(this, function (_e) {
263
+ switch (_e.label) {
264
+ case 0:
265
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
266
+ requestBody = {
267
+ activities: params.activities,
268
+ channel_services: params.salesChannels,
269
+ business_operation_start_at: params.operationStartDate,
270
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES
271
+ };
272
+ headers = { entity_id: (_b = business.data.businessInfo.responseBody) === null || _b === void 0 ? void 0 : _b.entity_id };
273
+ return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
274
+ case 1:
275
+ data = (_e.sent()).data;
276
+ if (!data.errors) {
277
+ thunkApi.dispatch(handleNextScreenStep());
278
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
279
+ }
280
+ return [2, { data: data, formData: __assign({}, params) }];
281
+ }
282
+ });
283
+ }); });
284
+ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
285
+ var _a, settings, business, requestBody, headers, data;
286
+ var _b, _c, _d;
287
+ return __generator(this, function (_e) {
288
+ switch (_e.label) {
289
+ case 0:
290
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
291
+ requestBody = {
292
+ customers_base: params.customerLocations,
293
+ customers_served_monthly: params.expectedCustomers,
294
+ yearly_sales_range: params.expectedSalesRange,
295
+ agree_refund: params.refundPolicy,
296
+ agree_chargeback: params.transactionPolicy,
297
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
298
+ };
299
+ headers = { entity_id: (_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id };
300
+ return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
301
+ case 1:
302
+ data = (_e.sent()).data;
303
+ if (!data.errors && !params.isResend) {
304
+ thunkApi.dispatch(handleNextScreenStep());
305
+ (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
306
+ }
307
+ return [2, { data: data, formData: __assign({}, params) }];
308
+ }
309
+ });
310
+ }); });
311
+ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
312
+ var _a, settings, business, headers, payload, data;
313
+ var _b, _c, _d, _e, _f, _g, _h;
314
+ return __generator(this, function (_j) {
315
+ switch (_j.label) {
316
+ case 0:
317
+ _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
318
+ headers = {
319
+ lead_id: ((_b = business.data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.id) || '',
320
+ device_identifier: (_d = (_c = settings.data.deviceInfo) === null || _c === void 0 ? void 0 : _c.browser) === null || _d === void 0 ? void 0 : _d.browser_id
321
+ };
322
+ payload = {
323
+ step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
324
+ encryption_contract: []
325
+ };
326
+ return [4, API.leadService.updateLead(payload, { headers: headers })];
327
+ case 1:
328
+ data = (_j.sent()).data;
329
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
330
+ (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
331
+ return [2, { response: data, formData: params }];
71
332
  }
72
333
  });
73
334
  }); });
@@ -79,6 +340,38 @@ var initialState = {
79
340
  countries: [],
80
341
  verify: {
81
342
  token: ''
343
+ },
344
+ otpData: {
345
+ otp: ''
346
+ },
347
+ nidData: {
348
+ nid: '',
349
+ dob: '1998-08-22',
350
+ type: ''
351
+ },
352
+ businessTypeData: {
353
+ businessType: '',
354
+ flNumber: '',
355
+ crNumber: ''
356
+ },
357
+ crInfos: [],
358
+ flInfos: [],
359
+ businessInfo: {
360
+ licenseNumber: '',
361
+ brandName: '',
362
+ legalName: ''
363
+ },
364
+ activitiesData: {
365
+ activities: [],
366
+ salesChannels: [],
367
+ operationStartDate: '1998-08-22'
368
+ },
369
+ customersData: {
370
+ customerLocations: [],
371
+ expectedCustomers: undefined,
372
+ expectedSalesRange: undefined,
373
+ refundPolicy: false,
374
+ transactionPolicy: false
82
375
  }
83
376
  }
84
377
  };
@@ -108,23 +401,223 @@ export var businessSlice = createSlice({
108
401
  state.error = action.error.message;
109
402
  })
110
403
  .addCase(verifyLeadToken.pending, function (state) {
111
- state.loading = true;
112
404
  state.error = null;
113
405
  })
114
406
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
115
407
  var _a;
116
- state.loading = false;
117
408
  state.error = null;
118
- var _b = action.payload, data = _b.data, token = _b.token;
409
+ var _b = action.payload, data = _b.data, token = _b.token, leadData = _b.leadData;
119
410
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
120
411
  if (description) {
121
412
  state.error = description;
122
413
  return;
123
414
  }
124
- state.data.verify.responseBody = action.payload.data;
415
+ state.data.verify.responseBody = __assign(__assign({}, data), leadData);
125
416
  state.data.verify.token = token;
126
417
  })
127
418
  .addCase(verifyLeadToken.rejected, function (state, action) {
419
+ state.error = action.error.message;
420
+ })
421
+ .addCase(verifyLeadOTP.pending, function (state) {
422
+ state.loading = true;
423
+ state.error = null;
424
+ })
425
+ .addCase(verifyLeadOTP.fulfilled, function (state, action) {
426
+ var _a;
427
+ state.loading = false;
428
+ state.error = null;
429
+ var _b = action.payload, data = _b.data, formData = _b.formData;
430
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
431
+ if (description) {
432
+ state.error = description;
433
+ return;
434
+ }
435
+ state.data.otpData = formData;
436
+ state.data.otpData.responseBody = data;
437
+ })
438
+ .addCase(verifyLeadOTP.rejected, function (state, action) {
439
+ state.loading = false;
440
+ state.error = action.error.message;
441
+ })
442
+ .addCase(updateLeadIdentity.pending, function (state) {
443
+ state.loading = true;
444
+ state.error = null;
445
+ })
446
+ .addCase(updateLeadIdentity.fulfilled, function (state, action) {
447
+ var _a;
448
+ state.loading = false;
449
+ state.error = null;
450
+ var _b = action.payload, data = _b.data, formData = _b.formData;
451
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
452
+ if (description) {
453
+ state.error = description;
454
+ return;
455
+ }
456
+ state.data.nidData = formData;
457
+ state.data.nidData.responseBody = data;
458
+ })
459
+ .addCase(updateLeadIdentity.rejected, function (state, action) {
460
+ state.loading = false;
461
+ state.error = action.error.message;
462
+ })
463
+ .addCase(retrieveCRInfos.pending, function (state) {
464
+ state.loading = true;
465
+ state.error = null;
466
+ })
467
+ .addCase(retrieveCRInfos.fulfilled, function (state, action) {
468
+ var _a;
469
+ state.loading = false;
470
+ state.error = null;
471
+ var data = action.payload.data;
472
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
473
+ if (!description) {
474
+ state.data.crInfos = data;
475
+ state.data.businessTypeData.businessType = BusinessType.CR;
476
+ }
477
+ })
478
+ .addCase(retrieveCRInfos.rejected, function (state, action) {
479
+ state.loading = false;
480
+ state.error = action.error.message;
481
+ })
482
+ .addCase(retrieveFLInfos.pending, function (state) {
483
+ state.loading = true;
484
+ state.error = null;
485
+ })
486
+ .addCase(retrieveFLInfos.fulfilled, function (state, action) {
487
+ var _a;
488
+ state.loading = false;
489
+ state.error = null;
490
+ var data = action.payload.data;
491
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
492
+ if (!description) {
493
+ state.data.flInfos = data === null || data === void 0 ? void 0 : data.licenses;
494
+ state.data.businessTypeData.businessType = BusinessType.FL;
495
+ }
496
+ })
497
+ .addCase(retrieveFLInfos.rejected, function (state, action) {
498
+ state.loading = false;
499
+ state.error = action.error.message;
500
+ })
501
+ .addCase(updateLeadBusinessType.pending, function (state) {
502
+ state.loading = true;
503
+ state.error = null;
504
+ })
505
+ .addCase(updateLeadBusinessType.fulfilled, function (state, action) {
506
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
507
+ state.loading = false;
508
+ state.error = null;
509
+ var _m = action.payload, data = _m.data, formData = _m.formData;
510
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
511
+ if (description) {
512
+ state.error = description;
513
+ return;
514
+ }
515
+ state.data.businessTypeData = formData;
516
+ 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;
517
+ state.data.businessInfo.licenseNumber = (data === null || data === void 0 ? void 0 : data.freelancer_number) || (data === null || data === void 0 ? void 0 : data.cr_number);
518
+ if (formData.businessType === BusinessType.CR) {
519
+ state.data.businessInfo.legalName = (_f = data === null || data === void 0 ? void 0 : data.license) === null || _f === void 0 ? void 0 : _f.crName;
520
+ 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'));
521
+ 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;
522
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
523
+ if (!!selectedActivity)
524
+ state.data.activitiesData.activities = [selectedActivity];
525
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: activities || [] });
526
+ return;
527
+ }
528
+ 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;
529
+ if (!!category)
530
+ state.data.activitiesData.activities = [category];
531
+ state.data.businessTypeData.responseBody = __assign(__assign({}, data), { activities: [category] });
532
+ })
533
+ .addCase(updateLeadBusinessType.rejected, function (state, action) {
534
+ state.loading = false;
535
+ state.error = action.error.message;
536
+ })
537
+ .addCase(createAccount.pending, function (state) {
538
+ state.loading = true;
539
+ state.error = null;
540
+ })
541
+ .addCase(createAccount.fulfilled, function (state, action) {
542
+ var _a, _b;
543
+ state.error = null;
544
+ var _c = action.payload, data = _c.data, channelsData = _c.channelsData;
545
+ 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;
546
+ if (description) {
547
+ state.error = description;
548
+ return;
549
+ }
550
+ if ((data === null || data === void 0 ? void 0 : data.status) === 'ALREADY_TAKEN') {
551
+ state.error = 'signup_user_exists_error';
552
+ return;
553
+ }
554
+ state.data.businessInfo.responseBody = __assign(__assign({}, data), { channelList: channelsData || [] });
555
+ var selectedChannel = channelsData === null || channelsData === void 0 ? void 0 : channelsData[0];
556
+ if (!!selectedChannel)
557
+ state.data.activitiesData.salesChannels = [selectedChannel];
558
+ })
559
+ .addCase(createAccount.rejected, function (state, action) {
560
+ state.loading = false;
561
+ state.error = action.error.message;
562
+ })
563
+ .addCase(updateActivitiesInfo.pending, function (state) {
564
+ state.loading = true;
565
+ state.error = null;
566
+ })
567
+ .addCase(updateActivitiesInfo.fulfilled, function (state, action) {
568
+ var _a;
569
+ state.error = null;
570
+ var _b = action.payload, data = _b.data, formData = _b.formData;
571
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
572
+ if (description) {
573
+ state.error = description;
574
+ return;
575
+ }
576
+ state.data.activitiesData = formData;
577
+ state.data.activitiesData.responseBody = data;
578
+ })
579
+ .addCase(updateActivitiesInfo.rejected, function (state, action) {
580
+ state.loading = false;
581
+ state.error = action.error.message;
582
+ })
583
+ .addCase(updateCustomersInfo.pending, function (state) {
584
+ state.loading = true;
585
+ state.error = null;
586
+ })
587
+ .addCase(updateCustomersInfo.fulfilled, function (state, action) {
588
+ var _a;
589
+ state.loading = false;
590
+ state.error = null;
591
+ var _b = action.payload, data = _b.data, formData = _b.formData;
592
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
593
+ if (description) {
594
+ state.error = description;
595
+ return;
596
+ }
597
+ state.data.customersData = formData;
598
+ state.data.customersData.responseBody = data;
599
+ })
600
+ .addCase(updateCustomersInfo.rejected, function (state, action) {
601
+ state.loading = false;
602
+ state.error = action.error.message;
603
+ })
604
+ .addCase(updateLeadSuccess.fulfilled, function (state, action) {
605
+ var _a;
606
+ state.loading = false;
607
+ state.error = null;
608
+ var response = action.payload.response;
609
+ var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
610
+ if (description) {
611
+ state.error = description;
612
+ return;
613
+ }
614
+ removeRequestHeaders();
615
+ })
616
+ .addCase(updateLeadSuccess.pending, function (state) {
617
+ state.loading = true;
618
+ state.error = null;
619
+ })
620
+ .addCase(updateLeadSuccess.rejected, function (state, action) {
128
621
  state.loading = false;
129
622
  state.error = action.error.message;
130
623
  });