@tap-payments/auth-jsconnect 2.0.34 → 2.0.35
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 +6 -4
- package/build/api/entity.d.ts +25 -0
- package/build/api/entity.js +17 -1
- package/build/api/index.d.ts +5 -2
- package/build/api/individual.d.ts +1 -1
- package/build/api/lead.d.ts +1 -0
- package/build/api/lead.js +8 -1
- package/build/assets/locales/ar.json +3 -1
- package/build/assets/locales/en.json +3 -1
- package/build/components/FileInput/DragAndDrop.js +2 -1
- package/build/constants/app.js +1 -1
- package/build/constants/assets.d.ts +3 -0
- package/build/constants/assets.js +3 -0
- package/build/constants/validation.js +2 -2
- package/build/features/app/auth/authStore.js +6 -11
- package/build/features/app/bank/bankStore.js +16 -13
- package/build/features/app/business/businessStore.js +7 -4
- package/build/features/app/connect/connectStore.js +2 -2
- package/build/features/app/entity/entityStore.d.ts +27 -7
- package/build/features/app/entity/entityStore.js +218 -146
- package/build/features/app/individual/individualStore.js +14 -12
- package/build/features/app/tax/taxStore.js +15 -12
- package/build/features/bank/screens/BankDetails/BankDetails.js +1 -1
- package/build/features/bank/screens/BankDetails/BankName.js +2 -1
- package/build/features/connect/screens/Merchant/SalesChannels.js +1 -1
- package/build/features/connect/screens/Merchant/SocialMedia.js +2 -2
- package/build/features/connect/screens/Mobile/Mobile.js +2 -1
- package/build/features/connect/screens/VerifyPACI/VerifyPACI.js +1 -1
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +1 -0
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +20 -11
- package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +3 -0
- package/build/features/entity/screens/EntityInfoConfirm/Article.js +73 -0
- package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +12 -6
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +20 -5
- package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +25 -4
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +13 -18
- package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +12 -51
- package/build/features/entity/screens/EntityInfoConfirm/validation.js +17 -10
- package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/entity/screens/Verify/Verify.js +5 -5
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +1 -1
- package/build/features/password/screens/CreatePassword/CreatePassword.js +1 -1
- package/build/features/shared/UploadFile/UploadFile.d.ts +2 -1
- package/build/features/shared/UploadFile/UploadFile.js +3 -3
- package/build/features/tax/screens/TaxDetails/TaxDetails.js +1 -1
- package/build/utils/object.js +1 -1
- package/package.json +129 -129
- package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.d.ts +0 -5
- package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.js +0 -115
|
@@ -49,15 +49,15 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
|
-
import {
|
|
53
|
-
import { ENTITY_STEP_NAMES
|
|
52
|
+
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
53
|
+
import { ENTITY_STEP_NAMES } from '../../../constants';
|
|
54
54
|
import moment from 'moment';
|
|
55
55
|
import { convertNumbers2English } from '../../../utils';
|
|
56
56
|
export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var payload, data, boardInfoData, board_id, board_info_id, info, hasEntityCompleted;
|
|
58
|
-
var _a;
|
|
59
|
-
return __generator(this, function (
|
|
60
|
-
switch (
|
|
57
|
+
var payload, data, boardData, entityData, boardInfoData, board_id, board_info_id, entityId, countryIso2, info, hasEntityCompleted;
|
|
58
|
+
var _a, _b, _c, _d;
|
|
59
|
+
return __generator(this, function (_e) {
|
|
60
|
+
switch (_e.label) {
|
|
61
61
|
case 0:
|
|
62
62
|
payload = {
|
|
63
63
|
service_name: 'tap_email',
|
|
@@ -65,36 +65,57 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
|
|
|
65
65
|
};
|
|
66
66
|
return [4, API.leadService.verifyLeadToken(payload)];
|
|
67
67
|
case 1:
|
|
68
|
-
data = (
|
|
69
|
-
return [4, thunkApi.dispatch(retrieveChannels())];
|
|
70
|
-
case 2:
|
|
71
|
-
_b.sent();
|
|
68
|
+
data = (_e.sent()).data;
|
|
72
69
|
boardInfoData = undefined;
|
|
73
|
-
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3,
|
|
70
|
+
if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 8];
|
|
71
|
+
if (!(data.step_name !== ENTITY_STEP_NAMES.PHONE_AUTH)) return [3, 8];
|
|
74
72
|
board_id = data === null || data === void 0 ? void 0 : data.id;
|
|
75
73
|
board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
|
|
76
|
-
if (!(
|
|
74
|
+
if (!(board_id && board_info_id)) return [3, 3];
|
|
77
75
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
76
|
+
case 2:
|
|
77
|
+
boardInfoData = _e.sent();
|
|
78
|
+
_e.label = 3;
|
|
78
79
|
case 3:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
case 4:
|
|
80
|
+
if (!board_id) return [3, 5];
|
|
81
|
+
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
82
|
+
case 4:
|
|
83
|
+
boardData = _e.sent();
|
|
84
|
+
_e.label = 5;
|
|
82
85
|
case 5:
|
|
83
|
-
|
|
86
|
+
entityId = (_a = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _a === void 0 ? void 0 : _a.id;
|
|
87
|
+
if (!entityId) return [3, 7];
|
|
88
|
+
return [4, API.entityService.retrieveEntity(entityId)];
|
|
89
|
+
case 6:
|
|
90
|
+
entityData = _e.sent();
|
|
91
|
+
_e.label = 7;
|
|
92
|
+
case 7:
|
|
93
|
+
countryIso2 = entityData.country;
|
|
94
|
+
if (countryIso2)
|
|
95
|
+
thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
|
|
84
96
|
info = boardInfoData.info;
|
|
85
|
-
hasEntityCompleted = ((
|
|
86
|
-
|
|
87
|
-
if (data.step_name === ENTITY_STEP_NAMES.PHONE_AUTH) {
|
|
88
|
-
thunkApi.dispatch(handleCurrentActiveScreen('ENTITY_INFO_STEP'));
|
|
89
|
-
}
|
|
90
|
-
else if (hasEntityCompleted) {
|
|
97
|
+
hasEntityCompleted = ((_b = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'entity'; })) === null || _b === void 0 ? void 0 : _b.status) === 'completed';
|
|
98
|
+
if (hasEntityCompleted) {
|
|
91
99
|
thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
92
100
|
}
|
|
93
|
-
else
|
|
101
|
+
else {
|
|
94
102
|
thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
|
|
95
103
|
}
|
|
96
|
-
|
|
97
|
-
case
|
|
104
|
+
_e.label = 8;
|
|
105
|
+
case 8: return [2, {
|
|
106
|
+
data: data,
|
|
107
|
+
boardResponse: {
|
|
108
|
+
user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
|
|
109
|
+
brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
|
|
110
|
+
bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
|
|
111
|
+
entity: entityData === null || entityData === void 0 ? void 0 : entityData.entity,
|
|
112
|
+
merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
|
|
113
|
+
name: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _c === void 0 ? void 0 : _c.names,
|
|
114
|
+
contact: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.contact,
|
|
115
|
+
flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
|
|
116
|
+
},
|
|
117
|
+
token: token
|
|
118
|
+
}];
|
|
98
119
|
}
|
|
99
120
|
});
|
|
100
121
|
}); });
|
|
@@ -116,14 +137,13 @@ export var resendOTP = createAsyncThunk('entityResendOTP', function (params, thu
|
|
|
116
137
|
});
|
|
117
138
|
}); });
|
|
118
139
|
export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
-
var _a, entity, settings, responseBody,
|
|
120
|
-
var _b, _c, _d, _e;
|
|
121
|
-
return __generator(this, function (
|
|
122
|
-
switch (
|
|
140
|
+
var _a, entity, settings, responseBody, payload, data, boardData, entityData, boardInfoData, board_id, board_info_id, entityId, info, hasEntityCompleted;
|
|
141
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
142
|
+
return __generator(this, function (_j) {
|
|
143
|
+
switch (_j.label) {
|
|
123
144
|
case 0:
|
|
124
145
|
_a = thunkApi.getState(), entity = _a.entity, settings = _a.settings;
|
|
125
146
|
responseBody = entity.data.verify.responseBody;
|
|
126
|
-
flows = (responseBody || {}).flows;
|
|
127
147
|
payload = {
|
|
128
148
|
data: params.otp,
|
|
129
149
|
service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
|
|
@@ -133,18 +153,54 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
|
|
|
133
153
|
};
|
|
134
154
|
return [4, API.leadService.verifyLeadOTP(payload)];
|
|
135
155
|
case 1:
|
|
136
|
-
data = (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
156
|
+
data = (_j.sent()).data;
|
|
157
|
+
boardInfoData = undefined;
|
|
158
|
+
if (!!data.errors) return [3, 8];
|
|
159
|
+
board_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.id;
|
|
160
|
+
board_info_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.board_info_id;
|
|
161
|
+
if (!(board_id && board_info_id)) return [3, 3];
|
|
162
|
+
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
163
|
+
case 2:
|
|
164
|
+
boardInfoData = _j.sent();
|
|
165
|
+
_j.label = 3;
|
|
166
|
+
case 3:
|
|
167
|
+
if (!board_id) return [3, 5];
|
|
168
|
+
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
169
|
+
case 4:
|
|
170
|
+
boardData = _j.sent();
|
|
171
|
+
_j.label = 5;
|
|
172
|
+
case 5:
|
|
173
|
+
entityId = (_c = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _c === void 0 ? void 0 : _c.id;
|
|
174
|
+
if (!entityId) return [3, 7];
|
|
175
|
+
return [4, API.entityService.retrieveEntity(entityId)];
|
|
176
|
+
case 6:
|
|
177
|
+
entityData = _j.sent();
|
|
178
|
+
_j.label = 7;
|
|
179
|
+
case 7:
|
|
180
|
+
(_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, { otp: params.otp });
|
|
181
|
+
info = boardInfoData.info;
|
|
182
|
+
hasEntityCompleted = ((_f = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'entity'; })) === null || _f === void 0 ? void 0 : _f.status) === 'completed';
|
|
183
|
+
if (hasEntityCompleted) {
|
|
184
|
+
thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
146
185
|
}
|
|
147
|
-
|
|
186
|
+
else {
|
|
187
|
+
thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
|
|
188
|
+
}
|
|
189
|
+
_j.label = 8;
|
|
190
|
+
case 8: return [2, {
|
|
191
|
+
data: data,
|
|
192
|
+
boardResponse: {
|
|
193
|
+
user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
|
|
194
|
+
brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
|
|
195
|
+
bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
|
|
196
|
+
entity: entityData === null || entityData === void 0 ? void 0 : entityData.entity,
|
|
197
|
+
merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
|
|
198
|
+
name: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _g === void 0 ? void 0 : _g.names,
|
|
199
|
+
contact: (_h = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _h === void 0 ? void 0 : _h.contact,
|
|
200
|
+
flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
|
|
201
|
+
},
|
|
202
|
+
formData: params
|
|
203
|
+
}];
|
|
148
204
|
}
|
|
149
205
|
});
|
|
150
206
|
}); });
|
|
@@ -157,40 +213,85 @@ export var retrieveBoardDetails = createAsyncThunk('entityRetrieveEntityInfo', f
|
|
|
157
213
|
case 1:
|
|
158
214
|
data = _c.sent();
|
|
159
215
|
return [2, {
|
|
160
|
-
data: __assign(__assign({}, data), { user: data === null || data === void 0 ? void 0 : data.user, brand: data === null || data === void 0 ? void 0 : data.brand, bank_account: data === null || data === void 0 ? void 0 : data.bank_account, entity: data === null || data === void 0 ? void 0 : data.entity, merchant: data === null || data === void 0 ? void 0 : data.merchant, name: (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.
|
|
216
|
+
data: __assign(__assign({}, data), { user: data === null || data === void 0 ? void 0 : data.user, brand: data === null || data === void 0 ? void 0 : data.brand, bank_account: data === null || data === void 0 ? void 0 : data.bank_account, entity: data === null || data === void 0 ? void 0 : data.entity, merchant: data === null || data === void 0 ? void 0 : data.merchant, name: (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.names, contact: (_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.contact })
|
|
161
217
|
}];
|
|
162
218
|
}
|
|
163
219
|
});
|
|
164
220
|
}); });
|
|
165
|
-
export var
|
|
166
|
-
var _a, settings, entity, requestBody, data;
|
|
167
|
-
var _b, _c, _d, _e, _f;
|
|
168
|
-
return __generator(this, function (
|
|
169
|
-
switch (
|
|
221
|
+
export var updateEntity = createAsyncThunk('entityUpdateEntity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
222
|
+
var _a, settings, entity, id, brandId, articleId, requestBody, brandData, payload, data;
|
|
223
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
224
|
+
return __generator(this, function (_j) {
|
|
225
|
+
switch (_j.label) {
|
|
170
226
|
case 0:
|
|
171
227
|
_a = thunkApi.getState(), settings = _a.settings, entity = _a.entity;
|
|
228
|
+
id = (_c = (_b = entity.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id;
|
|
229
|
+
brandId = (_e = (_d = entity.data.verify.responseBody) === null || _d === void 0 ? void 0 : _d.brand) === null || _e === void 0 ? void 0 : _e.id;
|
|
230
|
+
articleId = entity.data.entityData.articleId;
|
|
172
231
|
requestBody = {
|
|
173
|
-
id:
|
|
174
|
-
activities: (
|
|
232
|
+
id: brandId,
|
|
233
|
+
activities: (_f = (params.activities || [])) === null || _f === void 0 ? void 0 : _f.map(function (_a) {
|
|
175
234
|
var id = _a.id;
|
|
176
235
|
return ({ id: id });
|
|
177
236
|
}),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
237
|
+
operations: {
|
|
238
|
+
start_date: params.operationStartDate
|
|
239
|
+
},
|
|
240
|
+
encryption_contract: ['operations.start_date']
|
|
182
241
|
};
|
|
183
|
-
return [4, API.
|
|
242
|
+
return [4, API.brandService.updateBrandInfo(requestBody)];
|
|
184
243
|
case 1:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
244
|
+
brandData = (_j.sent()).data;
|
|
245
|
+
payload = {
|
|
246
|
+
id: id,
|
|
247
|
+
license: {
|
|
248
|
+
number: params.licenseNumber
|
|
249
|
+
},
|
|
250
|
+
legal_name: {
|
|
251
|
+
ar: params.licenseName,
|
|
252
|
+
en: params.licenseName
|
|
253
|
+
},
|
|
254
|
+
AOA_file_id: articleId,
|
|
255
|
+
encryption_contract: ['license.number', 'legal_name.ar', 'legal_name.en']
|
|
256
|
+
};
|
|
257
|
+
return [4, API.entityService.updateEntity(payload)];
|
|
258
|
+
case 2:
|
|
259
|
+
data = _j.sent();
|
|
260
|
+
thunkApi.dispatch(handleNextScreenStep());
|
|
261
|
+
(_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, id);
|
|
262
|
+
return [2, { data: __assign(__assign({}, data), brandData), formData: params }];
|
|
191
263
|
}
|
|
192
264
|
});
|
|
193
265
|
}); });
|
|
266
|
+
export var uploadArticle = createAsyncThunk('entityUploadArticle', function (_a) {
|
|
267
|
+
var file = _a.file, onProgress = _a.onProgress;
|
|
268
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
269
|
+
var typeArray, type, uploadPayload, onUploadProgress, data;
|
|
270
|
+
var _b;
|
|
271
|
+
return __generator(this, function (_c) {
|
|
272
|
+
switch (_c.label) {
|
|
273
|
+
case 0:
|
|
274
|
+
typeArray = ((_b = file === null || file === void 0 ? void 0 : file.type) === null || _b === void 0 ? void 0 : _b.split('/')) || [];
|
|
275
|
+
type = typeArray[1] || '';
|
|
276
|
+
uploadPayload = {
|
|
277
|
+
file_link_create: true,
|
|
278
|
+
title: file === null || file === void 0 ? void 0 : file.name,
|
|
279
|
+
purpose: 'identity_document',
|
|
280
|
+
type: type,
|
|
281
|
+
file: file
|
|
282
|
+
};
|
|
283
|
+
onUploadProgress = function (progressEvent) {
|
|
284
|
+
var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
|
|
285
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.floor(progress));
|
|
286
|
+
};
|
|
287
|
+
return [4, API.entityService.uploadFileInfo(uploadPayload, { onUploadProgress: onUploadProgress })];
|
|
288
|
+
case 1:
|
|
289
|
+
data = _c.sent();
|
|
290
|
+
return [2, { data: data }];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
});
|
|
194
295
|
export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
195
296
|
var _a, settings, entity, _b, id, infoId, payload, data;
|
|
196
297
|
var _c, _d, _e, _f;
|
|
@@ -215,22 +316,7 @@ export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', fun
|
|
|
215
316
|
(_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
|
|
216
317
|
(_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
|
|
217
318
|
thunkApi.dispatch(handleNextScreenStep());
|
|
218
|
-
return [2, { response: __assign(__assign({}, data), { flows:
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}); });
|
|
222
|
-
export var retrieveChannels = createAsyncThunk('retrieveChannelsEntity', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
223
|
-
var body, data;
|
|
224
|
-
return __generator(this, function (_a) {
|
|
225
|
-
switch (_a.label) {
|
|
226
|
-
case 0:
|
|
227
|
-
body = {
|
|
228
|
-
page: 0
|
|
229
|
-
};
|
|
230
|
-
return [4, API.dataService.getChannelsOfServices(body)];
|
|
231
|
-
case 1:
|
|
232
|
-
data = _a.sent();
|
|
233
|
-
return [2, data];
|
|
319
|
+
return [2, { response: __assign(__assign({}, data), { flows: data === null || data === void 0 ? void 0 : data.info }), formData: params }];
|
|
234
320
|
}
|
|
235
321
|
});
|
|
236
322
|
}); });
|
|
@@ -238,6 +324,7 @@ var initialState = {
|
|
|
238
324
|
error: null,
|
|
239
325
|
loading: false,
|
|
240
326
|
customLoading: false,
|
|
327
|
+
uploading: false,
|
|
241
328
|
data: {
|
|
242
329
|
flowName: FlowsTypes.ENTITY,
|
|
243
330
|
verify: {
|
|
@@ -247,9 +334,11 @@ var initialState = {
|
|
|
247
334
|
otp: ''
|
|
248
335
|
},
|
|
249
336
|
entityData: {
|
|
337
|
+
licenseName: '',
|
|
338
|
+
licenseNumber: '',
|
|
250
339
|
activities: [],
|
|
251
|
-
|
|
252
|
-
|
|
340
|
+
operationStartDate: '',
|
|
341
|
+
uploading: false
|
|
253
342
|
}
|
|
254
343
|
}
|
|
255
344
|
};
|
|
@@ -274,51 +363,37 @@ export var entitySlice = createSlice({
|
|
|
274
363
|
state.customLoading = true;
|
|
275
364
|
})
|
|
276
365
|
.addCase(verifyLeadToken.fulfilled, function (state, action) {
|
|
277
|
-
var _a, _b, _c;
|
|
366
|
+
var _a, _b, _c, _d;
|
|
278
367
|
state.error = null;
|
|
279
368
|
state.customLoading = false;
|
|
280
|
-
var
|
|
369
|
+
var _e = action.payload, data = _e.data, token = _e.token, boardResponse = _e.boardResponse;
|
|
281
370
|
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
282
371
|
if (description) {
|
|
283
372
|
state.error = description;
|
|
284
373
|
return;
|
|
285
374
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
|
|
298
|
-
var websiteData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a; return ((_a = c === null || c === void 0 ? void 0 : c.name) === null || _a === void 0 ? void 0 : _a.en.toLocaleLowerCase()) === 'website'; });
|
|
299
|
-
var socialData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a; return ((_a = c === null || c === void 0 ? void 0 : c.name) === null || _a === void 0 ? void 0 : _a.en.toLocaleLowerCase()) === 'social media'; });
|
|
300
|
-
if (isHasWebsite && (isHasTwitter || isHasInstagram))
|
|
301
|
-
selectedChannels = [websiteData, socialData];
|
|
302
|
-
else if (isHasTwitter || isHasInstagram)
|
|
303
|
-
selectedChannels = [socialData];
|
|
304
|
-
else if (isHasWebsite)
|
|
305
|
-
selectedChannels = [websiteData];
|
|
306
|
-
if (((_c = brand === null || brand === void 0 ? void 0 : brand.channel_services) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
307
|
-
selectedChannels = channels === null || channels === void 0 ? void 0 : channels.filter(function (channel) {
|
|
308
|
-
var _a;
|
|
309
|
-
return (_a = brand === null || brand === void 0 ? void 0 : brand.channel_services) === null || _a === void 0 ? void 0 : _a.find(function (storedChannel) { var _a; return ((_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.en.toLowerCase()) === storedChannel.toLowerCase(); });
|
|
310
|
-
});
|
|
375
|
+
state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id });
|
|
376
|
+
state.data.verify.token = token;
|
|
377
|
+
var _f = boardResponse || {}, brand = _f.brand, entity = _f.entity;
|
|
378
|
+
var licenseNumber = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.number;
|
|
379
|
+
var entityDate = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.issuing_date;
|
|
380
|
+
var startDate = (_d = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _d === void 0 ? void 0 : _d.start_date;
|
|
381
|
+
var issuingDate = undefined;
|
|
382
|
+
if (entityDate) {
|
|
383
|
+
var date = new Date(entityDate);
|
|
384
|
+
var formattedDate = moment(date).format('YYYY-MM-DD');
|
|
385
|
+
issuingDate = convertNumbers2English(formattedDate);
|
|
311
386
|
}
|
|
312
|
-
|
|
387
|
+
if (licenseNumber)
|
|
388
|
+
state.data.entityData.licenseNumber = licenseNumber;
|
|
313
389
|
var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
|
|
314
390
|
var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
|
|
315
391
|
var _a;
|
|
316
392
|
return (_a = brand === null || brand === void 0 ? void 0 : brand.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === activity.id; });
|
|
317
393
|
});
|
|
318
|
-
|
|
319
|
-
state.data.entityData.
|
|
320
|
-
state.data.
|
|
321
|
-
state.data.verify.token = token;
|
|
394
|
+
var defaultActivities = (activities === null || activities === void 0 ? void 0 : activities[0]) ? [activities === null || activities === void 0 ? void 0 : activities[0]] : [];
|
|
395
|
+
state.data.entityData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities;
|
|
396
|
+
state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, operationStartDate: startDate || issuingDate, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : defaultActivities });
|
|
322
397
|
})
|
|
323
398
|
.addCase(verifyLeadToken.rejected, function (state, action) {
|
|
324
399
|
state.error = action.error.message;
|
|
@@ -346,10 +421,10 @@ export var entitySlice = createSlice({
|
|
|
346
421
|
state.error = null;
|
|
347
422
|
})
|
|
348
423
|
.addCase(verifyEntityLeadOTP.fulfilled, function (state, action) {
|
|
349
|
-
var _a;
|
|
424
|
+
var _a, _b, _c, _d;
|
|
350
425
|
state.loading = false;
|
|
351
426
|
state.error = null;
|
|
352
|
-
var
|
|
427
|
+
var _e = action.payload, data = _e.data, boardResponse = _e.boardResponse, formData = _e.formData;
|
|
353
428
|
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
354
429
|
if (description) {
|
|
355
430
|
state.error = description;
|
|
@@ -357,16 +432,35 @@ export var entitySlice = createSlice({
|
|
|
357
432
|
}
|
|
358
433
|
state.data.otpData = formData;
|
|
359
434
|
state.data.otpData.responseBody = data;
|
|
435
|
+
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), boardResponse);
|
|
436
|
+
var _f = boardResponse || {}, brand = _f.brand, entity = _f.entity;
|
|
437
|
+
var licenseNumber = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.number;
|
|
438
|
+
var entityDate = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.issuing_date;
|
|
439
|
+
var startDate = (_d = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _d === void 0 ? void 0 : _d.start_date;
|
|
440
|
+
var issuingDate = undefined;
|
|
441
|
+
if (entityDate) {
|
|
442
|
+
var date = new Date(entityDate);
|
|
443
|
+
var formattedDate = moment(date).format('YYYY-MM-DD');
|
|
444
|
+
issuingDate = convertNumbers2English(formattedDate);
|
|
445
|
+
}
|
|
446
|
+
if (licenseNumber)
|
|
447
|
+
state.data.entityData.licenseNumber = licenseNumber;
|
|
448
|
+
var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
|
|
449
|
+
var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
|
|
450
|
+
var _a;
|
|
451
|
+
return (_a = brand === null || brand === void 0 ? void 0 : brand.activities) === null || _a === void 0 ? void 0 : _a.find(function (value) { return value.id === activity.id; });
|
|
452
|
+
});
|
|
453
|
+
state.data.entityData.responseBody = __assign(__assign({}, state.data.entityData.responseBody), { entity_id: entity === null || entity === void 0 ? void 0 : entity.id, activities: activities, selectedActivities: (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]], operationStartDate: startDate || issuingDate });
|
|
360
454
|
})
|
|
361
455
|
.addCase(verifyEntityLeadOTP.rejected, function (state, action) {
|
|
362
456
|
state.loading = false;
|
|
363
457
|
state.error = action.error.message;
|
|
364
458
|
})
|
|
365
|
-
.addCase(
|
|
459
|
+
.addCase(updateEntity.pending, function (state) {
|
|
366
460
|
state.loading = true;
|
|
367
461
|
state.error = null;
|
|
368
462
|
})
|
|
369
|
-
.addCase(
|
|
463
|
+
.addCase(updateEntity.fulfilled, function (state, action) {
|
|
370
464
|
var _a;
|
|
371
465
|
state.loading = false;
|
|
372
466
|
state.error = null;
|
|
@@ -379,7 +473,7 @@ export var entitySlice = createSlice({
|
|
|
379
473
|
state.data.entityData = formData;
|
|
380
474
|
state.data.entityData.responseBody = data;
|
|
381
475
|
})
|
|
382
|
-
.addCase(
|
|
476
|
+
.addCase(updateEntity.rejected, function (state, action) {
|
|
383
477
|
state.loading = false;
|
|
384
478
|
state.error = action.error.message;
|
|
385
479
|
})
|
|
@@ -418,41 +512,19 @@ export var entitySlice = createSlice({
|
|
|
418
512
|
state.loading = false;
|
|
419
513
|
state.error = action.error.message;
|
|
420
514
|
})
|
|
421
|
-
.addCase(
|
|
515
|
+
.addCase(uploadArticle.pending, function (state) {
|
|
422
516
|
state.error = null;
|
|
423
|
-
state.
|
|
517
|
+
state.uploading = true;
|
|
424
518
|
})
|
|
425
|
-
.addCase(
|
|
426
|
-
var _a;
|
|
519
|
+
.addCase(uploadArticle.fulfilled, function (state, action) {
|
|
427
520
|
state.error = null;
|
|
428
|
-
state.
|
|
429
|
-
var data = action.payload
|
|
430
|
-
|
|
431
|
-
if (description) {
|
|
432
|
-
state.error = description;
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
var channels = data.list || [];
|
|
436
|
-
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { channelList: channels });
|
|
437
|
-
var brand = (state.data.verify.responseBody || {}).brand;
|
|
438
|
-
var selectedChannels = (!!(channels === null || channels === void 0 ? void 0 : channels[0]) && [channels === null || channels === void 0 ? void 0 : channels[0]]) || [];
|
|
439
|
-
var _b = brand || {}, website = _b.website, social = _b.social;
|
|
440
|
-
var isHasWebsite = (website === null || website === void 0 ? void 0 : website.length) > 0;
|
|
441
|
-
var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
|
|
442
|
-
var isHasInstagram = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('instagram.com'); });
|
|
443
|
-
var websiteData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a; return ((_a = c === null || c === void 0 ? void 0 : c.name) === null || _a === void 0 ? void 0 : _a.en.toLocaleLowerCase()) === 'website'; });
|
|
444
|
-
var socialData = channels === null || channels === void 0 ? void 0 : channels.find(function (c) { var _a; return ((_a = c === null || c === void 0 ? void 0 : c.name) === null || _a === void 0 ? void 0 : _a.en.toLocaleLowerCase()) === 'social media'; });
|
|
445
|
-
if (isHasWebsite && (isHasTwitter || isHasInstagram))
|
|
446
|
-
selectedChannels = [websiteData, socialData];
|
|
447
|
-
else if (isHasTwitter || isHasInstagram)
|
|
448
|
-
selectedChannels = [socialData];
|
|
449
|
-
else if (isHasWebsite)
|
|
450
|
-
selectedChannels = [websiteData];
|
|
451
|
-
state.data.entityData.salesChannels = selectedChannels;
|
|
521
|
+
state.uploading = false;
|
|
522
|
+
var data = action.payload.data;
|
|
523
|
+
state.data.entityData.articleId = data === null || data === void 0 ? void 0 : data.id;
|
|
452
524
|
})
|
|
453
|
-
.addCase(
|
|
454
|
-
state.
|
|
455
|
-
state.
|
|
525
|
+
.addCase(uploadArticle.rejected, function (state) {
|
|
526
|
+
state.uploading = false;
|
|
527
|
+
state.error = 'file_upload_error';
|
|
456
528
|
});
|
|
457
529
|
}
|
|
458
530
|
});
|
|
@@ -49,7 +49,7 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
|
-
import { handleNextScreenStep } from '../../../app/settings';
|
|
52
|
+
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
53
53
|
import { BUSINESS_FLOW_SUCCESS, INDIVIDUAl_STEP_NAMES } from '../../../constants';
|
|
54
54
|
export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
55
|
var payload, settings, data, boardData, individualData, countryCode, boardInfoData, countries, board_id, board_info_id, notification, _a, id, type, info, hasIndividualCompleted;
|
|
@@ -83,16 +83,18 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
|
|
|
83
83
|
individualData = _f.sent();
|
|
84
84
|
_f.label = 4;
|
|
85
85
|
case 4:
|
|
86
|
-
countryCode = (_b = individualData === null || individualData === void 0 ? void 0 : individualData.user) === null || _b === void 0 ? void 0 : _b.nationality;
|
|
87
|
-
info = boardInfoData.info;
|
|
88
|
-
hasIndividualCompleted = ((_c = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _c === void 0 ? void 0 : _c.status) === 'completed';
|
|
89
|
-
if (!hasIndividualCompleted) return [3, 7];
|
|
90
86
|
if (!board_id) return [3, 6];
|
|
91
87
|
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
92
88
|
case 5:
|
|
93
89
|
boardData = _f.sent();
|
|
94
90
|
_f.label = 6;
|
|
95
91
|
case 6:
|
|
92
|
+
countryCode = (_b = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _b === void 0 ? void 0 : _b.country;
|
|
93
|
+
if (countryCode)
|
|
94
|
+
thunkApi.dispatch(handleSetCountryByIso2(countryCode));
|
|
95
|
+
info = boardInfoData.info;
|
|
96
|
+
hasIndividualCompleted = ((_c = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _c === void 0 ? void 0 : _c.status) === 'completed';
|
|
97
|
+
if (!hasIndividualCompleted) return [3, 7];
|
|
96
98
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
97
99
|
return [3, 10];
|
|
98
100
|
case 7:
|
|
@@ -216,17 +218,17 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
|
|
|
216
218
|
individualData = _l.sent();
|
|
217
219
|
_l.label = 4;
|
|
218
220
|
case 4:
|
|
219
|
-
countryCode = (_e = individualData === null || individualData === void 0 ? void 0 : individualData.user) === null || _e === void 0 ? void 0 : _e.nationality;
|
|
220
|
-
info = boardInfoData.info;
|
|
221
|
-
hasIndividualCompleted = ((_f = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _f === void 0 ? void 0 : _f.status) === 'completed';
|
|
222
|
-
(_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
|
|
223
|
-
if (!hasIndividualCompleted) return [3, 7];
|
|
224
221
|
if (!board_id) return [3, 6];
|
|
225
222
|
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
226
223
|
case 5:
|
|
227
224
|
boardData = _l.sent();
|
|
228
225
|
_l.label = 6;
|
|
229
226
|
case 6:
|
|
227
|
+
countryCode = (_e = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _e === void 0 ? void 0 : _e.country;
|
|
228
|
+
info = boardInfoData.info;
|
|
229
|
+
hasIndividualCompleted = ((_f = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _f === void 0 ? void 0 : _f.status) === 'completed';
|
|
230
|
+
(_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
|
|
231
|
+
if (!hasIndividualCompleted) return [3, 7];
|
|
230
232
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
231
233
|
return [3, 10];
|
|
232
234
|
case 7:
|
|
@@ -371,7 +373,7 @@ export var individualSlice = createSlice({
|
|
|
371
373
|
}
|
|
372
374
|
state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id });
|
|
373
375
|
state.data.verify.token = token;
|
|
374
|
-
var _c = boardResponse || {}, countries = _c.countries, user = _c.user;
|
|
376
|
+
var _c = boardResponse || {}, countries = _c.countries, user = _c.user, countryCode = _c.countryCode;
|
|
375
377
|
var _d = user || {}, source_income = _d.source_income, monthly_income = _d.monthly_income, occupation = _d.occupation, is_relative_PEP = _d.is_relative_PEP, is_influencer = _d.is_influencer;
|
|
376
378
|
var _e = state.data.individualData.responseBody || {}, sourceIncomeList = _e.sourceIncomeList, monthlyIncomeList = _e.monthlyIncomeList, occupationList = _e.occupationList;
|
|
377
379
|
var selectedSourceIncome = (sourceIncomeList === null || sourceIncomeList === void 0 ? void 0 : sourceIncomeList.find(function (source) { var _a; return (source === null || source === void 0 ? void 0 : source.id) === ((_a = source_income === null || source_income === void 0 ? void 0 : source_income[0]) === null || _a === void 0 ? void 0 : _a.id); })) ||
|
|
@@ -382,7 +384,7 @@ export var individualSlice = createSlice({
|
|
|
382
384
|
(monthlyIncomeList === null || monthlyIncomeList === void 0 ? void 0 : monthlyIncomeList[2]);
|
|
383
385
|
if (!!selectedMonthlyIncome)
|
|
384
386
|
state.data.individualData.monthlyIncome = selectedMonthlyIncome;
|
|
385
|
-
var code = user === null || user === void 0 ? void 0 : user.employer_country;
|
|
387
|
+
var code = (user === null || user === void 0 ? void 0 : user.employer_country) || countryCode;
|
|
386
388
|
if (!!code) {
|
|
387
389
|
var employerLocation = (countries || []).find(function (country) { return country.iso2 === code; });
|
|
388
390
|
state.data.individualData.employerLocation = employerLocation;
|