@tap-payments/auth-jsconnect 2.1.37-test → 2.1.39-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/@types/form.d.ts +4 -7
- package/build/api/auth.d.ts +4 -3
- package/build/api/auth.js +8 -4
- package/build/api/entity.d.ts +0 -8
- package/build/api/entity.js +0 -15
- package/build/api/file.d.ts +13 -0
- package/build/api/file.js +24 -0
- package/build/api/index.d.ts +11 -6
- package/build/api/index.js +3 -1
- package/build/assets/locales/ar.json +5 -1
- package/build/assets/locales/en.json +5 -1
- package/build/components/FileInput/DragAndDrop.js +1 -1
- package/build/components/ProgressBar/CircularProgressBar.d.ts +3 -1
- package/build/components/ProgressBar/CircularProgressBar.js +2 -2
- package/build/components/SimpleList/SimpleList.d.ts +1 -1
- package/build/components/SimpleList/SimpleList.js +3 -3
- package/build/constants/api.d.ts +2 -0
- package/build/constants/api.js +4 -0
- package/build/constants/assets.d.ts +1 -0
- package/build/constants/assets.js +1 -0
- package/build/constants/validation.d.ts +1 -0
- package/build/constants/validation.js +1 -0
- package/build/features/app/auth/authStore.js +1 -1
- package/build/features/app/bank/bankStore.js +1 -1
- package/build/features/app/business/businessStore.d.ts +7 -9
- package/build/features/app/business/businessStore.js +29 -67
- package/build/features/app/connect/connectStore.js +21 -33
- package/build/features/app/connectExpress/connectExpressStore.d.ts +18 -5
- package/build/features/app/connectExpress/connectExpressStore.js +197 -6
- package/build/features/app/individual/individualStore.d.ts +4 -16
- package/build/features/app/individual/individualStore.js +11 -89
- package/build/features/app/signIn/signInStore.js +13 -41
- package/build/features/brand/screens/BrandActivities/ActivitiesList.js +1 -1
- package/build/features/brand/screens/BrandInfo/SalesChannels.js +6 -6
- package/build/features/brand/screens/BrandInfo/Segments.js +1 -1
- package/build/features/brand/screens/BrandInfo/TeamSize.js +1 -1
- package/build/features/business/screens/Activities/ActivitiesList.js +1 -1
- package/build/features/business/screens/BusinessType/Article.js +10 -13
- package/build/features/business/screens/BusinessType/BusinessType.js +2 -4
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +12 -50
- package/build/features/business/screens/BusinessType/validation.d.ts +3 -6
- package/build/features/business/screens/BusinessType/validation.js +1 -11
- package/build/features/connect/screens/Merchant/SalesChannels.js +4 -3
- package/build/features/connectExpress/ConnectExpress.d.ts +3 -2
- package/build/features/connectExpress/ConnectExpress.js +7 -14
- package/build/features/connectExpress/screens/CivilID/CivilID.js +13 -31
- package/build/features/connectExpress/screens/CivilID/IDNumber.js +0 -4
- package/build/features/connectExpress/screens/Mobile/Mobile.js +25 -49
- package/build/features/connectExpress/screens/NID/DOB.js +2 -2
- package/build/features/connectExpress/screens/NID/IDNumber.js +1 -5
- package/build/features/connectExpress/screens/NID/NID.js +11 -16
- package/build/features/connectExpress/screens/OTP/OTP.js +13 -23
- package/build/features/entity/screens/EntityCapital/ActivityList.js +1 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +18 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +11 -62
- package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +11 -59
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +6 -12
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +2 -23
- package/build/features/shared/Address/CountryList.js +1 -1
- package/build/features/shared/Address/InputSelect.js +1 -1
- package/build/features/shared/SalesChannels/SalesChannel.d.ts +3 -2
- package/build/features/shared/SalesChannels/SalesChannel.js +25 -11
- package/build/features/shared/UploadFile/UploadFile.js +1 -1
- package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +38 -0
- package/build/features/shared/UploadMultipleFile/UploadFile.js +184 -1
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +27 -0
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +147 -1
- package/build/features/shared/UploadMultipleFile/index.d.ts +2 -0
- package/build/features/shared/UploadMultipleFile/index.js +2 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.js +1 -0
- package/build/hooks/useCountry.d.ts +4 -0
- package/build/hooks/useCountry.js +7 -0
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -3
- package/build/theme/typography.js +1 -1
- package/package.json +1 -1
|
@@ -441,36 +441,36 @@ export var retrieveBoardDetails = createAsyncThunk('retrieveBoardDetails', funct
|
|
|
441
441
|
});
|
|
442
442
|
}); });
|
|
443
443
|
export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
444
|
-
var _a, settings, business, isNonSA, isFL, payload, data, entity_activities, list, accountBody, accountData, documentData, entityData, entityId,
|
|
445
|
-
var _c, _d, _e, _f, _g
|
|
446
|
-
return __generator(this, function (
|
|
447
|
-
switch (
|
|
444
|
+
var _a, settings, business, isNonSA, isFL, payload, data, entity_activities, list, accountBody, accountData, documentData, entityData, entityId, articleId, documentBody, payload_1;
|
|
445
|
+
var _b, _c, _d, _e, _f, _g;
|
|
446
|
+
return __generator(this, function (_h) {
|
|
447
|
+
switch (_h.label) {
|
|
448
448
|
case 0:
|
|
449
449
|
_a = thunkApi.getState(), settings = _a.settings, business = _a.business;
|
|
450
450
|
isNonSA = !isSA(settings.data.businessCountry.iso2);
|
|
451
|
-
isFL = ((
|
|
451
|
+
isFL = ((_b = params.selectedLicense) === null || _b === void 0 ? void 0 : _b.type) === BusinessType.FL;
|
|
452
452
|
payload = {
|
|
453
|
-
id: ((
|
|
453
|
+
id: ((_c = business.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id) || '',
|
|
454
454
|
license_number: isNonSA && isFL ? '' : params.licenseNumber,
|
|
455
455
|
license_type: isFL ? 'freelance' : 'commercial_registration',
|
|
456
|
-
business_type: (
|
|
456
|
+
business_type: (_d = params.selectedLicense) === null || _d === void 0 ? void 0 : _d.type,
|
|
457
457
|
step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_INFO,
|
|
458
458
|
business: isNonSA && isFL ? undefined : { ar: params.entityLegalName, en: params.entityLegalName },
|
|
459
459
|
encryption_contract: ['license_number', 'business_type', 'license_type']
|
|
460
460
|
};
|
|
461
461
|
return [4, API.leadService.updateLead(payload)];
|
|
462
462
|
case 1:
|
|
463
|
-
data =
|
|
463
|
+
data = _h.sent();
|
|
464
464
|
entity_activities = data.entity_activities;
|
|
465
465
|
if (!!entity_activities) return [3, 3];
|
|
466
466
|
return [4, API.dataService.getActivities()];
|
|
467
467
|
case 2:
|
|
468
|
-
list = (
|
|
468
|
+
list = (_h.sent()).list;
|
|
469
469
|
data.entity_activities = list;
|
|
470
|
-
|
|
470
|
+
_h.label = 3;
|
|
471
471
|
case 3:
|
|
472
472
|
accountBody = {
|
|
473
|
-
lead_id: (
|
|
473
|
+
lead_id: (_e = business.data.verify.responseBody) === null || _e === void 0 ? void 0 : _e.lead_id,
|
|
474
474
|
notify: {
|
|
475
475
|
email: false,
|
|
476
476
|
phone: false
|
|
@@ -481,23 +481,23 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
|
|
|
481
481
|
};
|
|
482
482
|
return [4, API.accountService.createAccount(accountBody)];
|
|
483
483
|
case 4:
|
|
484
|
-
accountData =
|
|
484
|
+
accountData = _h.sent();
|
|
485
485
|
entityData = undefined;
|
|
486
486
|
entityId = accountData === null || accountData === void 0 ? void 0 : accountData.entity_id;
|
|
487
|
-
|
|
488
|
-
if (!certificateId) return [3, 6];
|
|
487
|
+
articleId = business.data.businessTypeData.articleId;
|
|
488
|
+
if (!((params.certificateId || []).length > 0)) return [3, 6];
|
|
489
489
|
documentBody = {
|
|
490
490
|
entity_id: entityId || '',
|
|
491
491
|
documents: [
|
|
492
492
|
{
|
|
493
|
-
images:
|
|
493
|
+
images: params.certificateId
|
|
494
494
|
}
|
|
495
495
|
]
|
|
496
496
|
};
|
|
497
497
|
return [4, API.entityService.updateDocumentInfo(documentBody)];
|
|
498
498
|
case 5:
|
|
499
|
-
documentData =
|
|
500
|
-
|
|
499
|
+
documentData = _h.sent();
|
|
500
|
+
_h.label = 6;
|
|
501
501
|
case 6:
|
|
502
502
|
if (!(articleId && entityId)) return [3, 8];
|
|
503
503
|
payload_1 = {
|
|
@@ -506,40 +506,15 @@ export var updateLeadBusinessType = createAsyncThunk('updateLeadBusinessType', f
|
|
|
506
506
|
};
|
|
507
507
|
return [4, API.entityService.updateEntity(payload_1)];
|
|
508
508
|
case 7:
|
|
509
|
-
entityData =
|
|
510
|
-
|
|
509
|
+
entityData = _h.sent();
|
|
510
|
+
_h.label = 8;
|
|
511
511
|
case 8:
|
|
512
512
|
thunkApi.dispatch(handleNextScreenStep());
|
|
513
|
-
(
|
|
513
|
+
(_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, params);
|
|
514
514
|
return [2, { data: data, formData: params, accountData: accountData, documentData: documentData, entityData: entityData }];
|
|
515
515
|
}
|
|
516
516
|
});
|
|
517
517
|
}); });
|
|
518
|
-
export var uploadLicenseCertificate = createAsyncThunk('uploadLicenseCertificate', function (_a) {
|
|
519
|
-
var file = _a.file, onProgress = _a.onProgress;
|
|
520
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
521
|
-
var uploadPayload, onUploadProgress, data;
|
|
522
|
-
return __generator(this, function (_b) {
|
|
523
|
-
switch (_b.label) {
|
|
524
|
-
case 0:
|
|
525
|
-
uploadPayload = {
|
|
526
|
-
file_link_create: true,
|
|
527
|
-
title: file === null || file === void 0 ? void 0 : file.name,
|
|
528
|
-
purpose: 'commercial_registration',
|
|
529
|
-
file: file
|
|
530
|
-
};
|
|
531
|
-
onUploadProgress = function (progressEvent) {
|
|
532
|
-
var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
|
|
533
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.floor(progress));
|
|
534
|
-
};
|
|
535
|
-
return [4, API.entityService.uploadFileInfo(uploadPayload, { onUploadProgress: onUploadProgress })];
|
|
536
|
-
case 1:
|
|
537
|
-
data = _b.sent();
|
|
538
|
-
return [2, { data: data }];
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
});
|
|
543
518
|
export var uploadArticle = createAsyncThunk('businessUploadArticle', function (_a) {
|
|
544
519
|
var file = _a.file, onProgress = _a.onProgress;
|
|
545
520
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -561,7 +536,7 @@ export var uploadArticle = createAsyncThunk('businessUploadArticle', function (_
|
|
|
561
536
|
var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
|
|
562
537
|
onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.floor(progress));
|
|
563
538
|
};
|
|
564
|
-
return [4, API.
|
|
539
|
+
return [4, API.fileService.uploadFileInfo(uploadPayload, { onUploadProgress: onUploadProgress })];
|
|
565
540
|
case 1:
|
|
566
541
|
data = _c.sent();
|
|
567
542
|
return [2, { data: data }];
|
|
@@ -732,6 +707,7 @@ var initialState = {
|
|
|
732
707
|
customLoading: false,
|
|
733
708
|
uploading: false,
|
|
734
709
|
uploadingArticle: false,
|
|
710
|
+
uploadingArticleError: null,
|
|
735
711
|
data: {
|
|
736
712
|
flowName: FlowsTypes.BUSINESS,
|
|
737
713
|
verify: {
|
|
@@ -779,11 +755,11 @@ export var businessSlice = createSlice({
|
|
|
779
755
|
resetOTPScreen: function (state) {
|
|
780
756
|
state.data.otpData.otp = '';
|
|
781
757
|
},
|
|
782
|
-
clearCertificateId: function (state) {
|
|
783
|
-
state.data.businessTypeData.certificateId = '';
|
|
784
|
-
},
|
|
785
758
|
clearArticleId: function (state) {
|
|
786
759
|
state.data.businessTypeData.articleId = '';
|
|
760
|
+
},
|
|
761
|
+
uploadingStatus: function (state, action) {
|
|
762
|
+
state.uploading = action.payload;
|
|
787
763
|
}
|
|
788
764
|
},
|
|
789
765
|
extraReducers: function (builder) {
|
|
@@ -1064,34 +1040,20 @@ export var businessSlice = createSlice({
|
|
|
1064
1040
|
.addCase(updateLeadBusinessType.rejected, function (state, action) {
|
|
1065
1041
|
state.loading = false;
|
|
1066
1042
|
state.error = action.error.message;
|
|
1067
|
-
})
|
|
1068
|
-
.addCase(uploadLicenseCertificate.pending, function (state) {
|
|
1069
|
-
state.error = null;
|
|
1070
|
-
state.uploading = true;
|
|
1071
|
-
})
|
|
1072
|
-
.addCase(uploadLicenseCertificate.fulfilled, function (state, action) {
|
|
1073
|
-
state.error = null;
|
|
1074
|
-
state.uploading = false;
|
|
1075
|
-
var data = action.payload.data;
|
|
1076
|
-
state.data.businessTypeData.certificateId = data === null || data === void 0 ? void 0 : data.id;
|
|
1077
|
-
})
|
|
1078
|
-
.addCase(uploadLicenseCertificate.rejected, function (state) {
|
|
1079
|
-
state.uploading = false;
|
|
1080
|
-
state.error = 'file_upload_error';
|
|
1081
1043
|
})
|
|
1082
1044
|
.addCase(uploadArticle.pending, function (state) {
|
|
1083
|
-
state.
|
|
1045
|
+
state.uploadingArticleError = null;
|
|
1084
1046
|
state.uploadingArticle = true;
|
|
1085
1047
|
})
|
|
1086
1048
|
.addCase(uploadArticle.fulfilled, function (state, action) {
|
|
1087
|
-
state.
|
|
1049
|
+
state.uploadingArticleError = null;
|
|
1088
1050
|
state.uploadingArticle = false;
|
|
1089
1051
|
var data = action.payload.data;
|
|
1090
1052
|
state.data.businessTypeData.articleId = data === null || data === void 0 ? void 0 : data.id;
|
|
1091
1053
|
})
|
|
1092
1054
|
.addCase(uploadArticle.rejected, function (state) {
|
|
1093
1055
|
state.uploadingArticle = false;
|
|
1094
|
-
state.
|
|
1056
|
+
state.uploadingArticleError = 'file_upload_article_error';
|
|
1095
1057
|
})
|
|
1096
1058
|
.addCase(updateActivitiesInfo.pending, function (state) {
|
|
1097
1059
|
state.loading = true;
|
|
@@ -1175,6 +1137,6 @@ export var businessSlice = createSlice({
|
|
|
1175
1137
|
});
|
|
1176
1138
|
}
|
|
1177
1139
|
});
|
|
1178
|
-
export var clearError = (_a = businessSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen,
|
|
1140
|
+
export var clearError = (_a = businessSlice.actions, _a.clearError), stopLoader = _a.stopLoader, resetOTPScreen = _a.resetOTPScreen, clearArticleId = _a.clearArticleId, uploadingStatus = _a.uploadingStatus;
|
|
1179
1141
|
export default businessSlice.reducer;
|
|
1180
1142
|
export var businessSelector = function (state) { return state.business; };
|
|
@@ -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;
|
|
79
|
+
return __generator(this, function (_c) {
|
|
80
|
+
switch (_c.label) {
|
|
81
81
|
case 0:
|
|
82
82
|
settings = thunkApi.getState().settings;
|
|
83
83
|
requestBody = {
|
|
@@ -95,20 +95,18 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
|
|
|
95
95
|
};
|
|
96
96
|
return [4, API.authService.createAuth(requestBody)];
|
|
97
97
|
case 1:
|
|
98
|
-
data =
|
|
99
|
-
if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
100
|
-
throw new Error(data.errors[0].description);
|
|
98
|
+
data = _c.sent();
|
|
101
99
|
thunkApi.dispatch(handleNextScreenStep());
|
|
102
|
-
(
|
|
100
|
+
(_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
103
101
|
return [2, { response: data, formData: params }];
|
|
104
102
|
}
|
|
105
103
|
});
|
|
106
104
|
}); });
|
|
107
105
|
export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
106
|
var settings, requestBody, data;
|
|
109
|
-
var _a, _b
|
|
110
|
-
return __generator(this, function (
|
|
111
|
-
switch (
|
|
107
|
+
var _a, _b;
|
|
108
|
+
return __generator(this, function (_c) {
|
|
109
|
+
switch (_c.label) {
|
|
112
110
|
case 0:
|
|
113
111
|
settings = thunkApi.getState().settings;
|
|
114
112
|
requestBody = {
|
|
@@ -126,20 +124,17 @@ export var createCivilIdAuth = createAsyncThunk('createCivilIdAuth', function (p
|
|
|
126
124
|
};
|
|
127
125
|
return [4, API.authService.createAuth(requestBody)];
|
|
128
126
|
case 1:
|
|
129
|
-
data =
|
|
130
|
-
if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
131
|
-
throw new Error(data.errors[0].description);
|
|
127
|
+
data = _c.sent();
|
|
132
128
|
thunkApi.dispatch(handleNextScreenStep());
|
|
133
|
-
(
|
|
129
|
+
(_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
134
130
|
return [2, { response: data, formData: params }];
|
|
135
131
|
}
|
|
136
132
|
});
|
|
137
133
|
}); });
|
|
138
134
|
export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
135
|
var _a, settings, connect, _b, mobile, countryCode, requestBody, data;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
switch (_d.label) {
|
|
136
|
+
return __generator(this, function (_c) {
|
|
137
|
+
switch (_c.label) {
|
|
143
138
|
case 0:
|
|
144
139
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
145
140
|
_b = connect.data.mobileData, mobile = _b.mobile, countryCode = _b.countryCode;
|
|
@@ -158,18 +153,15 @@ export var resendOTPMobile = createAsyncThunk('resendOTPMobile', function (param
|
|
|
158
153
|
};
|
|
159
154
|
return [4, API.authService.createAuth(requestBody)];
|
|
160
155
|
case 1:
|
|
161
|
-
data =
|
|
162
|
-
if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
163
|
-
throw new Error(data.errors[0].description);
|
|
156
|
+
data = _c.sent();
|
|
164
157
|
return [2, data];
|
|
165
158
|
}
|
|
166
159
|
});
|
|
167
160
|
}); });
|
|
168
161
|
export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
162
|
var _a, settings, connect, _b, nid, dob, type, requestBody, data;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
switch (_d.label) {
|
|
163
|
+
return __generator(this, function (_c) {
|
|
164
|
+
switch (_c.label) {
|
|
173
165
|
case 0:
|
|
174
166
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
175
167
|
_b = connect.data.nidData, nid = _b.nid, dob = _b.dob, type = _b.type;
|
|
@@ -195,18 +187,16 @@ export var resendOTPNID = createAsyncThunk('resendOTPNID', function (params, thu
|
|
|
195
187
|
};
|
|
196
188
|
return [4, API.authService.createAuth(requestBody)];
|
|
197
189
|
case 1:
|
|
198
|
-
data =
|
|
199
|
-
if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
|
|
200
|
-
throw new Error(data.errors[0].description);
|
|
190
|
+
data = _c.sent();
|
|
201
191
|
return [2, data];
|
|
202
192
|
}
|
|
203
193
|
});
|
|
204
194
|
}); });
|
|
205
195
|
export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
206
196
|
var settings, identification_id_type, requestBody, data;
|
|
207
|
-
var _a, _b
|
|
208
|
-
return __generator(this, function (
|
|
209
|
-
switch (
|
|
197
|
+
var _a, _b;
|
|
198
|
+
return __generator(this, function (_c) {
|
|
199
|
+
switch (_c.label) {
|
|
210
200
|
case 0:
|
|
211
201
|
settings = thunkApi.getState().settings;
|
|
212
202
|
identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
|
|
@@ -232,11 +222,9 @@ export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, t
|
|
|
232
222
|
};
|
|
233
223
|
return [4, API.authService.createAuth(requestBody)];
|
|
234
224
|
case 1:
|
|
235
|
-
data =
|
|
236
|
-
if ((_a = data.errors) === null || _a === void 0 ? void 0 : _a.length)
|
|
237
|
-
throw new Error(data.errors[0].description);
|
|
225
|
+
data = _c.sent();
|
|
238
226
|
thunkApi.dispatch(handleNextScreenStep());
|
|
239
|
-
(
|
|
227
|
+
(_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
240
228
|
return [2, { response: data, formData: __assign(__assign({}, params), { type: identification_id_type }) }];
|
|
241
229
|
}
|
|
242
230
|
});
|
|
@@ -2,6 +2,19 @@ import { RootState } from '../../../app/store';
|
|
|
2
2
|
import { MobileFormValues, NIDFormValues, CivilFormValues, OTPFormValues, SharedState, FlowsTypes, ActionState, CountryCode, AuthForType } from '../../../@types';
|
|
3
3
|
export declare const getLeadByIdAsync: import("@reduxjs/toolkit").AsyncThunk<any, string, {}>;
|
|
4
4
|
export declare const getBrandListAsync: import("@reduxjs/toolkit").AsyncThunk<any, string, {}>;
|
|
5
|
+
export declare const createMobileAuthAsync: import("@reduxjs/toolkit").AsyncThunk<{
|
|
6
|
+
response: any;
|
|
7
|
+
formData: MobileFormValues;
|
|
8
|
+
}, MobileFormValues, {}>;
|
|
9
|
+
export declare const createNIDAuthAsync: import("@reduxjs/toolkit").AsyncThunk<{
|
|
10
|
+
response: any;
|
|
11
|
+
formData: NIDFormValues;
|
|
12
|
+
}, NIDFormValues, {}>;
|
|
13
|
+
export declare const createCivilAuthAsync: import("@reduxjs/toolkit").AsyncThunk<{
|
|
14
|
+
response: any;
|
|
15
|
+
formData: CivilFormValues;
|
|
16
|
+
}, CivilFormValues, {}>;
|
|
17
|
+
export declare const verifyOtpAsync: import("@reduxjs/toolkit").AsyncThunk<any, OTPFormValues, {}>;
|
|
5
18
|
interface ResponseData {
|
|
6
19
|
responseData?: Record<string, any>;
|
|
7
20
|
}
|
|
@@ -9,18 +22,18 @@ export interface ConnectExpressData {
|
|
|
9
22
|
isLeadIdPassed: boolean;
|
|
10
23
|
postURL: string;
|
|
11
24
|
mobileData: MobileFormValues;
|
|
12
|
-
nidData: NIDFormValues
|
|
13
|
-
type: string;
|
|
14
|
-
};
|
|
25
|
+
nidData: NIDFormValues;
|
|
15
26
|
civilIdData: CivilFormValues;
|
|
16
27
|
otpData: OTPFormValues & {
|
|
17
28
|
authFor: AuthForType;
|
|
18
29
|
};
|
|
19
30
|
flowName: FlowsTypes;
|
|
31
|
+
leadId?: string;
|
|
20
32
|
}
|
|
21
33
|
export interface ConnectExpressState extends SharedState<ConnectExpressData & ResponseData> {
|
|
22
34
|
}
|
|
23
35
|
export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectExpressState, {
|
|
36
|
+
setLeadId(state: ConnectExpressState, action: ActionState<string>): void;
|
|
24
37
|
setIsLeadIdPassed: (state: ConnectExpressState, action: ActionState<boolean>) => void;
|
|
25
38
|
clearError: (state: ConnectExpressState) => void;
|
|
26
39
|
setError(state: ConnectExpressState, action: ActionState<string>): void;
|
|
@@ -29,11 +42,11 @@ export declare const connectSlice: import("@reduxjs/toolkit").Slice<ConnectExpre
|
|
|
29
42
|
resetMobileScreen: (state: ConnectExpressState, action: ActionState<CountryCode>) => void;
|
|
30
43
|
resetNIDScreen: (state: ConnectExpressState) => void;
|
|
31
44
|
resetCivilScreen: (state: ConnectExpressState) => void;
|
|
32
|
-
|
|
45
|
+
resetOTPValue: (state: ConnectExpressState) => void;
|
|
33
46
|
setPostUrl: (state: ConnectExpressState, action: ActionState<string>) => void;
|
|
34
47
|
resetStore: (state: ConnectExpressState) => void;
|
|
35
48
|
}, "connectExpress/store">;
|
|
36
|
-
export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setIsLeadIdPassed: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>,
|
|
49
|
+
export declare const clearError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, stopLoader: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setIsLeadIdPassed: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, string>, resetMobileScreen: import("@reduxjs/toolkit").ActionCreatorWithPayload<CountryCode, string>, resetOTPValue: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetNIDScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCivilScreen: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetStore: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setError: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, setResponseData: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<Record<string, any> | undefined, string>, setPostUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>, setLeadId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, string>;
|
|
37
50
|
declare const _default: import("redux").Reducer<ConnectExpressState, import("redux").AnyAction>;
|
|
38
51
|
export default _default;
|
|
39
52
|
export declare const connectExpressSelector: (state: RootState) => ConnectExpressState;
|
|
@@ -47,10 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
var _a;
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
|
+
import { handleNextScreenStep } from '../../../app/settings';
|
|
50
51
|
import { FlowsTypes, AuthForType } from '../../../@types';
|
|
51
52
|
import API from '../../../api';
|
|
53
|
+
import { CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE } from '../../../constants';
|
|
52
54
|
import { defaultCountry } from '../../../constants';
|
|
53
|
-
import { getEighteenYearsAgo } from '../../../utils';
|
|
55
|
+
import { getEighteenYearsAgo, sleep } from '../../../utils';
|
|
54
56
|
export var getLeadByIdAsync = createAsyncThunk('expressConnect/getLeadByIdAsync', function (leadId, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
57
|
var data;
|
|
56
58
|
return __generator(this, function (_a) {
|
|
@@ -73,6 +75,137 @@ export var getBrandListAsync = createAsyncThunk('expressConnect/getBrandListAsyn
|
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
77
|
}); });
|
|
78
|
+
export var createMobileAuthAsync = createAsyncThunk('connectExpress/createMobileAuthAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
+
var settings, requestBody, data;
|
|
80
|
+
var _a, _b;
|
|
81
|
+
return __generator(this, function (_c) {
|
|
82
|
+
switch (_c.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
settings = thunkApi.getState().settings;
|
|
85
|
+
requestBody = {
|
|
86
|
+
country: settings.data.businessCountry.iso2,
|
|
87
|
+
scope: settings.data.appConfig.scope,
|
|
88
|
+
lang: settings.data.language,
|
|
89
|
+
user_credentail: {
|
|
90
|
+
phone: params.mobile,
|
|
91
|
+
code: params.countryCode.idd_prefix.toString()
|
|
92
|
+
},
|
|
93
|
+
sign_in: false,
|
|
94
|
+
is_lead: true,
|
|
95
|
+
step_name: CONNECT_EXPRESS_STEP_NAMES.CREATE_AUTH_MOBILE,
|
|
96
|
+
encryption_contract: ['user_credentail.phone', 'user_credentail.code']
|
|
97
|
+
};
|
|
98
|
+
return [4, API.authService.createExpressAuth(requestBody)];
|
|
99
|
+
case 1:
|
|
100
|
+
data = _c.sent();
|
|
101
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
102
|
+
(_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
103
|
+
return [2, { response: data, formData: params }];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}); });
|
|
107
|
+
export var createNIDAuthAsync = createAsyncThunk('connectExpress/createNIDAuthAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
+
var settings, dob, nid, nidType, countryCode, requestBody, data;
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return __generator(this, function (_c) {
|
|
111
|
+
switch (_c.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
settings = thunkApi.getState().settings;
|
|
114
|
+
dob = params.dob, nid = params.nid;
|
|
115
|
+
nidType = nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
|
|
116
|
+
countryCode = settings.data.businessCountry.iso2;
|
|
117
|
+
requestBody = {
|
|
118
|
+
country: countryCode,
|
|
119
|
+
scope: settings.data.appConfig.scope,
|
|
120
|
+
lang: settings.data.language,
|
|
121
|
+
user_credentail: {
|
|
122
|
+
identification_id: nid,
|
|
123
|
+
identification_id_type: nidType,
|
|
124
|
+
date_of_birth: dob,
|
|
125
|
+
country_code: countryCode
|
|
126
|
+
},
|
|
127
|
+
sign_in: false,
|
|
128
|
+
is_lead: true,
|
|
129
|
+
step_name: CONNECT_EXPRESS_STEP_NAMES.CREATE_AUTH_NID,
|
|
130
|
+
encryption_contract: [
|
|
131
|
+
'user_credentail.country_code',
|
|
132
|
+
'user_credentail.identification_id',
|
|
133
|
+
'user_credentail.identification_id_type',
|
|
134
|
+
'user_credentail.date_of_birth'
|
|
135
|
+
]
|
|
136
|
+
};
|
|
137
|
+
return [4, API.authService.createExpressAuth(requestBody)];
|
|
138
|
+
case 1:
|
|
139
|
+
data = _c.sent();
|
|
140
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
141
|
+
(_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
142
|
+
return [2, { response: data, formData: params }];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); });
|
|
146
|
+
export var createCivilAuthAsync = createAsyncThunk('connectExpress/createCivilAuthAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
+
var settings, civilId, countryCode, requestBody, data;
|
|
148
|
+
var _a, _b;
|
|
149
|
+
return __generator(this, function (_c) {
|
|
150
|
+
switch (_c.label) {
|
|
151
|
+
case 0:
|
|
152
|
+
settings = thunkApi.getState().settings;
|
|
153
|
+
civilId = params.civilId;
|
|
154
|
+
countryCode = settings.data.businessCountry.iso2;
|
|
155
|
+
requestBody = {
|
|
156
|
+
country: countryCode,
|
|
157
|
+
scope: settings.data.appConfig.scope,
|
|
158
|
+
lang: settings.data.language,
|
|
159
|
+
user_credentail: {
|
|
160
|
+
identification_id: civilId,
|
|
161
|
+
country_code: countryCode
|
|
162
|
+
},
|
|
163
|
+
sign_in: false,
|
|
164
|
+
is_lead: true,
|
|
165
|
+
step_name: CONNECT_EXPRESS_STEP_NAMES.CREATE_AUTH_CIVIL_ID,
|
|
166
|
+
encryption_contract: ['user_credentail.identification_id']
|
|
167
|
+
};
|
|
168
|
+
return [4, API.authService.createAuth(requestBody)];
|
|
169
|
+
case 1:
|
|
170
|
+
data = _c.sent();
|
|
171
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
172
|
+
(_b = (_a = settings.data.appConfig).onStepCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, settings.data.activeScreen.name, requestBody.user_credentail);
|
|
173
|
+
return [2, { response: data, formData: params }];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}); });
|
|
177
|
+
export var verifyOtpAsync = createAsyncThunk('connectExpress/verifyOtpAsync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var _a, settings, connectExpress, _b, responseData, postURL, leadId, _c, verifyToken, device_token, service_name, payload, data;
|
|
179
|
+
var _d, _e;
|
|
180
|
+
return __generator(this, function (_f) {
|
|
181
|
+
switch (_f.label) {
|
|
182
|
+
case 0:
|
|
183
|
+
_a = thunkApi.getState(), settings = _a.settings, connectExpress = _a.connectExpress;
|
|
184
|
+
_b = connectExpress.data || {}, responseData = _b.responseData, postURL = _b.postURL, leadId = _b.leadId;
|
|
185
|
+
if (!(responseData === null || responseData === void 0 ? void 0 : responseData.authData))
|
|
186
|
+
throw new Error('Auth data is missing');
|
|
187
|
+
_c = responseData.authData, verifyToken = _c.verifyToken, device_token = _c.device_token, service_name = _c.service_name;
|
|
188
|
+
payload = {
|
|
189
|
+
auth_token: verifyToken,
|
|
190
|
+
lead_id: leadId,
|
|
191
|
+
data: params.otp,
|
|
192
|
+
post_url: postURL,
|
|
193
|
+
auth_type: 2,
|
|
194
|
+
device_token: device_token,
|
|
195
|
+
service_name: service_name || 'ABSHER',
|
|
196
|
+
sign_in: false,
|
|
197
|
+
terms: ['general'],
|
|
198
|
+
encryption_contract: ['data']
|
|
199
|
+
};
|
|
200
|
+
return [4, API.authService.verifyExpressAuth(payload)];
|
|
201
|
+
case 1:
|
|
202
|
+
data = _f.sent();
|
|
203
|
+
(_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, params);
|
|
204
|
+
sleep().then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
|
|
205
|
+
return [2, data];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}); });
|
|
76
209
|
var initialState = {
|
|
77
210
|
error: null,
|
|
78
211
|
loading: false,
|
|
@@ -86,8 +219,7 @@ var initialState = {
|
|
|
86
219
|
},
|
|
87
220
|
nidData: {
|
|
88
221
|
nid: '',
|
|
89
|
-
dob: getEighteenYearsAgo()
|
|
90
|
-
type: ''
|
|
222
|
+
dob: getEighteenYearsAgo()
|
|
91
223
|
},
|
|
92
224
|
civilIdData: {
|
|
93
225
|
civilId: ''
|
|
@@ -102,6 +234,9 @@ export var connectSlice = createSlice({
|
|
|
102
234
|
name: 'connectExpress/store',
|
|
103
235
|
initialState: initialState,
|
|
104
236
|
reducers: {
|
|
237
|
+
setLeadId: function (state, action) {
|
|
238
|
+
state.data.leadId = action.payload;
|
|
239
|
+
},
|
|
105
240
|
setIsLeadIdPassed: function (state, action) {
|
|
106
241
|
state.data.isLeadIdPassed = action.payload;
|
|
107
242
|
},
|
|
@@ -126,7 +261,7 @@ export var connectSlice = createSlice({
|
|
|
126
261
|
resetCivilScreen: function (state) {
|
|
127
262
|
state.data.civilIdData = __assign(__assign({}, state.data.civilIdData), initialState.data.civilIdData);
|
|
128
263
|
},
|
|
129
|
-
|
|
264
|
+
resetOTPValue: function (state) {
|
|
130
265
|
state.data.otpData.otp = '';
|
|
131
266
|
},
|
|
132
267
|
setPostUrl: function (state, action) {
|
|
@@ -135,7 +270,8 @@ export var connectSlice = createSlice({
|
|
|
135
270
|
resetStore: function (state) {
|
|
136
271
|
var countryCode = state.data.mobileData.countryCode;
|
|
137
272
|
var postURL = state.data.postURL;
|
|
138
|
-
|
|
273
|
+
var isLeadIdPassed = state.data.isLeadIdPassed;
|
|
274
|
+
state.data = __assign(__assign({}, initialState.data), { mobileData: __assign(__assign({}, initialState.data.mobileData), { countryCode: countryCode }), postURL: postURL, isLeadIdPassed: isLeadIdPassed });
|
|
139
275
|
}
|
|
140
276
|
},
|
|
141
277
|
extraReducers: function (builder) {
|
|
@@ -163,9 +299,64 @@ export var connectSlice = createSlice({
|
|
|
163
299
|
.addCase(getBrandListAsync.rejected, function (state, action) {
|
|
164
300
|
state.loading = false;
|
|
165
301
|
state.error = action.error.message;
|
|
302
|
+
})
|
|
303
|
+
.addCase(createMobileAuthAsync.pending, function (state) {
|
|
304
|
+
state.loading = true;
|
|
305
|
+
state.error = null;
|
|
306
|
+
})
|
|
307
|
+
.addCase(createMobileAuthAsync.fulfilled, function (state, action) {
|
|
308
|
+
state.loading = false;
|
|
309
|
+
state.data.mobileData = action.payload.formData;
|
|
310
|
+
state.data.otpData.authFor = AuthForType.NATIONAL_ID;
|
|
311
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authData: action.payload.response });
|
|
312
|
+
})
|
|
313
|
+
.addCase(createMobileAuthAsync.rejected, function (state, action) {
|
|
314
|
+
state.loading = false;
|
|
315
|
+
state.error = action.error.message;
|
|
316
|
+
})
|
|
317
|
+
.addCase(createNIDAuthAsync.pending, function (state) {
|
|
318
|
+
state.loading = true;
|
|
319
|
+
state.error = null;
|
|
320
|
+
})
|
|
321
|
+
.addCase(createNIDAuthAsync.fulfilled, function (state, action) {
|
|
322
|
+
state.loading = false;
|
|
323
|
+
state.data.nidData = action.payload.formData;
|
|
324
|
+
state.data.otpData.authFor = AuthForType.NATIONAL_ID;
|
|
325
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authData: action.payload.response });
|
|
326
|
+
})
|
|
327
|
+
.addCase(createNIDAuthAsync.rejected, function (state, action) {
|
|
328
|
+
state.loading = false;
|
|
329
|
+
state.error = action.error.message;
|
|
330
|
+
})
|
|
331
|
+
.addCase(createCivilAuthAsync.pending, function (state) {
|
|
332
|
+
state.loading = true;
|
|
333
|
+
state.error = null;
|
|
334
|
+
})
|
|
335
|
+
.addCase(createCivilAuthAsync.fulfilled, function (state, action) {
|
|
336
|
+
state.loading = false;
|
|
337
|
+
state.data.civilIdData = action.payload.formData;
|
|
338
|
+
state.data.otpData.authFor = AuthForType.NATIONAL_ID;
|
|
339
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authData: action.payload.response });
|
|
340
|
+
})
|
|
341
|
+
.addCase(createCivilAuthAsync.rejected, function (state, action) {
|
|
342
|
+
state.loading = false;
|
|
343
|
+
state.error = action.error.message;
|
|
344
|
+
})
|
|
345
|
+
.addCase(verifyOtpAsync.pending, function (state) {
|
|
346
|
+
state.loading = true;
|
|
347
|
+
state.error = null;
|
|
348
|
+
})
|
|
349
|
+
.addCase(verifyOtpAsync.fulfilled, function (state, action) {
|
|
350
|
+
var _a;
|
|
351
|
+
state.loading = false;
|
|
352
|
+
state.data.responseData = __assign(__assign({}, state.data.responseData), { authData: __assign(__assign({}, (_a = state.data.responseData) === null || _a === void 0 ? void 0 : _a.authData), action.payload) });
|
|
353
|
+
})
|
|
354
|
+
.addCase(verifyOtpAsync.rejected, function (state, action) {
|
|
355
|
+
state.loading = false;
|
|
356
|
+
state.error = action.error.message;
|
|
166
357
|
});
|
|
167
358
|
}
|
|
168
359
|
});
|
|
169
|
-
export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, setIsLeadIdPassed = _a.setIsLeadIdPassed, resetMobileScreen = _a.resetMobileScreen,
|
|
360
|
+
export var clearError = (_a = connectSlice.actions, _a.clearError), stopLoader = _a.stopLoader, setIsLeadIdPassed = _a.setIsLeadIdPassed, resetMobileScreen = _a.resetMobileScreen, resetOTPValue = _a.resetOTPValue, resetNIDScreen = _a.resetNIDScreen, resetCivilScreen = _a.resetCivilScreen, resetStore = _a.resetStore, setError = _a.setError, setResponseData = _a.setResponseData, setPostUrl = _a.setPostUrl, setLeadId = _a.setLeadId;
|
|
170
361
|
export default connectSlice.reducer;
|
|
171
362
|
export var connectExpressSelector = function (state) { return state.connectExpress; };
|