@tap-payments/auth-jsconnect 2.0.108-test → 2.0.109-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.
Files changed (28) hide show
  1. package/build/@types/form.d.ts +6 -4
  2. package/build/api/entity.d.ts +30 -0
  3. package/build/api/entity.js +35 -1
  4. package/build/api/index.d.ts +6 -2
  5. package/build/assets/locales/ar.json +3 -1
  6. package/build/assets/locales/en.json +3 -1
  7. package/build/constants/app.js +1 -1
  8. package/build/constants/assets.d.ts +3 -0
  9. package/build/constants/assets.js +3 -0
  10. package/build/features/app/entity/entityStore.d.ts +27 -7
  11. package/build/features/app/entity/entityStore.js +219 -145
  12. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +1 -0
  13. package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +21 -11
  14. package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +3 -0
  15. package/build/features/entity/screens/EntityInfoConfirm/Article.js +73 -0
  16. package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +25 -6
  17. package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +20 -5
  18. package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +25 -4
  19. package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +9 -17
  20. package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +12 -51
  21. package/build/features/entity/screens/EntityInfoConfirm/validation.js +17 -10
  22. package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
  23. package/build/features/entity/screens/Verify/Verify.js +4 -4
  24. package/build/features/shared/UploadFile/UploadFile.d.ts +2 -1
  25. package/build/features/shared/UploadFile/UploadFile.js +3 -3
  26. package/package.json +1 -1
  27. package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.d.ts +0 -5
  28. 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 { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
53
- import { ENTITY_STEP_NAMES, BUSINESS_FLOW_SUCCESS } from '../../../constants';
52
+ import { handleNextScreenStep } 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 (_b) {
60
- switch (_b.label) {
57
+ var payload, data, boardData, entityData, boardInfoData, board_id, board_info_id, entityId, 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,54 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
65
65
  };
66
66
  return [4, API.leadService.verifyLeadToken(payload)];
67
67
  case 1:
68
- data = (_b.sent()).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, 6];
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 (!(!!board_id && !!board_info_id)) return [3, 4];
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
- boardInfoData = _b.sent();
80
- _b.label = 4;
81
- case 4: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
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
- _b.sent();
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:
84
93
  info = boardInfoData.info;
85
- hasEntityCompleted = ((_a = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'entity'; })) === null || _a === void 0 ? void 0 : _a.status) === 'completed';
86
- thunkApi.dispatch(handleCurrentActiveScreen('ENTITY_INFO_STEP'));
87
- if (data.step_name === ENTITY_STEP_NAMES.PHONE_AUTH) {
88
- thunkApi.dispatch(handleCurrentActiveScreen('ENTITY_INFO_STEP'));
89
- }
90
- else if (hasEntityCompleted) {
94
+ 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';
95
+ if (hasEntityCompleted) {
91
96
  thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
92
97
  }
93
- else if (data.step_name === ENTITY_STEP_NAMES.ENTITY_INFO) {
98
+ else {
94
99
  thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
95
100
  }
96
- _b.label = 6;
97
- case 6: return [2, { data: data, boardResponse: { flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) }, token: token }];
101
+ _e.label = 8;
102
+ case 8: return [2, {
103
+ data: data,
104
+ boardResponse: {
105
+ user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
106
+ brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
107
+ bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
108
+ entity: entityData === null || entityData === void 0 ? void 0 : entityData.entity,
109
+ merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
110
+ name: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _c === void 0 ? void 0 : _c.names,
111
+ contact: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.contact,
112
+ flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
113
+ },
114
+ token: token
115
+ }];
98
116
  }
99
117
  });
100
118
  }); });
@@ -116,14 +134,13 @@ export var resendOTP = createAsyncThunk('entityResendOTP', function (params, thu
116
134
  });
117
135
  }); });
118
136
  export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
119
- var _a, entity, settings, responseBody, flows, payload, data, hasEntityCompleted;
120
- var _b, _c, _d, _e;
121
- return __generator(this, function (_f) {
122
- switch (_f.label) {
137
+ var _a, entity, settings, responseBody, payload, data, boardData, entityData, boardInfoData, board_id, board_info_id, entityId, info, hasEntityCompleted;
138
+ var _b, _c, _d, _e, _f, _g, _h;
139
+ return __generator(this, function (_j) {
140
+ switch (_j.label) {
123
141
  case 0:
124
142
  _a = thunkApi.getState(), entity = _a.entity, settings = _a.settings;
125
143
  responseBody = entity.data.verify.responseBody;
126
- flows = (responseBody || {}).flows;
127
144
  payload = {
128
145
  data: params.otp,
129
146
  service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
@@ -133,18 +150,54 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
133
150
  };
134
151
  return [4, API.leadService.verifyLeadOTP(payload)];
135
152
  case 1:
136
- data = (_f.sent()).data;
137
- if (!data.errors) {
138
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, { otp: params.otp });
139
- hasEntityCompleted = ((_e = flows === null || flows === void 0 ? void 0 : flows.find(function (flow) { return flow.name === 'entity'; })) === null || _e === void 0 ? void 0 : _e.status) === 'completed';
140
- if (hasEntityCompleted) {
141
- thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
142
- }
143
- else {
144
- thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
145
- }
153
+ data = (_j.sent()).data;
154
+ boardInfoData = undefined;
155
+ if (!!data.errors) return [3, 8];
156
+ board_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.id;
157
+ board_info_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.board_info_id;
158
+ if (!(board_id && board_info_id)) return [3, 3];
159
+ return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
160
+ case 2:
161
+ boardInfoData = _j.sent();
162
+ _j.label = 3;
163
+ case 3:
164
+ if (!board_id) return [3, 5];
165
+ return [4, API.boardService.retrieveBoardDetails(board_id)];
166
+ case 4:
167
+ boardData = _j.sent();
168
+ _j.label = 5;
169
+ case 5:
170
+ entityId = (_c = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _c === void 0 ? void 0 : _c.id;
171
+ if (!entityId) return [3, 7];
172
+ return [4, API.entityService.retrieveEntity(entityId)];
173
+ case 6:
174
+ entityData = _j.sent();
175
+ _j.label = 7;
176
+ case 7:
177
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, { otp: params.otp });
178
+ info = boardInfoData.info;
179
+ 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';
180
+ if (hasEntityCompleted) {
181
+ thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
146
182
  }
147
- return [2, { data: data, formData: params }];
183
+ else {
184
+ thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
185
+ }
186
+ _j.label = 8;
187
+ case 8: return [2, {
188
+ data: data,
189
+ boardResponse: {
190
+ user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
191
+ brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
192
+ bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account,
193
+ entity: entityData === null || entityData === void 0 ? void 0 : entityData.entity,
194
+ merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
195
+ name: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _g === void 0 ? void 0 : _g.names,
196
+ contact: (_h = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _h === void 0 ? void 0 : _h.contact,
197
+ flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
198
+ },
199
+ formData: params
200
+ }];
148
201
  }
149
202
  });
150
203
  }); });
@@ -157,40 +210,94 @@ export var retrieveBoardDetails = createAsyncThunk('entityRetrieveEntityInfo', f
157
210
  case 1:
158
211
  data = _c.sent();
159
212
  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.name, contact: (_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.contact })
213
+ 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
214
  }];
162
215
  }
163
216
  });
164
217
  }); });
165
- export var updateEntityInfo = createAsyncThunk('updateEntityInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
166
- var _a, settings, entity, requestBody, data;
167
- var _b, _c, _d, _e, _f;
168
- return __generator(this, function (_g) {
169
- switch (_g.label) {
218
+ export var updateEntity = createAsyncThunk('entityUpdateEntity', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
219
+ var _a, settings, entity, id, documentData, articleId, licenseBody, activitiesBody, nameBody, _b, nameData, activitiesData, licenseData, documentBody;
220
+ var _c, _d, _e, _f, _g;
221
+ return __generator(this, function (_h) {
222
+ switch (_h.label) {
170
223
  case 0:
171
224
  _a = thunkApi.getState(), settings = _a.settings, entity = _a.entity;
172
- requestBody = {
173
- id: (_c = (_b = entity.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.id,
174
- activities: (_d = (params.activities || [])) === null || _d === void 0 ? void 0 : _d.map(function (_a) {
225
+ id = (_d = (_c = entity.data.verify.responseBody) === null || _c === void 0 ? void 0 : _c.entity) === null || _d === void 0 ? void 0 : _d.id;
226
+ documentData = undefined;
227
+ articleId = entity.data.entityData.articleId;
228
+ licenseBody = {
229
+ id: id,
230
+ license: {
231
+ issuing_date: moment(params.operationStartDate).format('x'),
232
+ number: params.licenseNumber
233
+ }
234
+ };
235
+ activitiesBody = {
236
+ id: id,
237
+ activities: (_e = (params.activities || [])) === null || _e === void 0 ? void 0 : _e.map(function (_a) {
175
238
  var id = _a.id;
176
239
  return ({ id: id });
177
- }),
178
- license_name: params.licenseName,
179
- license_number: params.licenseNumber,
180
- business_operation_start_at: params.operationStartDate,
181
- step_name: ENTITY_STEP_NAMES.ENTITY_INFO
240
+ })
241
+ };
242
+ nameBody = {
243
+ id: id,
244
+ legal_name: {
245
+ ar: params.licenseName,
246
+ en: params.licenseName
247
+ }
182
248
  };
183
- return [4, API.entityService.updateEntityInfo(requestBody)];
249
+ return [4, Promise.all([
250
+ API.entityService.updateEntityName(nameBody),
251
+ API.entityService.updateEntityActivities(activitiesBody),
252
+ API.entityService.updateEntityLicense(licenseBody)
253
+ ])];
184
254
  case 1:
185
- data = (_g.sent()).data;
186
- if (!data.errors) {
187
- thunkApi.dispatch(handleNextScreenStep());
188
- (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, requestBody);
189
- }
190
- return [2, { data: data, formData: params }];
255
+ _b = _h.sent(), nameData = _b[0], activitiesData = _b[1], licenseData = _b[2];
256
+ if (!articleId) return [3, 3];
257
+ documentBody = {
258
+ entity_id: id || '',
259
+ documents: [
260
+ {
261
+ images: [articleId]
262
+ }
263
+ ]
264
+ };
265
+ return [4, API.entityService.updateDocumentInfo(documentBody)];
266
+ case 2:
267
+ documentData = _h.sent();
268
+ _h.label = 3;
269
+ case 3:
270
+ thunkApi.dispatch(handleNextScreenStep());
271
+ (_g = (_f = settings.data.appConfig).onStepCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, settings.data.activeScreen.name, id);
272
+ return [2, { data: __assign(__assign(__assign(__assign({}, nameData), activitiesData), licenseData), documentData), formData: params }];
191
273
  }
192
274
  });
193
275
  }); });
276
+ export var uploadArticle = createAsyncThunk('entityUploadArticle', function (_a) {
277
+ var file = _a.file, onProgress = _a.onProgress;
278
+ return __awaiter(void 0, void 0, void 0, function () {
279
+ var uploadPayload, onUploadProgress, data;
280
+ return __generator(this, function (_b) {
281
+ switch (_b.label) {
282
+ case 0:
283
+ uploadPayload = {
284
+ file_link_create: true,
285
+ title: file === null || file === void 0 ? void 0 : file.name,
286
+ purpose: 'identity_document',
287
+ file: file
288
+ };
289
+ onUploadProgress = function (progressEvent) {
290
+ var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
291
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.floor(progress));
292
+ };
293
+ return [4, API.entityService.uploadFileInfo(uploadPayload, { onUploadProgress: onUploadProgress })];
294
+ case 1:
295
+ data = _b.sent();
296
+ return [2, { data: data }];
297
+ }
298
+ });
299
+ });
300
+ });
194
301
  export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
195
302
  var _a, settings, entity, _b, id, infoId, payload, data;
196
303
  var _c, _d, _e, _f;
@@ -215,22 +322,7 @@ export var updateBoardSuccess = createAsyncThunk('updateBoardEntitySuccess', fun
215
322
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
216
323
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
217
324
  thunkApi.dispatch(handleNextScreenStep());
218
- return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat(data === null || data === void 0 ? void 0 : data.info) }), formData: params }];
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];
325
+ return [2, { response: __assign(__assign({}, data), { flows: data === null || data === void 0 ? void 0 : data.info }), formData: params }];
234
326
  }
235
327
  });
236
328
  }); });
@@ -238,6 +330,7 @@ var initialState = {
238
330
  error: null,
239
331
  loading: false,
240
332
  customLoading: false,
333
+ uploading: false,
241
334
  data: {
242
335
  flowName: FlowsTypes.ENTITY,
243
336
  verify: {
@@ -247,9 +340,11 @@ var initialState = {
247
340
  otp: ''
248
341
  },
249
342
  entityData: {
343
+ licenseName: '',
344
+ licenseNumber: '',
250
345
  activities: [],
251
- salesChannels: [],
252
- operationStartDate: new Date().toString()
346
+ operationStartDate: new Date().toString(),
347
+ uploading: false
253
348
  }
254
349
  }
255
350
  };
@@ -274,42 +369,27 @@ export var entitySlice = createSlice({
274
369
  state.customLoading = true;
275
370
  })
276
371
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
277
- var _a, _b, _c;
372
+ var _a, _b, _c, _d;
278
373
  state.error = null;
279
374
  state.customLoading = false;
280
- var _d = action.payload, data = _d.data, token = _d.token, boardResponse = _d.boardResponse;
375
+ var _e = action.payload, data = _e.data, token = _e.token, boardResponse = _e.boardResponse;
281
376
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
282
377
  if (description) {
283
378
  state.error = description;
284
379
  return;
285
380
  }
286
- var _e = state.data.verify.responseBody || {}, brand = _e.brand, entity = _e.entity;
287
- var issuingDate = brand === null || brand === void 0 ? void 0 : brand.business_operation_start_at;
288
- if (!!issuingDate) {
289
- var formattedDate = moment(issuingDate).format('YYYY-MM-DD');
381
+ state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id });
382
+ state.data.verify.token = token;
383
+ var _f = boardResponse || {}, brand = _f.brand, entity = _f.entity;
384
+ var issuingDate = ((_b = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _b === void 0 ? void 0 : _b.start_date) || ((_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.issuing_date);
385
+ var licenseNumber = (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.number;
386
+ if (issuingDate) {
387
+ var date = new Date(issuingDate);
388
+ var formattedDate = moment(date).format('YYYY-MM-DD');
290
389
  state.data.entityData.operationStartDate = convertNumbers2English(formattedDate);
291
390
  }
292
- var channels = (_b = state.data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.channelList;
293
- var selectedChannels = (!!(channels === null || channels === void 0 ? void 0 : channels[0]) && [channels === null || channels === void 0 ? void 0 : channels[0]]) || [];
294
- var _f = brand || {}, website = _f.website, social = _f.social;
295
- var isHasWebsite = (website === null || website === void 0 ? void 0 : website.length) > 0;
296
- var isHasTwitter = social === null || social === void 0 ? void 0 : social.find(function (s) { return s.includes('twitter.com'); });
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
- });
311
- }
312
- state.data.entityData.salesChannels = selectedChannels;
391
+ if (licenseNumber)
392
+ state.data.entityData.licenseNumber = licenseNumber;
313
393
  var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
314
394
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
315
395
  var _a;
@@ -317,8 +397,6 @@ export var entitySlice = createSlice({
317
397
  });
318
398
  state.data.entityData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
319
399
  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]] });
320
- state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), boardResponse), state.data.verify.responseBody), { board_id: data.id });
321
- state.data.verify.token = token;
322
400
  })
323
401
  .addCase(verifyLeadToken.rejected, function (state, action) {
324
402
  state.error = action.error.message;
@@ -346,10 +424,10 @@ export var entitySlice = createSlice({
346
424
  state.error = null;
347
425
  })
348
426
  .addCase(verifyEntityLeadOTP.fulfilled, function (state, action) {
349
- var _a;
427
+ var _a, _b, _c, _d;
350
428
  state.loading = false;
351
429
  state.error = null;
352
- var _b = action.payload, data = _b.data, formData = _b.formData;
430
+ var _e = action.payload, data = _e.data, boardResponse = _e.boardResponse, formData = _e.formData;
353
431
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
354
432
  if (description) {
355
433
  state.error = description;
@@ -357,16 +435,34 @@ export var entitySlice = createSlice({
357
435
  }
358
436
  state.data.otpData = formData;
359
437
  state.data.otpData.responseBody = data;
438
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), boardResponse);
439
+ var _f = boardResponse || {}, brand = _f.brand, entity = _f.entity;
440
+ var issuingDate = ((_b = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _b === void 0 ? void 0 : _b.start_date) || ((_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.issuing_date);
441
+ var licenseNumber = (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.number;
442
+ if (issuingDate) {
443
+ var date = new Date(issuingDate);
444
+ var formattedDate = moment(date).format('YYYY-MM-DD');
445
+ state.data.entityData.operationStartDate = convertNumbers2English(formattedDate);
446
+ }
447
+ if (licenseNumber)
448
+ state.data.entityData.licenseNumber = licenseNumber;
449
+ var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
450
+ var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
451
+ var _a;
452
+ 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; });
453
+ });
454
+ state.data.entityData.activities = (selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) > 0 ? selectedActivity : [activities === null || activities === void 0 ? void 0 : activities[0]];
455
+ 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]] });
360
456
  })
361
457
  .addCase(verifyEntityLeadOTP.rejected, function (state, action) {
362
458
  state.loading = false;
363
459
  state.error = action.error.message;
364
460
  })
365
- .addCase(updateEntityInfo.pending, function (state) {
461
+ .addCase(updateEntity.pending, function (state) {
366
462
  state.loading = true;
367
463
  state.error = null;
368
464
  })
369
- .addCase(updateEntityInfo.fulfilled, function (state, action) {
465
+ .addCase(updateEntity.fulfilled, function (state, action) {
370
466
  var _a;
371
467
  state.loading = false;
372
468
  state.error = null;
@@ -379,7 +475,7 @@ export var entitySlice = createSlice({
379
475
  state.data.entityData = formData;
380
476
  state.data.entityData.responseBody = data;
381
477
  })
382
- .addCase(updateEntityInfo.rejected, function (state, action) {
478
+ .addCase(updateEntity.rejected, function (state, action) {
383
479
  state.loading = false;
384
480
  state.error = action.error.message;
385
481
  })
@@ -418,41 +514,19 @@ export var entitySlice = createSlice({
418
514
  state.loading = false;
419
515
  state.error = action.error.message;
420
516
  })
421
- .addCase(retrieveChannels.pending, function (state) {
517
+ .addCase(uploadArticle.pending, function (state) {
422
518
  state.error = null;
423
- state.loading = true;
519
+ state.uploading = true;
424
520
  })
425
- .addCase(retrieveChannels.fulfilled, function (state, action) {
426
- var _a;
521
+ .addCase(uploadArticle.fulfilled, function (state, action) {
427
522
  state.error = null;
428
- state.loading = false;
429
- var data = action.payload || {};
430
- var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
431
- if (description) {
432
- state.error = description;
433
- return;
434
- }
435
- 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;
523
+ state.uploading = false;
524
+ var data = action.payload.data;
525
+ state.data.entityData.articleId = data === null || data === void 0 ? void 0 : data.id;
452
526
  })
453
- .addCase(retrieveChannels.rejected, function (state, action) {
454
- state.error = action.error.message;
455
- state.loading = false;
527
+ .addCase(uploadArticle.rejected, function (state) {
528
+ state.uploading = false;
529
+ state.error = 'file_upload_error';
456
530
  });
457
531
  }
458
532
  });
@@ -17,6 +17,7 @@ export declare const InputStyled: import("@emotion/styled").StyledComponent<Pick
17
17
  hide?: boolean | undefined;
18
18
  warningType?: "alert" | "error" | "hint" | undefined;
19
19
  } & {} & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
20
+ export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
20
21
  export declare const CheckIconStyled: import("@emotion/styled").StyledComponent<{
21
22
  children?: React.ReactNode;
22
23
  classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
@@ -58,6 +58,10 @@ export var InputStyled = styled(Input)(function (_a) {
58
58
  }
59
59
  });
60
60
  });
61
+ export var MandatoryStyled = styled('span')(function (_a) {
62
+ var theme = _a.theme;
63
+ return (__assign(__assign({ color: alpha(theme.palette.error.light, 0.4) }, theme.typography.h6), { fontWeight: theme.typography.fontWeightLight, verticalAlign: 'sub' }));
64
+ });
61
65
  var SimpleListStyled = styled((SimpleList))(function () { return ({
62
66
  height: 'fit-content'
63
67
  }); });
@@ -74,21 +78,22 @@ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { r
74
78
  return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25) }));
75
79
  });
76
80
  var ActivitiesList = function (_a) {
77
- var _b, _c, _d, _e;
81
+ var _b;
78
82
  var rest = __rest(_a, []);
79
- var _f = React.useState([]), activitiesMenuList = _f[0], setActivitiesMenuList = _f[1];
80
- var _g = React.useState([]), storedActivities = _g[0], setStoredActivities = _g[1];
81
- var _h = React.useState(null), anchorEl = _h[0], setAnchorEl = _h[1];
83
+ var _c = React.useState([]), activitiesMenuList = _c[0], setActivitiesMenuList = _c[1];
84
+ var _d = React.useState([]), storedActivities = _d[0], setStoredActivities = _d[1];
85
+ var _e = React.useState(null), anchorEl = _e[0], setAnchorEl = _e[1];
82
86
  var t = useTranslation().t;
83
87
  var isAr = useLanguage().isAr;
84
- var control = useFormContext().control;
88
+ var _f = useFormContext(), control = _f.control, setValue = _f.setValue;
85
89
  var data = useAppSelector(entitySelector).data;
86
90
  var activitiesControl = useController({ name: 'activities', control: control });
87
91
  var controlValue = activitiesControl.field.value;
88
92
  var verify = data.verify, entityData = data.entityData;
89
- var activities = (((_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).activities;
90
- var selectedActivities = (entityData.responseBody || {}).selectedActivities;
91
- var businessType = (_e = (_d = (_c = verify.responseBody) === null || _c === void 0 ? void 0 : _c.entity) === null || _d === void 0 ? void 0 : _d.license) === null || _e === void 0 ? void 0 : _e.type;
93
+ var _g = entityData.responseBody || {}, activities = _g.activities, selectedActivities = _g.selectedActivities;
94
+ var entity = (verify.responseBody || {}).entity;
95
+ var licenseType = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.type;
96
+ var businessType = licenseType === 'freelance' ? BusinessType.FL : BusinessType.CR;
92
97
  var isCR = businessType === BusinessType.CR;
93
98
  React.useEffect(function () {
94
99
  if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
@@ -99,7 +104,11 @@ var ActivitiesList = function (_a) {
99
104
  if ((selectedActivities === null || selectedActivities === void 0 ? void 0 : selectedActivities.length) > 0) {
100
105
  setStoredActivities(selectedActivities);
101
106
  }
102
- }, []);
107
+ }, [selectedActivities]);
108
+ React.useEffect(function () {
109
+ var activities = entityData.activities;
110
+ setValue('activities', activities);
111
+ }, [entityData === null || entityData === void 0 ? void 0 : entityData.activities]);
103
112
  var onOpenList = function (event) {
104
113
  var _a;
105
114
  setAnchorEl(event.currentTarget);
@@ -127,10 +136,11 @@ var ActivitiesList = function (_a) {
127
136
  if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > 1) {
128
137
  return (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) + ' ' + t('activities_selected');
129
138
  }
130
- return isAr ? (_a = controlValue[0]) === null || _a === void 0 ? void 0 : _a.ar : (_b = controlValue[0]) === null || _b === void 0 ? void 0 : _b.en;
139
+ var item = controlValue[0];
140
+ return isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en;
131
141
  };
132
142
  var getSelectedActivityFlag = function (item) {
133
- return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === (item === null || item === void 0 ? void 0 : item.id); });
143
+ return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return (activity === null || activity === void 0 ? void 0 : activity.id) === (item === null || item === void 0 ? void 0 : item.id); });
134
144
  };
135
145
  return (_jsx(Collapse, __assign({ in: (activitiesMenuList === null || activitiesMenuList === void 0 ? void 0 : activitiesMenuList.length) > 0 }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t(isCR ? 'activities' : 'category') }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: getSelectedActivities(), placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
136
146
  var _a;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const Article: () => JSX.Element;
3
+ export default Article;