@tap-payments/auth-jsconnect 2.8.2-test → 2.8.10-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.
@@ -55,10 +55,10 @@ import { getRecentDocumentBasedOnPurpose, hasNoneEditableValue, retrieveIndividu
55
55
  export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (_a, thunkApi) {
56
56
  var token = _a.token, isInternally = _a.isInternally;
57
57
  return __awaiter(void 0, void 0, void 0, function () {
58
- var payload, data, boardData, boardInfoData, individualData, publicKey, _b, id_1, type_1, serviceCallBack, _c, boardRes, individualRes, countryIso2;
59
- var _d, _e, _f, _g, _h;
60
- return __generator(this, function (_j) {
61
- switch (_j.label) {
58
+ var payload, data, entityData, _b, config, country_code, entity_id, publicKey, countryIso2;
59
+ var _c;
60
+ return __generator(this, function (_d) {
61
+ switch (_d.label) {
62
62
  case 0:
63
63
  payload = __assign({ service_name: 'tap_email', verify_token: token }, (isInternally && {
64
64
  notification: {
@@ -67,49 +67,36 @@ export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (_a
67
67
  }));
68
68
  return [4, API.leadService.verifyLeadToken(payload)];
69
69
  case 1:
70
- data = (_j.sent()).data;
71
- individualData = undefined;
72
- if (((_d = data === null || data === void 0 ? void 0 : data.errors) === null || _d === void 0 ? void 0 : _d.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
70
+ data = (_d.sent()).data;
71
+ entityData = undefined;
72
+ if (((_c = data === null || data === void 0 ? void 0 : data.errors) === null || _c === void 0 ? void 0 : _c.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
73
73
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
74
74
  if (isInternally)
75
75
  data.step_name = TAX_STEP_NAMES.TAX_INFO;
76
- publicKey = (_e = data === null || data === void 0 ? void 0 : data.config) === null || _e === void 0 ? void 0 : _e.public_key;
77
- if (publicKey) {
76
+ _b = data || {}, config = _b.config, country_code = _b.country_code, entity_id = _b.entity_id;
77
+ publicKey = config === null || config === void 0 ? void 0 : config.public_key;
78
+ if (publicKey)
78
79
  thunkApi.dispatch(handlePublicKey(publicKey));
79
- }
80
- if (!(data === null || data === void 0 ? void 0 : data.id)) return [3, 6];
81
- if (!data.board_info_id) return [3, 3];
82
- return [4, API.boardService.retrieveBoardInfo({ id: data.id, infoId: data.board_info_id })];
83
- case 2:
84
- boardInfoData = _j.sent();
85
- _j.label = 3;
86
- case 3: return [4, API.boardService.retrieveBoardDetails(data.id)];
87
- case 4:
88
- boardData = _j.sent();
89
- _b = ((_f = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _f === void 0 ? void 0 : _f.recipient) || {}, id_1 = _b.id, type_1 = _b.type;
90
- serviceCallBack = function () { return API.individualService.retrieveIndividual(id_1, type_1); };
91
- return [4, retrieveIndividualData(type_1, boardData, serviceCallBack)];
92
- case 5:
93
- _c = _j.sent(), boardRes = _c.boardRes, individualRes = _c.individualRes;
94
- boardData = boardRes;
95
- individualData = individualRes;
96
- _j.label = 6;
97
- case 6:
98
- countryIso2 = (_g = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _g === void 0 ? void 0 : _g.country;
80
+ countryIso2 = country_code;
99
81
  if (countryIso2)
100
82
  thunkApi.dispatch(handleSetCountryByIso2(countryIso2));
101
- if (data.step_name === TAX_STEP_NAMES.PHONE_AUTH) {
102
- thunkApi.dispatch(handleCurrentActiveScreen('TAX_VERIFY_STEP'));
103
- }
104
- else if (data.step_name === TAX_STEP_NAMES.TAX_INFO) {
105
- thunkApi.dispatch(handleNextScreenStep('TAX_TAX_DETAILS_STEP'));
106
- }
107
- return [2, {
108
- data: data,
109
- individualData: individualData,
110
- boardResponse: __assign(__assign({}, boardData === null || boardData === void 0 ? void 0 : boardData.business), { 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_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, vatID: (_h = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _h === void 0 ? void 0 : _h.vat_id, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant, individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals, business: boardData === null || boardData === void 0 ? void 0 : boardData.business, notification: boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification }),
111
- token: token
112
- }];
83
+ if (!(data.step_name === TAX_STEP_NAMES.PHONE_AUTH)) return [3, 2];
84
+ thunkApi.dispatch(handleCurrentActiveScreen('TAX_VERIFY_STEP'));
85
+ return [3, 4];
86
+ case 2:
87
+ if (!(data.step_name === TAX_STEP_NAMES.TAX_INFO)) return [3, 4];
88
+ if (!entity_id)
89
+ throw new Error('Internal server error');
90
+ return [4, API.entityService.retrieveEntity(entity_id)];
91
+ case 3:
92
+ entityData = _d.sent();
93
+ thunkApi.dispatch(handleNextScreenStep('TAX_TAX_DETAILS_STEP'));
94
+ _d.label = 4;
95
+ case 4: return [2, {
96
+ data: data,
97
+ entityData: entityData === null || entityData === void 0 ? void 0 : entityData.entity,
98
+ token: token
99
+ }];
113
100
  }
114
101
  });
115
102
  });
@@ -132,34 +119,59 @@ export var resendOTP = createAsyncThunk('resendOTPTax', function (params, thunkA
132
119
  });
133
120
  }); });
134
121
  export var retrieveBoardStatus = createAsyncThunk('tax/retrieveBoardStatus', function (parmas, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
135
- var tax, board_id, data;
136
- return __generator(this, function (_a) {
137
- switch (_a.label) {
122
+ var tax, _a, board_id, board_info_id, _b, boardInfoData, data, _c, id, type;
123
+ var _d;
124
+ return __generator(this, function (_e) {
125
+ switch (_e.label) {
138
126
  case 0:
139
127
  tax = thunkApi.getState().tax;
140
- board_id = (tax.data.verify.responseBody || {}).board_id;
141
- return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
128
+ _a = tax.data.verify.responseBody || {}, board_id = _a.board_id, board_info_id = _a.board_info_id;
129
+ if (!board_id || !board_info_id)
130
+ throw new Error('Internal server error');
131
+ return [4, Promise.all([
132
+ API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id }),
133
+ API.boardService.retrieveBoardInfoStatus(board_id)
134
+ ])];
142
135
  case 1:
143
- data = _a.sent();
136
+ _b = _e.sent(), boardInfoData = _b[0], data = _b[1];
137
+ _c = ((_d = boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.notification) === null || _d === void 0 ? void 0 : _d.recipient) || {}, id = _c.id, type = _c.type;
138
+ return [4, thunkApi.dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type })).unwrap()];
139
+ case 2:
140
+ _e.sent();
144
141
  thunkApi.dispatch(handlePrevScreenStep());
145
- return [2, { flows: (data === null || data === void 0 ? void 0 : data.info) || [] }];
142
+ return [2, { data: boardInfoData, flows: (data === null || data === void 0 ? void 0 : data.info) || [] }];
146
143
  }
147
144
  });
148
145
  }); });
149
- export var retrieveEntityInfo = createAsyncThunk('retrieveTaxEntityInfo', function (entityID) { return __awaiter(void 0, void 0, void 0, function () {
150
- var data;
151
- return __generator(this, function (_a) {
152
- switch (_a.label) {
153
- case 0: return [4, API.entityService.retrieveEntityInfo(entityID)];
154
- case 1:
155
- data = (_a.sent()).data;
156
- return [2, { data: data }];
157
- }
146
+ export var retrieveBoardDetails = createAsyncThunk('tax/retrieveBrandInfo', function (_a) {
147
+ var boardId = _a.boardId, id = _a.individualId, type = _a.individualType;
148
+ return __awaiter(void 0, void 0, void 0, function () {
149
+ var data, individualData, serviceCallBack, data_state;
150
+ var _b, _c, _d, _e;
151
+ return __generator(this, function (_f) {
152
+ switch (_f.label) {
153
+ case 0: return [4, API.boardService.retrieveBoardDetails(boardId)];
154
+ case 1:
155
+ data = _f.sent();
156
+ individualData = data === null || data === void 0 ? void 0 : data.user;
157
+ if (!(((_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.id) !== id)) return [3, 3];
158
+ serviceCallBack = function () { return API.individualService.retrieveIndividual(id, type); };
159
+ return [4, retrieveIndividualData(type, data, serviceCallBack)];
160
+ case 2:
161
+ individualData = _f.sent();
162
+ _f.label = 3;
163
+ case 3:
164
+ data_state = (((individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized) ? data === null || data === void 0 ? void 0 : data.individuals : individualData) || {}).data_state;
165
+ return [2, __assign(__assign(__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: (_c = data === null || data === void 0 ? void 0 : data.user) === null || _c === void 0 ? void 0 : _c.names, vatID: (_d = data === null || data === void 0 ? void 0 : data.entity) === null || _d === void 0 ? void 0 : _d.vat_id, individuals: data === null || data === void 0 ? void 0 : data.individuals, contact: (_e = data === null || data === void 0 ? void 0 : data.user) === null || _e === void 0 ? void 0 : _e.contact }), (individualData && { user: individualData })), (data_state && {
166
+ individuals: __assign(__assign({}, data === null || data === void 0 ? void 0 : data.individuals), { data_state: data_state })
167
+ }))];
168
+ }
169
+ });
158
170
  });
159
- }); });
171
+ });
160
172
  export var verifyTaxLeadOTP = createAsyncThunk('verifyTaxLeadOTP', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
161
- var _a, tax, settings, responseBody, payload, data, publicKey;
162
- var _b, _c, _d, _e, _f;
173
+ var _a, tax, settings, responseBody, payload, data, _b, config, entity_id, publicKey, entityData;
174
+ var _c, _d, _e, _f;
163
175
  return __generator(this, function (_g) {
164
176
  switch (_g.label) {
165
177
  case 0:
@@ -167,7 +179,7 @@ export var verifyTaxLeadOTP = createAsyncThunk('verifyTaxLeadOTP', function (par
167
179
  responseBody = tax.data.verify.responseBody;
168
180
  payload = {
169
181
  data: params.otp,
170
- service_name: (_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _b === void 0 ? void 0 : _b.service_name,
182
+ service_name: (_c = responseBody === null || responseBody === void 0 ? void 0 : responseBody.verification_by) === null || _c === void 0 ? void 0 : _c.service_name,
171
183
  verify_token: responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token,
172
184
  step_name: TAX_STEP_NAMES.PHONE_AUTH,
173
185
  encryption_contract: ['data']
@@ -175,55 +187,68 @@ export var verifyTaxLeadOTP = createAsyncThunk('verifyTaxLeadOTP', function (par
175
187
  return [4, API.leadService.verifyLeadOTP(payload)];
176
188
  case 1:
177
189
  data = (_g.sent()).data;
178
- if ((_c = data.errors) === null || _c === void 0 ? void 0 : _c.length)
190
+ if ((_d = data.errors) === null || _d === void 0 ? void 0 : _d.length)
179
191
  throw new Error(data.errors[0].description);
180
- publicKey = (_d = data === null || data === void 0 ? void 0 : data.config) === null || _d === void 0 ? void 0 : _d.public_key;
181
- if (publicKey) {
192
+ _b = data || {}, config = _b.config, entity_id = _b.entity_id;
193
+ publicKey = config === null || config === void 0 ? void 0 : config.public_key;
194
+ if (publicKey)
182
195
  thunkApi.dispatch(handlePublicKey(publicKey));
183
- }
196
+ if (!entity_id)
197
+ throw new Error('Internal server error');
198
+ return [4, API.entityService.retrieveEntity(entity_id)];
199
+ case 2:
200
+ entityData = _g.sent();
184
201
  (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, { otp: params.otp });
185
202
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep('TAX_TAX_DETAILS_STEP')); });
186
- return [2, { data: data, formData: params }];
203
+ return [2, { data: data, entityData: entityData === null || entityData === void 0 ? void 0 : entityData.entity, formData: params }];
187
204
  }
188
205
  });
189
206
  }); });
190
207
  export var updateTaxInfo = createAsyncThunk('updateTaxInfo', function (_a, thunkApi) {
191
208
  var formData = _a.formData, originalFormData = _a.originalFormData;
192
209
  return __awaiter(void 0, void 0, void 0, function () {
193
- var _b, settings, tax, _c, entity, notification, _d, id, data_status, documents, isTaxNumberNonEditable, isConfirmPolicyNonEditable, isDocumentsNonEditable, document, vatId, confirmPolicy, documentId, requestBody, data, documentBody, _e, documentBody, _f;
210
+ var _b, settings, tax, _c, entity, notification, board_id, board_info_id, _d, id, data_status, documents, isTaxNumberNonEditable, isConfirmPolicyNonEditable, isDocumentsNonEditable, document, vatId, confirmPolicy, documentId, notificationData, data_1, requestBody, data, documentBody, _e, documentBody, _f;
194
211
  var _g, _h, _j, _k;
195
212
  return __generator(this, function (_l) {
196
213
  switch (_l.label) {
197
214
  case 0:
198
215
  _b = thunkApi.getState(), settings = _b.settings, tax = _b.tax;
199
- _c = tax.data.verify.responseBody || {}, entity = _c.entity, notification = _c.notification;
216
+ _c = tax.data.verify.responseBody || {}, entity = _c.entity, notification = _c.notification, board_id = _c.board_id, board_info_id = _c.board_info_id;
200
217
  _d = entity || {}, id = _d.id, data_status = _d.data_status, documents = _d.documents;
201
218
  isTaxNumberNonEditable = hasNoneEditableValue(data_status, 'tax_number');
202
219
  isConfirmPolicyNonEditable = hasNoneEditableValue(data_status, 'is_vat_acknowledged');
203
220
  isDocumentsNonEditable = hasNoneEditableValue(data_status, 'documents');
204
221
  document = getRecentDocumentBasedOnPurpose(documents, DocumentPurpose.TAX_DOCUMENT);
205
222
  vatId = formData.vatId, confirmPolicy = formData.confirmPolicy, documentId = formData.documentId;
223
+ notificationData = notification;
224
+ if (!(!isConfirmPolicyNonEditable && !notification)) return [3, 2];
225
+ return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
226
+ case 1:
227
+ data_1 = _l.sent();
228
+ notificationData = (data_1 === null || data_1 === void 0 ? void 0 : data_1.notification) || {};
229
+ _l.label = 2;
230
+ case 2:
206
231
  requestBody = __assign(__assign({ id: id, vat_id: isTaxNumberNonEditable ? undefined : vatId }, (!isConfirmPolicyNonEditable && {
207
- vat_acknowledged_by: (_g = notification === null || notification === void 0 ? void 0 : notification.recipient) === null || _g === void 0 ? void 0 : _g.id,
232
+ vat_acknowledged_by: (_g = notificationData === null || notificationData === void 0 ? void 0 : notificationData.recipient) === null || _g === void 0 ? void 0 : _g.id,
208
233
  is_vat_acknowledged: confirmPolicy
209
234
  })), { step_name: TAX_STEP_NAMES.TAX_INFO });
210
235
  return [4, API.entityService.updateEntityInfo(requestBody)];
211
- case 1:
236
+ case 3:
212
237
  data = (_l.sent()).data;
213
238
  if ((_h = data.errors) === null || _h === void 0 ? void 0 : _h.length)
214
239
  throw new Error(data.errors[0].description);
215
- if (!(!isDocumentsNonEditable && (documentId || []).length > 0)) return [3, 5];
216
- if (!(document === null || document === void 0 ? void 0 : document.id)) return [3, 3];
240
+ if (!(!isDocumentsNonEditable && (documentId || []).length > 0)) return [3, 7];
241
+ if (!(document === null || document === void 0 ? void 0 : document.id)) return [3, 5];
217
242
  documentBody = {
218
243
  id: document === null || document === void 0 ? void 0 : document.id,
219
244
  images: documentId
220
245
  };
221
246
  _e = data;
222
247
  return [4, API.documentService.addFilesToExistingDocument(documentBody)];
223
- case 2:
248
+ case 4:
224
249
  _e.documentData = _l.sent();
225
- return [3, 5];
226
- case 3:
250
+ return [3, 7];
251
+ case 5:
227
252
  documentBody = {
228
253
  entity_id: id || '',
229
254
  documents: [
@@ -235,10 +260,10 @@ export var updateTaxInfo = createAsyncThunk('updateTaxInfo', function (_a, thunk
235
260
  };
236
261
  _f = data;
237
262
  return [4, API.documentService.updateDocumentInfo(documentBody)];
238
- case 4:
263
+ case 6:
239
264
  _f.documentData = _l.sent();
240
- _l.label = 5;
241
- case 5:
265
+ _l.label = 7;
266
+ case 7:
242
267
  thunkApi.dispatch(handleNextScreenStep());
243
268
  (_k = (_j = settings.data.appConfig).onStepCompleted) === null || _k === void 0 ? void 0 : _k.call(_j, settings.data.activeScreen.name, requestBody);
244
269
  return [2, { data: data, formData: originalFormData }];
@@ -247,41 +272,39 @@ export var updateTaxInfo = createAsyncThunk('updateTaxInfo', function (_a, thunk
247
272
  });
248
273
  });
249
274
  export var updateLeadSuccess = createAsyncThunk('taxUpdateLeadSuccess', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
250
- var _a, settings, tax, _b, id, infoId, _c, showBoard, mode, payload, data, boardInfoData, boardData;
251
- var _d, _e, _f, _g, _h, _j, _k, _l, _m;
252
- return __generator(this, function (_o) {
253
- switch (_o.label) {
275
+ var _a, settings, tax, _b, board_id, infoId, _c, showBoard, mode, payload, data, _d, id, type, boardInfoStatusData;
276
+ var _e, _f, _g, _h, _j, _k, _l, _m, _o;
277
+ return __generator(this, function (_p) {
278
+ switch (_p.label) {
254
279
  case 0:
255
280
  _a = thunkApi.getState(), settings = _a.settings, tax = _a.tax;
256
- _b = tax.data.verify.responseBody || {}, id = _b.board_id, infoId = _b.board_info_id;
281
+ _b = tax.data.verify.responseBody || {}, board_id = _b.board_id, infoId = _b.board_info_id;
257
282
  _c = settings.data.appConfig, showBoard = _c.showBoard, mode = _c.mode;
258
- if (!id)
283
+ if (!board_id)
259
284
  return [2];
260
285
  payload = {
261
286
  lang: settings.data.language,
262
287
  step_name: TAX_STEP_NAMES.TAX_SUCCESS
263
288
  };
264
- return [4, API.boardService.updateBoardInfo(__assign({ id: id, infoId: infoId }, payload))];
289
+ return [4, API.boardService.updateBoardInfo(__assign({ id: board_id, infoId: infoId }, payload))];
265
290
  case 1:
266
- data = _o.sent();
291
+ data = _p.sent();
267
292
  if (!showBoard && mode === 'content') {
268
- (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, {});
269
- (_g = (_f = settings.data.appConfig).onFlowCompleted) === null || _g === void 0 ? void 0 : _g.call(_f, { data: data });
270
- return [2, { response: __assign({}, data), formData: params }];
293
+ (_f = (_e = settings.data.appConfig).onStepCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, settings.data.activeScreen.name, {});
294
+ (_h = (_g = settings.data.appConfig).onFlowCompleted) === null || _h === void 0 ? void 0 : _h.call(_g, { data: data });
295
+ return [2, { data: data }];
271
296
  }
272
- return [4, API.boardService.retrieveBoardInfoStatus(id)];
297
+ _d = ((_j = data === null || data === void 0 ? void 0 : data.notification) === null || _j === void 0 ? void 0 : _j.recipient) || {}, id = _d.id, type = _d.type;
298
+ return [4, Promise.all([
299
+ API.boardService.retrieveBoardInfoStatus(board_id),
300
+ thunkApi.dispatch(retrieveBoardDetails({ boardId: board_id, individualId: id, individualType: type })).unwrap()
301
+ ])];
273
302
  case 2:
274
- boardInfoData = _o.sent();
275
- return [4, API.boardService.retrieveBoardDetails(id)];
276
- case 3:
277
- boardData = _o.sent();
278
- (_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, {});
279
- (_l = (_k = settings.data.appConfig).onFlowCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, { data: data });
303
+ boardInfoStatusData = (_p.sent())[0];
304
+ (_l = (_k = settings.data.appConfig).onStepCompleted) === null || _l === void 0 ? void 0 : _l.call(_k, settings.data.activeScreen.name, {});
305
+ (_o = (_m = settings.data.appConfig).onFlowCompleted) === null || _o === void 0 ? void 0 : _o.call(_m, { data: data });
280
306
  thunkApi.dispatch(handleNextScreenStep());
281
- return [2, {
282
- response: __assign(__assign({}, data), { flows: (boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.info) || [], user: boardData === null || boardData === void 0 ? void 0 : boardData.user, entity: boardData === null || boardData === void 0 ? void 0 : boardData.entity, brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand, bank_account: boardData === null || boardData === void 0 ? void 0 : boardData.bank_account, vatID: (_m = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _m === void 0 ? void 0 : _m.vat_id, merchant: boardData === null || boardData === void 0 ? void 0 : boardData.merchant, individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals, business: boardData === null || boardData === void 0 ? void 0 : boardData.business }),
283
- formData: params
284
- }];
307
+ return [2, { data: data, flows: (boardInfoStatusData === null || boardInfoStatusData === void 0 ? void 0 : boardInfoStatusData.info) || [] }];
285
308
  }
286
309
  });
287
310
  }); });
@@ -339,13 +362,13 @@ export var taxSlice = createSlice({
339
362
  .addCase(verifyLeadToken.fulfilled, function (state, action) {
340
363
  state.error = null;
341
364
  state.customLoading = false;
342
- var _a = action.payload, data = _a.data, token = _a.token, boardResponse = _a.boardResponse, individualData = _a.individualData;
343
- var user = boardResponse.user, bank_account = boardResponse.bank_account, vatID = boardResponse.vatID, merchant = boardResponse.merchant, individuals = boardResponse.individuals, entity = boardResponse.entity;
344
- state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), boardResponse), state.data.verify.responseBody), { board_id: data.id, name: user === null || user === void 0 ? void 0 : user.names, bank_account: bank_account, vatID: vatID, merchant: merchant, individuals: individuals, individualData: individualData });
365
+ var _a = action.payload, data = _a.data, token = _a.token, entityData = _a.entityData;
366
+ var _b = entityData || {}, vat_id = _b.vat_id, is_vat_acknowledged = _b.is_vat_acknowledged;
367
+ state.data.verify.responseBody = __assign(__assign({}, data), { entity: entityData, board_id: data.id });
345
368
  state.data.verify.token = token;
346
- state.data.taxData.vatId = vatID;
347
- if (entity === null || entity === void 0 ? void 0 : entity.is_vat_acknowledged)
348
- state.data.taxData.confirmPolicy = entity === null || entity === void 0 ? void 0 : entity.is_vat_acknowledged;
369
+ state.data.taxData.vatId = vat_id;
370
+ if (is_vat_acknowledged)
371
+ state.data.taxData.confirmPolicy = is_vat_acknowledged;
349
372
  })
350
373
  .addCase(verifyLeadToken.pending, function (state) {
351
374
  state.error = null;
@@ -379,9 +402,14 @@ export var taxSlice = createSlice({
379
402
  .addCase(verifyTaxLeadOTP.fulfilled, function (state, action) {
380
403
  state.loading = false;
381
404
  state.error = null;
382
- var _a = action.payload, data = _a.data, formData = _a.formData;
405
+ var _a = action.payload, data = _a.data, entityData = _a.entityData, formData = _a.formData;
383
406
  state.data.otpData = formData;
384
407
  state.data.otpData.responseBody = data;
408
+ var _b = entityData || {}, vat_id = _b.vat_id, is_vat_acknowledged = _b.is_vat_acknowledged;
409
+ state.data.verify.responseBody = __assign(__assign(__assign({}, state.data.verify.responseBody), data), { board_id: data.id, entity: entityData });
410
+ state.data.taxData.vatId = vat_id;
411
+ if (is_vat_acknowledged)
412
+ state.data.taxData.confirmPolicy = is_vat_acknowledged;
385
413
  })
386
414
  .addCase(verifyTaxLeadOTP.rejected, function (state, action) {
387
415
  state.loading = false;
@@ -402,23 +430,17 @@ export var taxSlice = createSlice({
402
430
  state.loading = false;
403
431
  state.error = action.error.message;
404
432
  })
405
- .addCase(retrieveEntityInfo.pending, function (state) {
433
+ .addCase(retrieveBoardDetails.pending, function (state) {
406
434
  state.error = null;
407
435
  state.loading = true;
408
436
  })
409
- .addCase(retrieveEntityInfo.fulfilled, function (state, action) {
410
- var _a;
437
+ .addCase(retrieveBoardDetails.fulfilled, function (state, action) {
411
438
  state.error = null;
412
439
  state.loading = false;
413
- var data = (action.payload || {}).data;
414
- var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
415
- if (description) {
416
- state.error = description;
417
- return;
418
- }
440
+ var data = action.payload || {};
419
441
  state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), data);
420
442
  })
421
- .addCase(retrieveEntityInfo.rejected, function (state, action) {
443
+ .addCase(retrieveBoardDetails.rejected, function (state, action) {
422
444
  state.error = action.error.message;
423
445
  state.loading = false;
424
446
  })
@@ -429,29 +451,18 @@ export var taxSlice = createSlice({
429
451
  .addCase(retrieveBoardStatus.fulfilled, function (state, action) {
430
452
  state.error = null;
431
453
  state.loading = false;
432
- var flows = action.payload.flows;
433
- state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows });
454
+ var _a = action.payload, flows = _a.flows, data = _a.data;
455
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, notification: data === null || data === void 0 ? void 0 : data.notification });
434
456
  })
435
457
  .addCase(retrieveBoardStatus.rejected, function (state, action) {
436
458
  state.error = action.error.message;
437
459
  state.loading = false;
438
460
  })
439
461
  .addCase(updateLeadSuccess.fulfilled, function (state, action) {
440
- var _a;
441
462
  state.loading = false;
442
- state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { updateBoardSuccessLoading: false });
443
463
  state.error = null;
444
- var response = (action.payload || {}).response;
445
- var description = (((_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
446
- if (description) {
447
- state.error = description;
448
- return;
449
- }
450
- var flows = response.flows, steps = response.steps, user = response.user, bank_account = response.bank_account, vatID = response.vatID, merchant = response.merchant, individuals = response.individuals, entity = response.entity, brand = response.brand, individualData = response.individualData;
451
- var data_state = (((individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized) ? individuals : individualData) || {}).data_state;
452
- state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps, bank_account: bank_account, name: user === null || user === void 0 ? void 0 : user.names, vatID: vatID, merchant: merchant, individuals: individuals, entity: entity, brand: brand }), (individualData && { user: individualData })), (data_state && {
453
- individuals: __assign(__assign({}, individuals), { data_state: data_state })
454
- }));
464
+ var _a = action.payload || {}, flows = _a.flows, data = _a.data;
465
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, notification: data === null || data === void 0 ? void 0 : data.notification, updateBoardSuccessLoading: false });
455
466
  })
456
467
  .addCase(updateLeadSuccess.pending, function (state) {
457
468
  state.loading = true;
@@ -58,6 +58,7 @@ var OTP = function () {
58
58
  mode: 'onChange'
59
59
  });
60
60
  var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID;
61
+ var isEmailAuth = data.otpData.authFor === AuthForType.EMAIL;
61
62
  React.useEffect(function () {
62
63
  if (error)
63
64
  dispatch(clearError());
@@ -76,6 +77,8 @@ var OTP = function () {
76
77
  };
77
78
  var onBack = function () {
78
79
  var screen = isNidAuth ? 'AUTH_NID_STEP' : 'AUTH_MOBILE_STEP';
80
+ if (isEmailAuth)
81
+ screen = 'AUTH_EMAIL_STEP';
79
82
  dispatch(handlePrevScreenStep(screen));
80
83
  };
81
84
  var disabled = !methods.formState.isValid;
@@ -18,7 +18,7 @@ import { styled } from '@mui/material/styles';
18
18
  import OTPField from '../../../shared/OTP';
19
19
  import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
20
  import { AuthForType } from '../../../../@types';
21
- import { resendMobileAuthOTP, resendNIDAuthOTP, authSelector, clearError } from '../../../app/auth/authStore';
21
+ import { resendMobileAuthOTP, resendNIDAuthOTP, authSelector, clearError, resendEmailAuthOTP } from '../../../app/auth/authStore';
22
22
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
23
23
  var BoxStyled = styled(Box)(function (_a) {
24
24
  var theme = _a.theme;
@@ -34,8 +34,9 @@ var OTPInput = function (_a) {
34
34
  var dispatch = useAppDispatch();
35
35
  var otpControl = useController({ name: 'otp', control: control });
36
36
  var _c = useAppSelector(authSelector), data = _c.data, error = _c.error;
37
- var mobileData = data.mobileData, nidData = data.nidData;
37
+ var mobileData = data.mobileData, nidData = data.nidData, emailData = data.emailData;
38
38
  var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID;
39
+ var isEmailAuth = data.otpData.authFor === AuthForType.EMAIL;
39
40
  var handleOnOTPChange = function (otp) {
40
41
  if (error)
41
42
  dispatch(clearError());
@@ -51,11 +52,20 @@ var OTPInput = function (_a) {
51
52
  setValue('otp', '', { shouldValidate: true });
52
53
  dispatch(resendNIDAuthOTP(nidData));
53
54
  };
55
+ var handleOnResendEmailOTP = function () {
56
+ if (otpControl.field.value)
57
+ setValue('otp', '', { shouldValidate: true });
58
+ dispatch(resendEmailAuthOTP(emailData));
59
+ };
54
60
  var onResendClick = function () {
55
61
  if (isNidAuth) {
56
62
  handleOnResendAbsherOTP();
57
63
  return;
58
64
  }
65
+ if (isEmailAuth) {
66
+ handleOnResendEmailOTP();
67
+ return;
68
+ }
59
69
  handleOnResendOTP();
60
70
  };
61
71
  var otpValue = otpControl.field.value;
@@ -26,7 +26,7 @@ var PreparingData = function (_a) {
26
26
  var _b = useAppSelector(authSelector), error = _b.error, data = _b.data;
27
27
  var settingsData = useAppSelector(settingsSelector).data;
28
28
  var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
29
- var startWithEmail = data.passwordData.authFor === AuthForType.EMAIL;
29
+ var startWithEmail = data.otpData.authFor === AuthForType.EMAIL;
30
30
  var isNE = React.useMemo(function () { return isNetworkError(error); }, [error]);
31
31
  var onReTry = function () {
32
32
  var _a;
@@ -46,9 +46,9 @@ var FormStyled = styled(Form)(function () { return ({
46
46
  flexDirection: 'column'
47
47
  }); });
48
48
  var VerifyNumber = function (_a) {
49
- var _b, _c, _d;
49
+ var _b, _c;
50
50
  var dispatch = useAppDispatch();
51
- var _e = useAppSelector(bankSelector), data = _e.data, loading = _e.loading, error = _e.error;
51
+ var _d = useAppSelector(bankSelector), data = _d.data, loading = _d.loading, error = _d.error;
52
52
  var methods = useForm({
53
53
  resolver: yupResolver(OTPValidation),
54
54
  defaultValues: data.otpData,
@@ -56,8 +56,8 @@ var VerifyNumber = function (_a) {
56
56
  });
57
57
  var t = useTranslation().t;
58
58
  var isAr = useLanguage().isAr;
59
- var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
60
- var phone = (_d = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.contact) === null || _c === void 0 ? void 0 : _c.phone) === null || _d === void 0 ? void 0 : _d.number;
59
+ var _e = React.useState(false), resendLoading = _e[0], setResendLoading = _e[1];
60
+ var phone = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.verification_by) === null || _c === void 0 ? void 0 : _c.sent_to;
61
61
  React.useEffect(function () {
62
62
  if (error && methods.formState.isValid && phone)
63
63
  dispatch(clearError());
@@ -4,7 +4,7 @@ export declare const EntityNameValidationSchema: () => yup.ObjectSchema<import("
4
4
  licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
5
5
  entityType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
6
  licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
- unifiedNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
+ unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
8
8
  issuingDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
9
9
  expiryDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
10
  certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
@@ -14,7 +14,7 @@ export declare const EntityNameValidationSchema: () => yup.ObjectSchema<import("
14
14
  licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
15
15
  entityType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
16
16
  licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
17
- unifiedNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
17
+ unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
18
18
  issuingDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
19
19
  expiryDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
20
20
  certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
@@ -24,7 +24,7 @@ export declare const EntityNameValidationSchema: () => yup.ObjectSchema<import("
24
24
  licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
25
25
  entityType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
26
26
  licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
27
- unifiedNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
27
+ unifiedNumber: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
28
28
  issuingDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
29
29
  expiryDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
30
30
  certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
@@ -32,16 +32,7 @@ export var EntityNameValidationSchema = function () {
32
32
  }
33
33
  })
34
34
  .required(''),
35
- unifiedNumber: yup
36
- .string()
37
- .when('licenseType', function (licenseType) {
38
- var isCR = licenseType === BusinessType.CR;
39
- if (isCR) {
40
- return yup.string().required('unified_number_required');
41
- }
42
- return yup.string().optional();
43
- })
44
- .required(''),
35
+ unifiedNumber: yup.string().optional(),
45
36
  issuingDate: yup.string().required('choose_any_issuing_date'),
46
37
  expiryDate: yup.string().required('choose_any_expiry_date'),
47
38
  certificateId: yup.array().optional(),
@@ -46,9 +46,9 @@ var FormStyled = styled(Form)(function () { return ({
46
46
  flexDirection: 'column'
47
47
  }); });
48
48
  var VerifyNumber = function (_a) {
49
- var _b, _c, _d, _e;
49
+ var _b, _c;
50
50
  var dispatch = useAppDispatch();
51
- var _f = useAppSelector(taxSelector), data = _f.data, loading = _f.loading, error = _f.error;
51
+ var _d = useAppSelector(taxSelector), data = _d.data, loading = _d.loading, error = _d.error;
52
52
  var methods = useForm({
53
53
  resolver: yupResolver(OTPValidation),
54
54
  defaultValues: data.otpData,
@@ -57,8 +57,8 @@ var VerifyNumber = function (_a) {
57
57
  useSetFromDefaultValues(methods, data.otpData);
58
58
  var t = useTranslation().t;
59
59
  var isAr = useLanguage().isAr;
60
- var _g = React.useState(false), resendLoading = _g[0], setResendLoading = _g[1];
61
- var phone = (_e = (_d = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.user) === null || _c === void 0 ? void 0 : _c.contact) === null || _d === void 0 ? void 0 : _d.phone) === null || _e === void 0 ? void 0 : _e.number;
60
+ var _e = React.useState(false), resendLoading = _e[0], setResendLoading = _e[1];
61
+ var phone = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.verification_by) === null || _c === void 0 ? void 0 : _c.sent_to;
62
62
  React.useEffect(function () {
63
63
  if (error && methods.formState.isValid && phone)
64
64
  dispatch(clearError());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.8.2-test",
3
+ "version": "2.8.10-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",