@tap-payments/auth-jsconnect 2.0.38 → 2.0.39

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.
@@ -84,6 +84,7 @@ export declare type PasswordCreateFormValues = {
84
84
  export declare type EntityFormValues = {
85
85
  licenseNumber: string;
86
86
  licenseName: string;
87
+ licenseType: string;
87
88
  activities: Array<Activity>;
88
89
  operationStartDate: string;
89
90
  uploading?: boolean;
@@ -79,7 +79,7 @@ export var verifyLeadToken = createAsyncThunk('bankVerifyLeadToken', function (t
79
79
  countryIso2 = (_a = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _a === void 0 ? void 0 : _a.country;
80
80
  if (countryIso2)
81
81
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
82
- info = boardInfoData.info;
82
+ info = (boardInfoData || {}).info;
83
83
  hasBankCompleted = ((_b = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'bank'; })) === null || _b === void 0 ? void 0 : _b.status) === 'completed';
84
84
  if (data.step_name === BANK_STEP_NAMES.PHONE_AUTH) {
85
85
  thunkApi.dispatch(handleCurrentActiveScreen('BANK_VERIFY_STEP'));
@@ -102,7 +102,7 @@ export var verifyLeadToken = createAsyncThunk('bankVerifyLeadToken', function (t
102
102
  name: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _c === void 0 ? void 0 : _c.names,
103
103
  contact: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.contact,
104
104
  business: boardData === null || boardData === void 0 ? void 0 : boardData.business,
105
- flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info)
105
+ flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || [])
106
106
  },
107
107
  token: token
108
108
  }];
@@ -275,7 +275,7 @@ export var updateBoardSuccess = createAsyncThunk('updateBoardBankSuccess', funct
275
275
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
276
276
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
277
277
  thunkApi.dispatch(handleNextScreenStep());
278
- return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat(data === null || data === void 0 ? void 0 : data.info) }), formData: params }];
278
+ return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat((data === null || data === void 0 ? void 0 : data.info) || []) }), formData: params }];
279
279
  }
280
280
  });
281
281
  }); });
@@ -164,7 +164,7 @@ export var verifyLeadToken = createAsyncThunk('businessVerifyLeadToken', functio
164
164
  _h.label = 18;
165
165
  case 18: return [2, {
166
166
  data: data,
167
- leadData: __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat(boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) }),
167
+ leadData: __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat((boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) || []) }),
168
168
  token: token,
169
169
  brandInfo: brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.brand,
170
170
  boardId: (_g = leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data) === null || _g === void 0 ? void 0 : _g.board_id
@@ -254,7 +254,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
254
254
  return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
255
255
  case 9:
256
256
  boardResponse = _j.sent();
257
- leadResponse.data = __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat(boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) });
257
+ leadResponse.data = __assign(__assign({}, leadResponse === null || leadResponse === void 0 ? void 0 : leadResponse.data), { flows: BUSINESS_FLOW_SUCCESS.concat((boardResponse === null || boardResponse === void 0 ? void 0 : boardResponse.info) || []) });
258
258
  _j.label = 10;
259
259
  case 10: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
260
260
  case 11:
@@ -11,6 +11,7 @@ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
11
11
  name: any;
12
12
  contact: any;
13
13
  flows: any;
14
+ entity_activities: any;
14
15
  };
15
16
  token: string;
16
17
  }, string, {}>;
@@ -28,6 +29,7 @@ export declare const verifyEntityLeadOTP: import("@reduxjs/toolkit").AsyncThunk<
28
29
  name: any;
29
30
  contact: any;
30
31
  flows: any;
32
+ entity_activities: any;
31
33
  };
32
34
  formData: OTPFormValues;
33
35
  }, OTPFormValues, {}>;
@@ -48,13 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
- import { FlowsTypes } from '../../../@types';
51
+ import { BusinessType, FlowsTypes } from '../../../@types';
52
52
  import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
53
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, boardData, entityData, boardInfoData, countryIso2, board_id, board_info_id, entityId, info, hasEntityCompleted;
57
+ var payload, data, boardData, entityData, boardInfoData, countryIso2, board_id, board_info_id, entityId, activities, data_1, info, hasEntityCompleted;
58
58
  var _a, _b, _c, _d;
59
59
  return __generator(this, function (_e) {
60
60
  switch (_e.label) {
@@ -67,13 +67,13 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
67
67
  case 1:
68
68
  data = (_e.sent()).data;
69
69
  countryIso2 = undefined;
70
- if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 8];
70
+ if (!(!(data === null || data === void 0 ? void 0 : data.errors) && !(data === null || data === void 0 ? void 0 : data.mw_error))) return [3, 9];
71
71
  if (data === null || data === void 0 ? void 0 : data.country_code) {
72
72
  countryIso2 = data === null || data === void 0 ? void 0 : data.country_code;
73
73
  if (countryIso2)
74
74
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
75
75
  }
76
- if (!(data.step_name !== ENTITY_STEP_NAMES.PHONE_AUTH)) return [3, 8];
76
+ if (!(data.step_name !== ENTITY_STEP_NAMES.PHONE_AUTH)) return [3, 9];
77
77
  board_id = data === null || data === void 0 ? void 0 : data.id;
78
78
  board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
79
79
  if (!(board_id && board_info_id)) return [3, 3];
@@ -89,18 +89,24 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
89
89
  _e.label = 5;
90
90
  case 5:
91
91
  entityId = (_a = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _a === void 0 ? void 0 : _a.id;
92
- if (!entityId) return [3, 7];
92
+ if (!entityId) return [3, 8];
93
93
  return [4, API.entityService.retrieveEntity(entityId)];
94
94
  case 6:
95
95
  entityData = _e.sent();
96
- _e.label = 7;
96
+ activities = (entityData || {}).activities;
97
+ if (!!activities) return [3, 8];
98
+ return [4, API.dataService.getActivities()];
97
99
  case 7:
100
+ data_1 = _e.sent();
101
+ entityData = __assign(__assign({}, entityData), { entity_activities: data_1.list });
102
+ _e.label = 8;
103
+ case 8:
98
104
  if (!countryIso2) {
99
105
  countryIso2 = entityData.country;
100
106
  if (countryIso2)
101
107
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
102
108
  }
103
- info = boardInfoData.info;
109
+ info = (boardInfoData || {}).info;
104
110
  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';
105
111
  if (hasEntityCompleted) {
106
112
  thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
@@ -108,8 +114,8 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
108
114
  else {
109
115
  thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
110
116
  }
111
- _e.label = 8;
112
- case 8: return [2, {
117
+ _e.label = 9;
118
+ case 9: return [2, {
113
119
  data: data,
114
120
  boardResponse: {
115
121
  user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
@@ -119,7 +125,8 @@ export var verifyLeadToken = createAsyncThunk('entityVerifyLeadToken', function
119
125
  merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
120
126
  name: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _c === void 0 ? void 0 : _c.names,
121
127
  contact: (_d = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _d === void 0 ? void 0 : _d.contact,
122
- flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
128
+ flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info,
129
+ entity_activities: entityData === null || entityData === void 0 ? void 0 : entityData.entity_activities
123
130
  },
124
131
  token: token
125
132
  }];
@@ -144,7 +151,7 @@ export var resendOTP = createAsyncThunk('entityResendOTP', function (params, thu
144
151
  });
145
152
  }); });
146
153
  export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
147
- var _a, entity, settings, responseBody, payload, data, boardData, entityData, boardInfoData, board_id, board_info_id, entityId, info, hasEntityCompleted;
154
+ var _a, entity, settings, responseBody, payload, data, boardData, entityData, boardInfoData, board_id, board_info_id, entityId, activities, data_2, info, hasEntityCompleted;
148
155
  var _b, _c, _d, _e, _f, _g, _h;
149
156
  return __generator(this, function (_j) {
150
157
  switch (_j.label) {
@@ -162,7 +169,7 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
162
169
  case 1:
163
170
  data = (_j.sent()).data;
164
171
  boardInfoData = undefined;
165
- if (!!data.errors) return [3, 8];
172
+ if (!!data.errors) return [3, 9];
166
173
  board_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.id;
167
174
  board_info_id = responseBody === null || responseBody === void 0 ? void 0 : responseBody.board_info_id;
168
175
  if (!(board_id && board_info_id)) return [3, 3];
@@ -178,14 +185,20 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
178
185
  _j.label = 5;
179
186
  case 5:
180
187
  entityId = (_c = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _c === void 0 ? void 0 : _c.id;
181
- if (!entityId) return [3, 7];
188
+ if (!entityId) return [3, 8];
182
189
  return [4, API.entityService.retrieveEntity(entityId)];
183
190
  case 6:
184
191
  entityData = _j.sent();
185
- _j.label = 7;
192
+ activities = (entityData || {}).activities;
193
+ if (!!activities) return [3, 8];
194
+ return [4, API.dataService.getActivities()];
186
195
  case 7:
196
+ data_2 = _j.sent();
197
+ entityData = __assign(__assign({}, entityData), { entity_activities: data_2.list });
198
+ _j.label = 8;
199
+ case 8:
187
200
  (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, { otp: params.otp });
188
- info = boardInfoData.info;
201
+ info = (boardInfoData || {}).info;
189
202
  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';
190
203
  if (hasEntityCompleted) {
191
204
  thunkApi.dispatch(handleNextScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
@@ -193,8 +206,8 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
193
206
  else {
194
207
  thunkApi.dispatch(handleNextScreenStep('ENTITY_INFO_STEP'));
195
208
  }
196
- _j.label = 8;
197
- case 8: return [2, {
209
+ _j.label = 9;
210
+ case 9: return [2, {
198
211
  data: data,
199
212
  boardResponse: {
200
213
  user: boardData === null || boardData === void 0 ? void 0 : boardData.user,
@@ -204,7 +217,8 @@ export var verifyEntityLeadOTP = createAsyncThunk('verifyEntityLeadOTP', functio
204
217
  merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant,
205
218
  name: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _g === void 0 ? void 0 : _g.names,
206
219
  contact: (_h = boardData === null || boardData === void 0 ? void 0 : boardData.user) === null || _h === void 0 ? void 0 : _h.contact,
207
- flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info
220
+ flows: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info,
221
+ entity_activities: entityData === null || entityData === void 0 ? void 0 : entityData.entity_activities
208
222
  },
209
223
  formData: params
210
224
  }];
@@ -343,6 +357,7 @@ var initialState = {
343
357
  entityData: {
344
358
  licenseName: '',
345
359
  licenseNumber: '',
360
+ licenseType: BusinessType.CR,
346
361
  activities: [],
347
362
  operationStartDate: '',
348
363
  uploading: false
@@ -370,10 +385,10 @@ export var entitySlice = createSlice({
370
385
  state.customLoading = true;
371
386
  })
372
387
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
373
- var _a, _b, _c, _d;
388
+ var _a, _b, _c, _d, _e;
374
389
  state.error = null;
375
390
  state.customLoading = false;
376
- var _e = action.payload, data = _e.data, token = _e.token, boardResponse = _e.boardResponse;
391
+ var _f = action.payload, data = _f.data, token = _f.token, boardResponse = _f.boardResponse;
377
392
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
378
393
  if (description) {
379
394
  state.error = description;
@@ -381,10 +396,11 @@ export var entitySlice = createSlice({
381
396
  }
382
397
  state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id });
383
398
  state.data.verify.token = token;
384
- var _f = boardResponse || {}, brand = _f.brand, entity = _f.entity;
399
+ var _g = boardResponse || {}, brand = _g.brand, entity = _g.entity, entity_activities = _g.entity_activities;
385
400
  var licenseNumber = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.number;
386
- var entityDate = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.issuing_date;
387
- var startDate = (_d = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _d === void 0 ? void 0 : _d.start_date;
401
+ var licenseType = (_c = entity === null || entity === void 0 ? void 0 : entity.type) === null || _c === void 0 ? void 0 : _c.toLowerCase();
402
+ var entityDate = (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.issuing_date;
403
+ var startDate = (_e = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _e === void 0 ? void 0 : _e.start_date;
388
404
  var issuingDate = undefined;
389
405
  if (entityDate) {
390
406
  var date = new Date(entityDate);
@@ -393,7 +409,9 @@ export var entitySlice = createSlice({
393
409
  }
394
410
  if (licenseNumber)
395
411
  state.data.entityData.licenseNumber = licenseNumber;
396
- var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
412
+ if (licenseType)
413
+ state.data.entityData.licenseType = licenseType;
414
+ var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || entity_activities || [];
397
415
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
398
416
  var _a;
399
417
  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; });
@@ -428,10 +446,10 @@ export var entitySlice = createSlice({
428
446
  state.error = null;
429
447
  })
430
448
  .addCase(verifyEntityLeadOTP.fulfilled, function (state, action) {
431
- var _a, _b, _c, _d;
449
+ var _a, _b, _c, _d, _e;
432
450
  state.loading = false;
433
451
  state.error = null;
434
- var _e = action.payload, data = _e.data, boardResponse = _e.boardResponse, formData = _e.formData;
452
+ var _f = action.payload, data = _f.data, boardResponse = _f.boardResponse, formData = _f.formData;
435
453
  var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
436
454
  if (description) {
437
455
  state.error = description;
@@ -440,10 +458,11 @@ export var entitySlice = createSlice({
440
458
  state.data.otpData = formData;
441
459
  state.data.otpData.responseBody = data;
442
460
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), boardResponse);
443
- var _f = boardResponse || {}, brand = _f.brand, entity = _f.entity;
461
+ var _g = boardResponse || {}, brand = _g.brand, entity = _g.entity, entity_activities = _g.entity_activities;
444
462
  var licenseNumber = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.number;
445
- var entityDate = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.issuing_date;
446
- var startDate = (_d = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _d === void 0 ? void 0 : _d.start_date;
463
+ var licenseType = (_c = entity === null || entity === void 0 ? void 0 : entity.type) === null || _c === void 0 ? void 0 : _c.toLowerCase();
464
+ var entityDate = (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.issuing_date;
465
+ var startDate = (_e = brand === null || brand === void 0 ? void 0 : brand.operations) === null || _e === void 0 ? void 0 : _e.start_date;
447
466
  var issuingDate = undefined;
448
467
  if (entityDate) {
449
468
  var date = new Date(entityDate);
@@ -452,7 +471,9 @@ export var entitySlice = createSlice({
452
471
  }
453
472
  if (licenseNumber)
454
473
  state.data.entityData.licenseNumber = licenseNumber;
455
- var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || [];
474
+ if (licenseType)
475
+ state.data.entityData.licenseType = licenseType;
476
+ var activities = (entity === null || entity === void 0 ? void 0 : entity.activities) || entity_activities || [];
456
477
  var selectedActivity = activities === null || activities === void 0 ? void 0 : activities.filter(function (activity) {
457
478
  var _a;
458
479
  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; });
@@ -98,7 +98,7 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
98
98
  if (countryCode)
99
99
  thunkApi.dispatch(handleSetCountryByIso2(countryCode));
100
100
  }
101
- info = boardInfoData.info;
101
+ info = (boardInfoData || {}).info;
102
102
  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';
103
103
  if (!hasIndividualCompleted) return [3, 7];
104
104
  thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
@@ -125,7 +125,7 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
125
125
  countries: countries,
126
126
  countryCode: countryCode,
127
127
  notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification,
128
- flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info)
128
+ flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || [])
129
129
  },
130
130
  token: token
131
131
  }];
@@ -231,7 +231,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
231
231
  _l.label = 6;
232
232
  case 6:
233
233
  countryCode = (_e = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _e === void 0 ? void 0 : _e.country;
234
- info = boardInfoData.info;
234
+ info = (boardInfoData || {}).info;
235
235
  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';
236
236
  (_h = (_g = settings.data.appConfig).onStepCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, settings.data.activeScreen.name, { otp: params.otp });
237
237
  if (!hasIndividualCompleted) return [3, 7];
@@ -259,7 +259,7 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
259
259
  countries: countries,
260
260
  countryCode: countryCode,
261
261
  notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification,
262
- flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info)
262
+ flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || [])
263
263
  },
264
264
  formData: __assign({}, params)
265
265
  }];
@@ -322,7 +322,7 @@ export var updateBoardSuccess = createAsyncThunk('individualUpdateBoardSuccess',
322
322
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
323
323
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
324
324
  thunkApi.dispatch(handleNextScreenStep());
325
- return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat(data === null || data === void 0 ? void 0 : data.info) }), formData: params }];
325
+ return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat((data === null || data === void 0 ? void 0 : data.info) || []) }), formData: params }];
326
326
  }
327
327
  });
328
328
  }); });
@@ -76,7 +76,7 @@ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', functio
76
76
  case 3: return [4, thunkApi.dispatch(retrieveBoardDetails(board_id))];
77
77
  case 4:
78
78
  _b.sent();
79
- info = boardInfoData.info;
79
+ info = (boardInfoData || {}).info;
80
80
  hasPasswordCompleted = ((_a = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'password'; })) === null || _a === void 0 ? void 0 : _a.status) === 'completed';
81
81
  if (data.step_name === PASSWORD_STEP_NAMES.PHONE_AUTH) {
82
82
  thunkApi.dispatch(handleCurrentActiveScreen('PASSWORD_VERIFY_STEP'));
@@ -88,7 +88,7 @@ export var verifyLeadToken = createAsyncThunk('passwordVerifyLeadToken', functio
88
88
  thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
89
89
  }
90
90
  _b.label = 5;
91
- case 5: return [2, { data: data, boardResponse: { flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) }, token: token }];
91
+ case 5: return [2, { data: data, boardResponse: { flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || []) }, token: token }];
92
92
  }
93
93
  });
94
94
  }); });
@@ -202,7 +202,7 @@ export var updateBoardSuccess = createAsyncThunk('passwordUpdateBoardSuccess', f
202
202
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, params);
203
203
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
204
204
  thunkApi.dispatch(handleNextScreenStep());
205
- return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat(data === null || data === void 0 ? void 0 : data.info) }), formData: params }];
205
+ return [2, { response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat((data === null || data === void 0 ? void 0 : data.info) || []) }), formData: params }];
206
206
  }
207
207
  });
208
208
  }); });
@@ -227,7 +227,7 @@ export var verifyOperationToken = createAsyncThunk('verifyOperationToken', funct
227
227
  _a.label = 3;
228
228
  case 3:
229
229
  thunkApi.dispatch(handleNextScreenStep('PASSWORD_CREATE_PASSWORD_STEP'));
230
- return [2, { data: data, token: token, boardId: boardId, flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) }];
230
+ return [2, { data: data, token: token, boardId: boardId, flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || []) }];
231
231
  }
232
232
  });
233
233
  }); });
@@ -73,7 +73,7 @@ export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (to
73
73
  boardInfoData = _d.sent();
74
74
  _d.label = 3;
75
75
  case 3:
76
- info = boardInfoData.info;
76
+ info = (boardInfoData || {}).info;
77
77
  return [4, API.boardService.retrieveBoardDetails(data === null || data === void 0 ? void 0 : data.id)];
78
78
  case 4:
79
79
  boardData = _d.sent();
@@ -93,7 +93,7 @@ export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (to
93
93
  _d.label = 5;
94
94
  case 5: return [2, {
95
95
  data: data,
96
- boardResponse: __assign(__assign({}, boardData === null || boardData === void 0 ? void 0 : boardData.business), { flows: BUSINESS_FLOW_SUCCESS.concat(boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info), entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity, brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand, user: boardData === null || boardData === void 0 ? void 0 : boardData.user, bank: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, vatID: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _c === void 0 ? void 0 : _c.vat_id, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant }),
96
+ boardResponse: __assign(__assign({}, boardData === null || boardData === void 0 ? void 0 : boardData.business), { flows: BUSINESS_FLOW_SUCCESS.concat((boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || []), entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity, brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand, user: boardData === null || boardData === void 0 ? void 0 : boardData.user, bank: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, vatID: (_c = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _c === void 0 ? void 0 : _c.vat_id, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant }),
97
97
  token: token
98
98
  }];
99
99
  }
@@ -210,7 +210,7 @@ export var updateLeadSuccess = createAsyncThunk('taxUpdateLeadSuccess', function
210
210
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
211
211
  thunkApi.dispatch(handleNextScreenStep());
212
212
  return [2, {
213
- response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat(data === null || data === void 0 ? void 0 : data.info), user: boardData === null || boardData === void 0 ? void 0 : boardData.user, bank: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, vatID: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _g === void 0 ? void 0 : _g.vat_id, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant }),
213
+ response: __assign(__assign({}, data), { flows: BUSINESS_FLOW_SUCCESS.concat((data === null || data === void 0 ? void 0 : data.info) || []), user: boardData === null || boardData === void 0 ? void 0 : boardData.user, bank: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, vatID: (_g = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _g === void 0 ? void 0 : _g.vat_id, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant }),
214
214
  formData: params
215
215
  }];
216
216
  }
@@ -42,6 +42,7 @@ import { isSA } from '../../../../utils';
42
42
  import LicenseType from './LicenseType';
43
43
  import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
44
44
  import LicenseCertificate from './LicenseCertificate';
45
+ import { settingsSelector } from '../../../../app/settings';
45
46
  var InputStyled = styled(Input)(function (_a) {
46
47
  var theme = _a.theme;
47
48
  return ({
@@ -61,6 +62,7 @@ var LicenseNameText = styled(Text, { shouldForwardProp: function (prop) { return
61
62
  var LicenseList = function (_a) {
62
63
  var rest = __rest(_a, []);
63
64
  var _b = useAppSelector(businessSelector), data = _b.data, error = _b.error;
65
+ var settingsData = useAppSelector(settingsSelector).data;
64
66
  var businessTypeData = data.businessTypeData;
65
67
  var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
66
68
  var t = useTranslation().t;
@@ -70,7 +72,7 @@ var LicenseList = function (_a) {
70
72
  var selectedLicenseControl = useController({ control: control, name: 'selectedLicense' });
71
73
  var responseBody = businessTypeData.responseBody, selectedLicense = businessTypeData.selectedLicense, licenseNumber = businessTypeData.licenseNumber, entityLegalName = businessTypeData.entityLegalName;
72
74
  var licenseList = (responseBody || { licenseList: [] }).licenseList;
73
- var country_code = (data.verify.responseBody || {}).country_code;
75
+ var country_code = settingsData.businessCountry.iso2;
74
76
  var onOpenLicenseList = function (event) {
75
77
  var _a;
76
78
  setAnchorEl(event.currentTarget);
@@ -140,6 +142,6 @@ var LicenseList = function (_a) {
140
142
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
141
143
  return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
142
144
  return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
143
- } }) }))] })), _jsx(EntityName, { show: show && !isSACountry }), _jsx(LicenseType, { show: show && !isSACountry }), _jsx(LicenseNumber, { show: !isSACountry ? isCR : show, readOnly: licenseReadonly }), _jsx(LicenseCertificate, { show: show && !isSACountry })] }));
145
+ } }) }))] })), _jsx(EntityName, { show: show && !isSACountry }), _jsx(LicenseType, { show: show && !isSACountry }), _jsx(LicenseNumber, { show: !isSACountry ? isCR : show, readOnly: licenseReadonly }), _jsx(LicenseCertificate, { show: show && !isSACountry && isCR })] }));
144
146
  };
145
147
  export default React.memo(LicenseList);
@@ -22,15 +22,15 @@ import Input from '../../../shared/Input';
22
22
  import Collapse from '../../../../components/Collapse';
23
23
  import { BusinessType } from '../../../../@types';
24
24
  import { useAppSelector } from '../../../../hooks';
25
- import { businessSelector } from '../../../app/business/businessStore';
25
+ import { settingsSelector } from '../../../../app/settings';
26
26
  var LicenseNumber = function (_a) {
27
- var _b, _c;
27
+ var _b;
28
28
  var show = _a.show, readOnly = _a.readOnly;
29
29
  var t = useTranslation().t;
30
- var _d = useFormContext(), control = _d.control, watch = _d.watch, getValues = _d.getValues;
30
+ var _c = useFormContext(), control = _c.control, watch = _c.watch, getValues = _c.getValues;
31
31
  var licenseNumberControl = useController({ control: control, name: 'licenseNumber' });
32
- var businessData = useAppSelector(businessSelector).data;
33
- var isSACountry = React.useMemo(function () { var _a; return isSA((_a = businessData.verify.responseBody) === null || _a === void 0 ? void 0 : _a.country_code); }, [(_b = businessData.verify.responseBody) === null || _b === void 0 ? void 0 : _b.country_code]);
32
+ var settingsData = useAppSelector(settingsSelector).data;
33
+ var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
34
34
  var selectedLicense = !isSACountry ? watch('selectedLicense') : getValues('selectedLicense');
35
35
  var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
36
36
  var handleFLNumberChange = function (_a) {
@@ -42,7 +42,7 @@ var LicenseNumber = function (_a) {
42
42
  licenseNumberControl.field.onChange('');
43
43
  };
44
44
  var licenseNumberValue = licenseNumberControl.field.value;
45
- var error = (_c = licenseNumberControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
45
+ var error = (_b = licenseNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
46
46
  var length = !isSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_LENGTH : FL_NUMBER_LENGTH;
47
47
  var minLength = !isSACountry ? KW_MIN_LICENSE_LENGTH : length;
48
48
  var label = isCR ? 'cr_number' : 'fl_number';
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
13
14
  import { styled, alpha } from '@mui/material/styles';
14
15
  import Collapse from '../../../../components/Collapse';
15
16
  import { useTranslation } from 'react-i18next';
@@ -24,6 +25,8 @@ import Radio from '../../../../components/Radio';
24
25
  import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
25
26
  import { businessSelector, clearError } from '../../../app/business/businessStore';
26
27
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
28
+ import { isKW } from '../../../../utils';
29
+ import { settingsSelector } from '../../../../app/settings';
27
30
  var LabelTextStyled = styled(Text)(function (_a) {
28
31
  var theme = _a.theme;
29
32
  return (__assign(__assign({}, theme.typography.caption), { color: alpha(theme.palette.text.primary, 0.6), marginBlockEnd: theme.spacing(0.625) }));
@@ -47,15 +50,23 @@ var RadioStyled = styled(Radio)(function (_a) {
47
50
  var LicenseType = function (_a) {
48
51
  var show = _a.show;
49
52
  var t = useTranslation().t;
50
- var control = useFormContext().control;
53
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
51
54
  var error = useAppSelector(businessSelector).error;
55
+ var settingsData = useAppSelector(settingsSelector).data;
56
+ var country_code = settingsData.businessCountry.iso2;
52
57
  var selectedLicenseControl = useController({ control: control, name: 'selectedLicense' });
53
58
  var dispatch = useAppDispatch();
59
+ var isKWCountry = React.useMemo(function () { return isKW(country_code); }, [country_code]);
54
60
  var handleOnChange = function (_a) {
55
61
  var target = _a.target;
56
62
  if (error)
57
63
  dispatch(clearError());
58
64
  selectedLicenseControl.field.onChange(target.value === BusinessType.FL ? OTHER_FL_LICENSE : OTHER_CR_LICENSE);
65
+ if (isKWCountry && target.value === BusinessType.FL) {
66
+ setValue('licenseNumber', '', { shouldValidate: true });
67
+ setValue('certificateFile', undefined, { shouldValidate: true });
68
+ setValue('certificateId', undefined, { shouldValidate: true });
69
+ }
59
70
  };
60
71
  var selectedLicenseValue = selectedLicenseControl.field.value;
61
72
  return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { pb: 1.5, pl: 2.5, pr: 2.5 } }, { children: [_jsxs(LabelTextStyled, { children: [t('signup_business_type_label'), _jsx(Mandatory, {})] }), _jsxs(RadioGroupStyled, __assign({ value: selectedLicenseValue != null
@@ -30,15 +30,17 @@ import { useAppDispatch, useAppSelector, useLanguage, useSetFromDefaultValues }
30
30
  import { entitySelector, updateEntity } from '../../../app/entity/entityStore';
31
31
  import { FormProvider, useForm } from 'react-hook-form';
32
32
  import { yupResolver } from '@hookform/resolvers/yup';
33
- import { handlePrevScreenStep } from '../../../../app/settings';
33
+ import { BusinessType } from '../../../../@types';
34
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
34
35
  import { styled } from '@mui/system';
35
- import { EntityInfoValidationSchema } from './validation';
36
+ import { EntityInfoValidationSchema, EntityInfoKWValidationSchema } from './validation';
36
37
  import Form from '../../../../components/Form';
37
38
  import Collapse from '../../../../components/Collapse';
38
39
  import Button from '../../../shared/Button';
39
40
  import { useTranslation } from 'react-i18next';
40
41
  import OperationStartDate from './OperationStartDate';
41
42
  import Article from './Article';
43
+ import { isKW } from '../../../../utils';
42
44
  var FormStyled = styled(Form)(function () { return ({
43
45
  display: 'flex',
44
46
  flexDirection: 'column'
@@ -47,12 +49,17 @@ var EntityInfo = function (_a) {
47
49
  var _b = React.useState(false), anchorEl = _b[0], setAnchorEl = _b[1];
48
50
  var _c = React.useState(false), collapse = _c[0], setCollapse = _c[1];
49
51
  var _d = useAppSelector(entitySelector), data = _d.data, loading = _d.loading, error = _d.error, uploading = _d.uploading;
52
+ var settingsData = useAppSelector(settingsSelector).data;
50
53
  var isAr = useLanguage().isAr;
51
54
  var t = useTranslation().t;
52
55
  var dispatch = useAppDispatch();
53
- var _e = data.entityData, responseBody = _e.responseBody, defaultValues = __rest(_e, ["responseBody"]);
56
+ var defaultValues = __rest(data.entityData, []);
57
+ var country_code = settingsData.businessCountry.iso2;
58
+ var licenseType = defaultValues.licenseType;
59
+ var isKWCountry = React.useMemo(function () { return isKW(country_code); }, [country_code]);
60
+ var isCR = React.useMemo(function () { return licenseType === BusinessType.CR; }, [licenseType]);
54
61
  var methods = useForm({
55
- resolver: yupResolver(EntityInfoValidationSchema),
62
+ resolver: yupResolver(isKWCountry ? EntityInfoKWValidationSchema : EntityInfoValidationSchema),
56
63
  defaultValues: defaultValues,
57
64
  mode: 'onChange'
58
65
  });
@@ -70,6 +77,8 @@ var EntityInfo = function (_a) {
70
77
  anchorEl ? setAnchorEl(false) : setAnchorEl(true);
71
78
  };
72
79
  var disabled = !methods.formState.isValid || !!error || uploading;
73
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse && !anchorEl }, { children: [_jsx(LicenseName, {}), _jsx(LicenseNumber, {})] })), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Article, {}) })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
80
+ var showLicenseNumber = isKWCountry ? isCR : true;
81
+ var showCertificate = isCR;
82
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse && !anchorEl }, { children: [_jsx(LicenseName, {}), _jsx(LicenseNumber, { show: showLicenseNumber })] })), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl && showCertificate }, { children: _jsx(Article, {}) })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
74
83
  };
75
84
  export default EntityInfo;
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  interface LicenseNumberProps {
3
+ show: boolean;
3
4
  }
4
- declare const _default: React.MemoExoticComponent<({}: LicenseNumberProps) => JSX.Element>;
5
+ declare const _default: React.MemoExoticComponent<({ show }: LicenseNumberProps) => JSX.Element>;
5
6
  export default _default;
@@ -17,20 +17,26 @@ import { ScreenContainer } from '../../../shared/Containers';
17
17
  import Input from '../../../shared/Input';
18
18
  import { useAppSelector } from '../../../../hooks';
19
19
  import { entitySelector } from '../../../app/entity/entityStore';
20
- import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
20
+ import { isSA, removeAllOtherThanCharsAndNumber } from '../../../../utils';
21
21
  import { BusinessType } from '../../../../@types';
22
- import { CR_NUMBER_LENGTH, FL_NUMBER_LENGTH } from '../../../../constants';
22
+ import { CR_NUMBER_LENGTH, FL_NUMBER_LENGTH, KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
23
+ import Collapse from '../../../../components/Collapse';
24
+ import { settingsSelector } from '../../../../app/settings';
23
25
  var LicenseNumber = function (_a) {
24
- var _b, _c;
26
+ var _b, _c, _d, _e;
27
+ var show = _a.show;
25
28
  var t = useTranslation().t;
26
29
  var data = useAppSelector(entitySelector).data;
27
- var _d = useFormContext(), control = _d.control, setValue = _d.setValue;
30
+ var settingsData = useAppSelector(settingsSelector).data;
31
+ var _f = useFormContext(), control = _f.control, setValue = _f.setValue;
28
32
  var entity = (data.verify.responseBody || {}).entity;
29
33
  var licenseType = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.type;
30
34
  var type = licenseType === 'freelance' ? BusinessType.FL : BusinessType.CR;
31
35
  var isLicensedTrue = entity === null || entity === void 0 ? void 0 : entity.is_licensed;
32
36
  var hasLicenseNumber = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.number;
37
+ var resLicenseNumber = (_d = entity === null || entity === void 0 ? void 0 : entity.license) === null || _d === void 0 ? void 0 : _d.number;
33
38
  var licenseNumber = data.entityData.licenseNumber;
39
+ var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
34
40
  React.useEffect(function () {
35
41
  setValue('licenseNumber', licenseNumber, { shouldValidate: true });
36
42
  }, [licenseNumber]);
@@ -41,9 +47,11 @@ var LicenseNumber = function (_a) {
41
47
  };
42
48
  var licenseNumberControl = useController({ control: control, name: 'licenseNumber' });
43
49
  var licenseNumberValue = licenseNumberControl.field.value;
50
+ var error = (_e = licenseNumberControl.fieldState.error) === null || _e === void 0 ? void 0 : _e.message;
44
51
  var isCR = type === BusinessType.CR;
45
- var length = isCR ? CR_NUMBER_LENGTH : FL_NUMBER_LENGTH;
46
- var disabled = hasLicenseNumber && isLicensedTrue;
47
- return (_jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('license_number_label'), onChange: handleChange, disabled: disabled, inputProps: { maxLength: length }, value: licenseNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } } }) })));
52
+ var length = !isSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_LENGTH : FL_NUMBER_LENGTH;
53
+ var minLength = !isSACountry ? KW_MIN_LICENSE_LENGTH : length;
54
+ var disabled = hasLicenseNumber && isLicensedTrue && (resLicenseNumber === null || resLicenseNumber === void 0 ? void 0 : resLicenseNumber.length) >= minLength;
55
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('license_number_label'), onChange: handleChange, disabled: disabled, inputProps: { maxLength: length }, value: licenseNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) })) })));
48
56
  };
49
57
  export default React.memo(LicenseNumber);
@@ -1,6 +1,7 @@
1
1
  import * as yup from 'yup';
2
2
  export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
3
  licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ licenseType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
5
  licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
6
  activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
7
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
@@ -23,6 +24,7 @@ export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/li
23
24
  articleFile: any;
24
25
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
25
26
  licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
27
+ licenseType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
26
28
  licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
27
29
  activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
28
30
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
@@ -45,6 +47,77 @@ export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/li
45
47
  articleFile: any;
46
48
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
47
49
  licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
50
+ licenseType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
51
+ licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
52
+ activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
53
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
54
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
55
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
56
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
57
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
58
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
59
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
60
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
61
+ }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
62
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
63
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
64
+ }>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
65
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
66
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
67
+ }>>[] | undefined>;
68
+ operationStartDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
69
+ articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
70
+ articleFile: any;
71
+ }>>>;
72
+ export declare const EntityInfoKWValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
73
+ licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
74
+ licenseType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
75
+ licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
76
+ activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
77
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
78
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
79
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
80
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
81
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
82
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
83
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
84
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
85
+ }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
86
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
87
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
88
+ }>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
89
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
90
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
91
+ }>>[] | undefined>;
92
+ operationStartDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
93
+ articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
94
+ articleFile: any;
95
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
96
+ licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
97
+ licenseType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
98
+ licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
99
+ activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
100
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
101
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
102
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
103
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
104
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
105
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
106
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
107
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
108
+ }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
109
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
110
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
111
+ }>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
112
+ ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
113
+ en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
114
+ }>>[] | undefined>;
115
+ operationStartDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
116
+ articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
117
+ articleFile: any;
118
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
119
+ licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
120
+ licenseType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
48
121
  licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
49
122
  activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
50
123
  ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
@@ -1,8 +1,67 @@
1
- import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
1
+ import { KW_MIN_LICENSE_LENGTH, MAX_FILE_SIZE, VALID_FILE_FORMATS, CR_MIN_LICENSE_LENGTH, FL_MIN_LICENSE_LENGTH } from '../../../../constants';
2
+ import { BusinessType } from '../../../../@types';
2
3
  import * as yup from 'yup';
3
4
  export var EntityInfoValidationSchema = yup.object().shape({
4
5
  licenseName: yup.string().required(''),
5
- licenseNumber: yup.string().required(''),
6
+ licenseType: yup.string().required(''),
7
+ licenseNumber: yup
8
+ .string()
9
+ .test({
10
+ test: function (value) {
11
+ var type = this.parent.licenseType;
12
+ var isCR = type === BusinessType.CR;
13
+ var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
14
+ if (length === 0)
15
+ return true;
16
+ if (isCR) {
17
+ return length > CR_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_max_length' });
18
+ }
19
+ return length > FL_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
20
+ }
21
+ })
22
+ .required(''),
23
+ activities: yup.array().of(yup.object().shape({
24
+ ar: yup.string(),
25
+ en: yup.string()
26
+ })),
27
+ operationStartDate: yup.string().required('choose_any_business_date'),
28
+ articleId: yup.string().optional(),
29
+ articleFile: yup
30
+ .mixed()
31
+ .test({
32
+ test: function (value) {
33
+ if (!!value)
34
+ return VALID_FILE_FORMATS.includes(value === null || value === void 0 ? void 0 : value.type) && (value === null || value === void 0 ? void 0 : value.size) < MAX_FILE_SIZE
35
+ ? true
36
+ : this.createError({ message: 'alert_file_upload' });
37
+ return true;
38
+ }
39
+ })
40
+ .optional()
41
+ });
42
+ export var EntityInfoKWValidationSchema = yup.object().shape({
43
+ licenseName: yup.string().required(''),
44
+ licenseType: yup.string().required(''),
45
+ licenseNumber: yup
46
+ .string()
47
+ .when('licenseType', function (licenseType) {
48
+ var isCR = licenseType === BusinessType.CR;
49
+ if (!isCR) {
50
+ return yup.string().optional();
51
+ }
52
+ return yup
53
+ .string()
54
+ .required('')
55
+ .test({
56
+ test: function (value) {
57
+ var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
58
+ if (length === 0)
59
+ return true;
60
+ return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_kw_max_length' });
61
+ }
62
+ });
63
+ })
64
+ .required(''),
6
65
  activities: yup.array().of(yup.object().shape({
7
66
  ar: yup.string(),
8
67
  en: yup.string()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.38",
3
+ "version": "2.0.39",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",