@tap-payments/auth-jsconnect 2.1.14-test → 2.1.16-test
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.
- package/build/components/Lottie/files/start_loading.json +9 -9
- package/build/constants/app.js +2 -2
- package/build/features/app/business/businessStore.js +13 -9
- package/build/features/app/connect/connectStore.d.ts +1 -5
- package/build/features/app/connect/connectStore.js +172 -247
- package/build/features/business/screens/Activities/Activities.js +6 -14
- package/build/features/business/screens/BusinessType/BusinessType.js +11 -14
- package/build/features/connect/screens/CivilID/CivilID.js +1 -1
- package/build/features/connect/screens/Individual/Individual.js +5 -8
- package/build/features/connect/screens/Merchant/Merchant.js +9 -21
- package/build/features/connect/screens/Merchant/SalesChannels.js +8 -12
- package/build/features/connect/screens/Merchant/validation.js +3 -3
- package/build/features/shared/PaciVerification/VerifyPACILoading.js +3 -3
- package/build/features/shared/SalesChannels/SalesChannel.js +6 -4
- package/build/hooks/useSetFromDefaultValues.js +2 -0
- package/package.json +129 -129
|
@@ -75,9 +75,9 @@ import { defaultCountry } from '../../../constants';
|
|
|
75
75
|
import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep, findCountryByIddPrefix, concatenateObjectValues, isTwitter, isWebsite, fixBrandList } from '../../../utils';
|
|
76
76
|
export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
77
|
var settings, requestBody, data;
|
|
78
|
-
var _a, _b;
|
|
79
|
-
return __generator(this, function (
|
|
80
|
-
switch (
|
|
78
|
+
var _a, _b, _c;
|
|
79
|
+
return __generator(this, function (_d) {
|
|
80
|
+
switch (_d.label) {
|
|
81
81
|
case 0:
|
|
82
82
|
settings = thunkApi.getState().settings;
|
|
83
83
|
requestBody = {
|
|
@@ -93,20 +93,20 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
|
|
|
93
93
|
};
|
|
94
94
|
return [4, API.authService.createAuth(requestBody)];
|
|
95
95
|
case 1:
|
|
96
|
-
data = (
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
data = (_d.sent()).data;
|
|
97
|
+
if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
98
|
+
throw new Error(data.errors[0].description);
|
|
99
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
100
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
101
101
|
return [2, { response: data, formData: params }];
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
}); });
|
|
105
105
|
export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
106
|
var settings, requestBody, data;
|
|
107
|
-
var _a, _b;
|
|
108
|
-
return __generator(this, function (
|
|
109
|
-
switch (
|
|
107
|
+
var _a, _b, _c;
|
|
108
|
+
return __generator(this, function (_d) {
|
|
109
|
+
switch (_d.label) {
|
|
110
110
|
case 0:
|
|
111
111
|
settings = thunkApi.getState().settings;
|
|
112
112
|
requestBody = {
|
|
@@ -122,19 +122,20 @@ export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (p
|
|
|
122
122
|
};
|
|
123
123
|
return [4, API.authService.createAuth(requestBody)];
|
|
124
124
|
case 1:
|
|
125
|
-
data = (
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
data = (_d.sent()).data;
|
|
126
|
+
if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
127
|
+
throw new Error(data.errors[0].description);
|
|
128
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
129
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
130
130
|
return [2, { response: data, formData: params }];
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
}); });
|
|
134
134
|
export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
135
135
|
var _a, settings, connect, _b, mobile, countryCode, requestBody, data;
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
var _c;
|
|
137
|
+
return __generator(this, function (_d) {
|
|
138
|
+
switch (_d.label) {
|
|
138
139
|
case 0:
|
|
139
140
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
140
141
|
_b = connect.data.mobileData, mobile = _b.mobile, countryCode = _b.countryCode;
|
|
@@ -151,25 +152,27 @@ export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (param
|
|
|
151
152
|
};
|
|
152
153
|
return [4, API.authService.createAuth(requestBody)];
|
|
153
154
|
case 1:
|
|
154
|
-
data = (
|
|
155
|
+
data = (_d.sent()).data;
|
|
156
|
+
if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
157
|
+
throw new Error(data.errors[0].description);
|
|
155
158
|
return [2, data];
|
|
156
159
|
}
|
|
157
160
|
});
|
|
158
161
|
}); });
|
|
159
|
-
export var
|
|
160
|
-
var settings,
|
|
161
|
-
var
|
|
162
|
-
return __generator(this, function (
|
|
163
|
-
switch (
|
|
162
|
+
export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
163
|
+
var _a, settings, connect, _b, nid, dob, type, requestBody, data;
|
|
164
|
+
var _c;
|
|
165
|
+
return __generator(this, function (_d) {
|
|
166
|
+
switch (_d.label) {
|
|
164
167
|
case 0:
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
169
|
+
_b = connect.data.nidData, nid = _b.nid, dob = _b.dob, type = _b.type;
|
|
167
170
|
requestBody = {
|
|
168
171
|
lang: settings.data.language,
|
|
169
172
|
user_credentail: {
|
|
170
|
-
identification_id:
|
|
171
|
-
identification_id_type:
|
|
172
|
-
date_of_birth:
|
|
173
|
+
identification_id: nid,
|
|
174
|
+
identification_id_type: type,
|
|
175
|
+
date_of_birth: dob,
|
|
173
176
|
country_code: settings.data.businessCountry.iso2
|
|
174
177
|
},
|
|
175
178
|
sign_in: false,
|
|
@@ -184,28 +187,27 @@ export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, t
|
|
|
184
187
|
};
|
|
185
188
|
return [4, API.authService.createAuth(requestBody)];
|
|
186
189
|
case 1:
|
|
187
|
-
data = (
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
return [2, { response: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
|
|
190
|
+
data = (_d.sent()).data;
|
|
191
|
+
if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
192
|
+
throw new Error(data.errors[0].description);
|
|
193
|
+
return [2, data];
|
|
193
194
|
}
|
|
194
195
|
});
|
|
195
196
|
}); });
|
|
196
|
-
export var
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
+
var settings, identification_id_type, requestBody, data;
|
|
199
|
+
var _a, _b, _c;
|
|
200
|
+
return __generator(this, function (_d) {
|
|
201
|
+
switch (_d.label) {
|
|
200
202
|
case 0:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
+
settings = thunkApi.getState().settings;
|
|
204
|
+
identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
|
|
203
205
|
requestBody = {
|
|
204
206
|
lang: settings.data.language,
|
|
205
207
|
user_credentail: {
|
|
206
|
-
identification_id: nid,
|
|
207
|
-
identification_id_type:
|
|
208
|
-
date_of_birth: dob,
|
|
208
|
+
identification_id: params.nid,
|
|
209
|
+
identification_id_type: identification_id_type,
|
|
210
|
+
date_of_birth: params.dob,
|
|
209
211
|
country_code: settings.data.businessCountry.iso2
|
|
210
212
|
},
|
|
211
213
|
sign_in: false,
|
|
@@ -220,16 +222,20 @@ export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thu
|
|
|
220
222
|
};
|
|
221
223
|
return [4, API.authService.createAuth(requestBody)];
|
|
222
224
|
case 1:
|
|
223
|
-
data = (
|
|
224
|
-
|
|
225
|
+
data = (_d.sent()).data;
|
|
226
|
+
if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
227
|
+
throw new Error(data.errors[0].description);
|
|
228
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
229
|
+
(_c = (_b = settings.data.appConfig).onStepCompleted) === null || _c === void 0 ? void 0 : _c.call(_b, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
230
|
+
return [2, { response: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
|
|
225
231
|
}
|
|
226
232
|
});
|
|
227
233
|
}); });
|
|
228
234
|
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,
|
|
230
|
-
var
|
|
231
|
-
return __generator(this, function (
|
|
232
|
-
switch (
|
|
235
|
+
var _a, connect, settings, startWithNID, _b, mobileData, nidData, responseBody, stepName, payload, data, lead_id, leadResponse, channels, brands, err_1, countryCode, phone;
|
|
236
|
+
var _c, _d, _e, _f;
|
|
237
|
+
return __generator(this, function (_g) {
|
|
238
|
+
switch (_g.label) {
|
|
233
239
|
case 0:
|
|
234
240
|
_a = thunkApi.getState(), connect = _a.connect, settings = _a.settings;
|
|
235
241
|
startWithNID = connect.data.otpData.authFor === AuthForType.NATIONAL_ID;
|
|
@@ -250,66 +256,48 @@ export var verifyAuth = createAsyncThunk('connect/verifyAuth', function (params,
|
|
|
250
256
|
};
|
|
251
257
|
return [4, API.authService.verifyAuth(payload)];
|
|
252
258
|
case 1:
|
|
253
|
-
data = (
|
|
254
|
-
if ((
|
|
259
|
+
data = (_g.sent()).data;
|
|
260
|
+
if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
255
261
|
throw new Error(data.errors[0].description);
|
|
256
|
-
lead_id = data.lead_id
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
individual_id: individual_id
|
|
260
|
-
};
|
|
261
|
-
if (!lead_id) return [3, 3];
|
|
262
|
+
lead_id = data.lead_id;
|
|
263
|
+
if (!lead_id)
|
|
264
|
+
throw new Error('Lead id is missing');
|
|
262
265
|
return [4, API.leadService.retrieveLead(lead_id)];
|
|
263
266
|
case 2:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
case 3: return [4, API.leadService.createLead(leadBody)];
|
|
267
|
-
case 4:
|
|
268
|
-
_c = _j.sent();
|
|
269
|
-
_j.label = 5;
|
|
270
|
-
case 5:
|
|
271
|
-
leadResponse = (_c).data;
|
|
272
|
-
if ((_f = leadResponse.errors) === null || _f === void 0 ? void 0 : _f.length)
|
|
267
|
+
leadResponse = (_g.sent()).data;
|
|
268
|
+
if ((_d = leadResponse.errors) === null || _d === void 0 ? void 0 : _d.length)
|
|
273
269
|
throw new Error(leadResponse.errors[0].description);
|
|
274
|
-
isNewUser = leadResponse.is_new_individual;
|
|
275
|
-
if (!!isNewUser) return [3, 10];
|
|
276
270
|
return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
277
|
-
case
|
|
278
|
-
channels = (
|
|
271
|
+
case 3:
|
|
272
|
+
channels = (_g.sent()).list;
|
|
279
273
|
leadResponse.channel_list = channels;
|
|
280
|
-
|
|
281
|
-
case
|
|
282
|
-
|
|
274
|
+
_g.label = 4;
|
|
275
|
+
case 4:
|
|
276
|
+
_g.trys.push([4, 6, , 7]);
|
|
283
277
|
return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
|
|
284
|
-
case
|
|
285
|
-
brands = (
|
|
278
|
+
case 5:
|
|
279
|
+
brands = (_g.sent()).brands;
|
|
286
280
|
leadResponse.brand_list = fixBrandList(brands, channels);
|
|
287
|
-
return [3,
|
|
288
|
-
case
|
|
289
|
-
err_1 =
|
|
290
|
-
return [3,
|
|
291
|
-
case
|
|
281
|
+
return [3, 7];
|
|
282
|
+
case 6:
|
|
283
|
+
err_1 = _g.sent();
|
|
284
|
+
return [3, 7];
|
|
285
|
+
case 7:
|
|
292
286
|
countryCode = settings.data.businessCountry;
|
|
293
|
-
|
|
294
|
-
_d = contact || {}, phone = _d.phone, email = _d.email;
|
|
295
|
-
userInfoMissed = (!phone || !email || !name) && !isNewUser;
|
|
287
|
+
phone = (leadResponse.contact || {}).phone;
|
|
296
288
|
if (phone === null || phone === void 0 ? void 0 : phone.country_code)
|
|
297
289
|
countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
|
|
298
|
-
(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return [2, { authResponse: data, leadResponse: leadResponse, isNewUser: isNewUser, countryCode: countryCode, userInfoMissed: userInfoMissed }];
|
|
302
|
-
}
|
|
303
|
-
thunkApi.dispatch(handleNextScreenStep('CONNECT_MERCHANT_INFO_STEP'));
|
|
304
|
-
return [2, { authResponse: data, leadResponse: leadResponse, isNewUser: isNewUser, countryCode: countryCode, userInfoMissed: userInfoMissed }];
|
|
290
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, { otp: params.otp });
|
|
291
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
292
|
+
return [2, { authResponse: data, leadResponse: leadResponse, countryCode: countryCode }];
|
|
305
293
|
}
|
|
306
294
|
});
|
|
307
295
|
}); });
|
|
308
296
|
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,
|
|
310
|
-
var
|
|
311
|
-
return __generator(this, function (
|
|
312
|
-
switch (
|
|
297
|
+
var _a, settings, connect, responseBody, expiry, interval, maxCalls, count, authResponse, isSuccess, lead_id, leadResponse, countryCode, channels, brands, err_2, phone;
|
|
298
|
+
var _b, _c, _d, _e, _f;
|
|
299
|
+
return __generator(this, function (_g) {
|
|
300
|
+
switch (_g.label) {
|
|
313
301
|
case 0:
|
|
314
302
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
315
303
|
responseBody = connect.data.civilIdData.responseBody;
|
|
@@ -317,131 +305,105 @@ export var verifyPACI = createAsyncThunk('connect/verifyPACI', function (params,
|
|
|
317
305
|
interval = 3;
|
|
318
306
|
maxCalls = Math.floor(expiry / interval);
|
|
319
307
|
count = 1;
|
|
320
|
-
|
|
308
|
+
_g.label = 1;
|
|
321
309
|
case 1:
|
|
322
|
-
if (!(count <= maxCalls)) return [3,
|
|
310
|
+
if (!(count <= maxCalls)) return [3, 13];
|
|
323
311
|
if (thunkApi.signal.aborted) {
|
|
324
|
-
return [3,
|
|
312
|
+
return [3, 13];
|
|
325
313
|
}
|
|
326
314
|
return [4, API.authService.getVerifyAuth(responseBody === null || responseBody === void 0 ? void 0 : responseBody.auth_token)];
|
|
327
315
|
case 2:
|
|
328
|
-
authResponse =
|
|
329
|
-
isSuccess = ((
|
|
330
|
-
if (!isSuccess) return [3,
|
|
331
|
-
lead_id = authResponse.lead_id
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
individual_id: individual_id
|
|
335
|
-
};
|
|
336
|
-
if (!lead_id) return [3, 4];
|
|
316
|
+
authResponse = _g.sent();
|
|
317
|
+
isSuccess = ((_b = authResponse.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
|
|
318
|
+
if (!isSuccess) return [3, 10];
|
|
319
|
+
lead_id = authResponse.lead_id;
|
|
320
|
+
if (!lead_id)
|
|
321
|
+
throw new Error('Lead id is missing');
|
|
337
322
|
return [4, API.leadService.retrieveLead(lead_id)];
|
|
338
323
|
case 3:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
case 4: return [4, API.leadService.createLead(leadBody)];
|
|
342
|
-
case 5:
|
|
343
|
-
_b = _k.sent();
|
|
344
|
-
_k.label = 6;
|
|
345
|
-
case 6:
|
|
346
|
-
leadResponse = (_b).data;
|
|
347
|
-
if ((_e = leadResponse.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
324
|
+
leadResponse = (_g.sent()).data;
|
|
325
|
+
if ((_c = leadResponse.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
348
326
|
throw new Error(leadResponse.errors[0].description);
|
|
349
|
-
isNewUser = leadResponse.is_new_individual;
|
|
350
327
|
countryCode = settings.data.businessCountry;
|
|
351
|
-
contact = leadResponse.contact, name_1 = leadResponse.name;
|
|
352
|
-
_c = contact || {}, phone = _c.phone, email = _c.email;
|
|
353
|
-
userInfoMissed = (!phone || !email || !name_1) && !isNewUser;
|
|
354
|
-
if (!!isNewUser) return [3, 13];
|
|
355
328
|
return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
356
|
-
case
|
|
357
|
-
channels = (
|
|
329
|
+
case 4:
|
|
330
|
+
channels = (_g.sent()).list;
|
|
358
331
|
leadResponse.channel_list = channels;
|
|
359
|
-
|
|
360
|
-
case
|
|
361
|
-
|
|
332
|
+
_g.label = 5;
|
|
333
|
+
case 5:
|
|
334
|
+
_g.trys.push([5, 7, , 8]);
|
|
362
335
|
return [4, API.brandService.getBrandList({ individual_id: leadResponse.individual_id })];
|
|
363
|
-
case
|
|
364
|
-
brands = (
|
|
336
|
+
case 6:
|
|
337
|
+
brands = (_g.sent()).brands;
|
|
365
338
|
leadResponse.brand_list = fixBrandList(brands, channels);
|
|
366
|
-
return [3,
|
|
367
|
-
case
|
|
368
|
-
err_2 =
|
|
369
|
-
return [3,
|
|
370
|
-
case
|
|
371
|
-
(
|
|
372
|
-
return [4, sleep(3000)];
|
|
373
|
-
case 12:
|
|
374
|
-
_k.sent();
|
|
375
|
-
return [3, 15];
|
|
376
|
-
case 13:
|
|
377
|
-
(_g = params.onSuccess) === null || _g === void 0 ? void 0 : _g.call(params);
|
|
339
|
+
return [3, 8];
|
|
340
|
+
case 7:
|
|
341
|
+
err_2 = _g.sent();
|
|
342
|
+
return [3, 8];
|
|
343
|
+
case 8:
|
|
344
|
+
(_d = params.onSuccess) === null || _d === void 0 ? void 0 : _d.call(params);
|
|
378
345
|
return [4, sleep(3000)];
|
|
379
|
-
case
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
case 15:
|
|
346
|
+
case 9:
|
|
347
|
+
_g.sent();
|
|
348
|
+
phone = (leadResponse.contact || {}).phone;
|
|
383
349
|
if (phone === null || phone === void 0 ? void 0 : phone.country_code)
|
|
384
350
|
countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
|
|
385
|
-
(
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
case
|
|
393
|
-
case 17:
|
|
394
|
-
_k.sent();
|
|
395
|
-
_k.label = 18;
|
|
396
|
-
case 18:
|
|
351
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
|
|
352
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
353
|
+
return [2, { authResponse: authResponse, leadResponse: leadResponse, countryCode: countryCode }];
|
|
354
|
+
case 10: return [4, sleep(interval * 1000)];
|
|
355
|
+
case 11:
|
|
356
|
+
_g.sent();
|
|
357
|
+
_g.label = 12;
|
|
358
|
+
case 12:
|
|
397
359
|
count++;
|
|
398
360
|
return [3, 1];
|
|
399
|
-
case
|
|
361
|
+
case 13: throw new Error('paci_verification_failed');
|
|
400
362
|
}
|
|
401
363
|
});
|
|
402
364
|
}); });
|
|
403
365
|
export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
404
|
-
var _a, settings, connect,
|
|
405
|
-
var _c, _d, _e, _f
|
|
406
|
-
return __generator(this, function (
|
|
407
|
-
switch (
|
|
366
|
+
var _a, settings, connect, lead_id, phoneCountry, payload, leadResponse, brand;
|
|
367
|
+
var _b, _c, _d, _e, _f;
|
|
368
|
+
return __generator(this, function (_g) {
|
|
369
|
+
switch (_g.label) {
|
|
408
370
|
case 0:
|
|
409
371
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
410
|
-
|
|
411
|
-
phoneCountry = (
|
|
412
|
-
payload =
|
|
372
|
+
lead_id = (connect.data.otpData.responseBody || {}).lead_id;
|
|
373
|
+
phoneCountry = (_c = (_b = params.countryCode) === null || _b === void 0 ? void 0 : _b.idd_prefix) === null || _c === void 0 ? void 0 : _c.toString();
|
|
374
|
+
payload = {
|
|
375
|
+
id: lead_id || '',
|
|
376
|
+
country_code: (_d = settings.data.businessCountry) === null || _d === void 0 ? void 0 : _d.iso2,
|
|
377
|
+
name: getIndividualName(params.name),
|
|
378
|
+
contact: __assign({ email: params.email }, (params.mobile && { phone: { country_code: phoneCountry, number: params.mobile } })),
|
|
379
|
+
step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_INDIVIDUAL,
|
|
380
|
+
encryption_contract: [
|
|
413
381
|
'name.first',
|
|
414
382
|
'name.middle',
|
|
415
383
|
'name.last',
|
|
416
384
|
'contact.email',
|
|
417
385
|
'contact.phone.country_code',
|
|
418
386
|
'contact.phone.number'
|
|
419
|
-
]
|
|
387
|
+
]
|
|
388
|
+
};
|
|
420
389
|
return [4, API.leadService.updateLead(payload)];
|
|
421
390
|
case 1:
|
|
422
|
-
leadResponse =
|
|
391
|
+
leadResponse = _g.sent();
|
|
423
392
|
if (!leadResponse.brand) return [3, 3];
|
|
424
393
|
return [4, API.brandService.retrieveBrand(leadResponse.brand.id)];
|
|
425
394
|
case 2:
|
|
426
|
-
brand = (
|
|
395
|
+
brand = (_g.sent()).brand;
|
|
427
396
|
leadResponse.brand = __assign(__assign({}, leadResponse.brand), brand);
|
|
428
|
-
|
|
397
|
+
_g.label = 3;
|
|
429
398
|
case 3:
|
|
430
|
-
|
|
431
|
-
return [4, API.dataService.getChannelsOfServices({ page: 0 })];
|
|
432
|
-
case 4:
|
|
433
|
-
channels = (_h.sent()).list;
|
|
434
|
-
leadResponse.channel_list = channels;
|
|
435
|
-
_h.label = 5;
|
|
436
|
-
case 5:
|
|
437
|
-
(_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, params);
|
|
399
|
+
(_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, params);
|
|
438
400
|
thunkApi.dispatch(handleNextScreenStep());
|
|
439
401
|
return [2, { leadResponse: leadResponse, formData: params }];
|
|
440
402
|
}
|
|
441
403
|
});
|
|
442
404
|
}); });
|
|
443
405
|
export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
444
|
-
var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
|
|
406
|
+
var _a, settings, connect, responseBody, leadBrandId, isNewBrand, brandName, salesChannels, selectedBrandItem, termAndConditionChecked, getAddress, channel_services, payload_1, brandReqBody_1, brand_1, brandNameBody, payload, lead, brandReqBody, brand;
|
|
445
407
|
var _b, _c, _d, _e, _f;
|
|
446
408
|
return __generator(this, function (_g) {
|
|
447
409
|
switch (_g.label) {
|
|
@@ -449,7 +411,7 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
449
411
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
450
412
|
responseBody = connect.data.otpData.responseBody;
|
|
451
413
|
leadBrandId = responseBody === null || responseBody === void 0 ? void 0 : responseBody.brand_id;
|
|
452
|
-
isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem;
|
|
414
|
+
isNewBrand = params.isNewBrand, brandName = params.brandName, salesChannels = params.salesChannels, selectedBrandItem = params.selectedBrandItem, termAndConditionChecked = params.termAndConditionChecked;
|
|
453
415
|
getAddress = function (value, isTwitter, isWeb) {
|
|
454
416
|
if (isTwitter)
|
|
455
417
|
return '@' + value;
|
|
@@ -678,15 +640,9 @@ export var connectSlice = createSlice({
|
|
|
678
640
|
extraReducers: function (builder) {
|
|
679
641
|
builder
|
|
680
642
|
.addCase(createMobileAuth.fulfilled, function (state, action) {
|
|
681
|
-
var _a;
|
|
682
643
|
state.loading = false;
|
|
683
644
|
state.error = null;
|
|
684
|
-
var
|
|
685
|
-
var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
686
|
-
if (description) {
|
|
687
|
-
state.error = description;
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
645
|
+
var _a = action.payload, formData = _a.formData, response = _a.response;
|
|
690
646
|
state.data.mobileData = formData;
|
|
691
647
|
state.data.mobileData.responseBody = response;
|
|
692
648
|
state.data.otpData.authFor = AuthForType.MOBILE;
|
|
@@ -700,14 +656,8 @@ export var connectSlice = createSlice({
|
|
|
700
656
|
state.error = action.error.message;
|
|
701
657
|
})
|
|
702
658
|
.addCase(resendOTPMobile.fulfilled, function (state, action) {
|
|
703
|
-
var _a;
|
|
704
659
|
state.error = null;
|
|
705
660
|
var response = action.payload;
|
|
706
|
-
var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
707
|
-
if (description) {
|
|
708
|
-
state.error = description;
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
661
|
state.data.mobileData.responseBody = response;
|
|
712
662
|
state.data.otpData.authFor = AuthForType.MOBILE;
|
|
713
663
|
})
|
|
@@ -722,15 +672,9 @@ export var connectSlice = createSlice({
|
|
|
722
672
|
state.error = null;
|
|
723
673
|
})
|
|
724
674
|
.addCase(createCivilIdAuth.fulfilled, function (state, action) {
|
|
725
|
-
var _a;
|
|
726
675
|
state.loading = false;
|
|
727
676
|
state.error = null;
|
|
728
|
-
var
|
|
729
|
-
var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
730
|
-
if (description) {
|
|
731
|
-
state.error = description;
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
677
|
+
var _a = action.payload, formData = _a.formData, response = _a.response;
|
|
734
678
|
state.data.otpData.authFor = AuthForType.NATIONAL_ID;
|
|
735
679
|
state.data.civilIdData = __assign(__assign({}, formData), { responseBody: response });
|
|
736
680
|
})
|
|
@@ -746,7 +690,7 @@ export var connectSlice = createSlice({
|
|
|
746
690
|
var _a;
|
|
747
691
|
state.loading = false;
|
|
748
692
|
state.error = null;
|
|
749
|
-
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse,
|
|
693
|
+
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, countryCode = _b.countryCode;
|
|
750
694
|
var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
|
|
751
695
|
var _c = contact || {}, email = _c.email, phone = _c.phone;
|
|
752
696
|
var fullName = concatenateObjectValues(name, ['first', 'middle', 'last']);
|
|
@@ -762,22 +706,20 @@ export var connectSlice = createSlice({
|
|
|
762
706
|
state.data.individualData.countryCode = countryCode;
|
|
763
707
|
if ((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en)
|
|
764
708
|
state.data.brandData.brandName = brand.name.en;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
state.data.brandData.selectedBrandItem = brandList[0];
|
|
774
|
-
}
|
|
775
|
-
state.data.brandData.responseBody = {
|
|
776
|
-
brand_list: brandList,
|
|
777
|
-
channel_list: channel_list
|
|
778
|
-
};
|
|
709
|
+
var brandList = [];
|
|
710
|
+
if ((brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) > 0) {
|
|
711
|
+
var isBrandExist = brand_list.find(function (item) { return item.id === (brand === null || brand === void 0 ? void 0 : brand.id); });
|
|
712
|
+
brandList = __spreadArray([], brand_list, true);
|
|
713
|
+
if (!isBrandExist && brand)
|
|
714
|
+
brandList = __spreadArray(__spreadArray([], brandList, true), [__assign(__assign({}, brand), { channel_services: [] })], false);
|
|
715
|
+
brandList = __spreadArray(__spreadArray([], brandList, true), [OTHER_BRAND], false);
|
|
716
|
+
state.data.brandData.selectedBrandItem = brandList[0];
|
|
779
717
|
}
|
|
780
|
-
state.data.
|
|
718
|
+
state.data.brandData.responseBody = {
|
|
719
|
+
brand_list: brandList,
|
|
720
|
+
channel_list: channel_list
|
|
721
|
+
};
|
|
722
|
+
state.data.otpData.responseBody = __assign(__assign({}, authResponse), { is_new_individual: is_new_individual, lead_id: id, brand_id: brand === null || brand === void 0 ? void 0 : brand.id, name: name, contact: contact });
|
|
781
723
|
})
|
|
782
724
|
.addCase(verifyPACI.rejected, function (state, action) {
|
|
783
725
|
state.loading = false;
|
|
@@ -790,7 +732,7 @@ export var connectSlice = createSlice({
|
|
|
790
732
|
var _a;
|
|
791
733
|
state.loading = false;
|
|
792
734
|
state.error = null;
|
|
793
|
-
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse,
|
|
735
|
+
var _b = action.payload, authResponse = _b.authResponse, leadResponse = _b.leadResponse, countryCode = _b.countryCode;
|
|
794
736
|
var name = leadResponse.name, contact = leadResponse.contact, brand = leadResponse.brand, brand_list = leadResponse.brand_list, channel_list = leadResponse.channel_list, is_new_individual = leadResponse.is_new_individual, id = leadResponse.id;
|
|
795
737
|
var _c = contact || {}, email = _c.email, phone = _c.phone;
|
|
796
738
|
var fullName = concatenateObjectValues(name, ['first', 'middle', 'last']);
|
|
@@ -806,22 +748,20 @@ export var connectSlice = createSlice({
|
|
|
806
748
|
state.data.individualData.countryCode = countryCode;
|
|
807
749
|
if ((_a = brand === null || brand === void 0 ? void 0 : brand.name) === null || _a === void 0 ? void 0 : _a.en)
|
|
808
750
|
state.data.brandData.brandName = brand.name.en;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
state.data.brandData.selectedBrandItem = brandList[0];
|
|
818
|
-
}
|
|
819
|
-
state.data.brandData.responseBody = {
|
|
820
|
-
brand_list: brandList,
|
|
821
|
-
channel_list: channel_list
|
|
822
|
-
};
|
|
751
|
+
var brandList = [];
|
|
752
|
+
if ((brand_list === null || brand_list === void 0 ? void 0 : brand_list.length) > 0) {
|
|
753
|
+
var isBrandExist = brand_list.find(function (item) { return item.id === (brand === null || brand === void 0 ? void 0 : brand.id); });
|
|
754
|
+
brandList = __spreadArray([], brand_list, true);
|
|
755
|
+
if (!isBrandExist && brand)
|
|
756
|
+
brandList = __spreadArray(__spreadArray([], brandList, true), [__assign(__assign({}, brand), { channel_services: [] })], false);
|
|
757
|
+
brandList = __spreadArray(__spreadArray([], brandList, true), [OTHER_BRAND], false);
|
|
758
|
+
state.data.brandData.selectedBrandItem = brandList[0];
|
|
823
759
|
}
|
|
824
|
-
state.data.
|
|
760
|
+
state.data.brandData.responseBody = {
|
|
761
|
+
brand_list: brandList,
|
|
762
|
+
channel_list: channel_list
|
|
763
|
+
};
|
|
764
|
+
state.data.otpData.responseBody = __assign(__assign({}, authResponse), { is_new_individual: is_new_individual, lead_id: id, brand_id: brand === null || brand === void 0 ? void 0 : brand.id, name: name, contact: contact });
|
|
825
765
|
})
|
|
826
766
|
.addCase(verifyAuth.pending, function (state) {
|
|
827
767
|
state.loading = true;
|
|
@@ -832,15 +772,9 @@ export var connectSlice = createSlice({
|
|
|
832
772
|
state.error = action.error.message;
|
|
833
773
|
})
|
|
834
774
|
.addCase(createNIDAuth.fulfilled, function (state, action) {
|
|
835
|
-
var _a;
|
|
836
775
|
state.loading = false;
|
|
837
776
|
state.error = null;
|
|
838
|
-
var
|
|
839
|
-
var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
840
|
-
if (description) {
|
|
841
|
-
state.error = description;
|
|
842
|
-
return;
|
|
843
|
-
}
|
|
777
|
+
var _a = action.payload, formData = _a.formData, response = _a.response;
|
|
844
778
|
state.data.nidData = formData;
|
|
845
779
|
state.data.nidData.responseBody = response;
|
|
846
780
|
state.data.otpData.authFor = AuthForType.NATIONAL_ID;
|
|
@@ -854,14 +788,8 @@ export var connectSlice = createSlice({
|
|
|
854
788
|
state.error = action.error.message;
|
|
855
789
|
})
|
|
856
790
|
.addCase(resendOTPNID.fulfilled, function (state, action) {
|
|
857
|
-
var _a;
|
|
858
791
|
state.error = null;
|
|
859
792
|
var response = action.payload;
|
|
860
|
-
var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
861
|
-
if (description) {
|
|
862
|
-
state.error = description;
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
793
|
state.data.nidData.responseBody = response;
|
|
866
794
|
state.data.otpData.authFor = AuthForType.NATIONAL_ID;
|
|
867
795
|
})
|
|
@@ -875,7 +803,7 @@ export var connectSlice = createSlice({
|
|
|
875
803
|
state.loading = false;
|
|
876
804
|
state.error = null;
|
|
877
805
|
var _a = action.payload, formData = _a.formData, leadResponse = _a.leadResponse;
|
|
878
|
-
var brand = leadResponse.brand,
|
|
806
|
+
var brand = leadResponse.brand, rest = __rest(leadResponse, ["brand"]);
|
|
879
807
|
if (brand) {
|
|
880
808
|
var channel_services = brand.channel_services, terms = brand.terms;
|
|
881
809
|
state.data.brandData.salesChannels = channel_services || [];
|
|
@@ -885,9 +813,6 @@ export var connectSlice = createSlice({
|
|
|
885
813
|
});
|
|
886
814
|
state.data.brandData.termAndConditionChecked = !!termAndCondition;
|
|
887
815
|
}
|
|
888
|
-
if (channel_list) {
|
|
889
|
-
state.data.brandData.responseBody = __assign(__assign({}, state.data.brandData.responseBody), { channel_list: channel_list });
|
|
890
|
-
}
|
|
891
816
|
state.data.individualData = formData;
|
|
892
817
|
state.data.individualData.responseBody = rest;
|
|
893
818
|
})
|