@tap-payments/auth-jsconnect 2.3.70-test → 2.3.72-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.
@@ -383,20 +383,20 @@ export var BANK_SCREENS_NAVIGATION = [
383
383
  export var TAX_SCREENS_NAVIGATION = [
384
384
  {
385
385
  name: 'TAX_VERIFY_STEP',
386
- next: ['TAX_TAX_DETAILS_STEP', 'TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'],
387
- prev: '',
386
+ next: 'TAX_TAX_DETAILS_STEP',
387
+ prev: 'TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
388
388
  order: 1
389
389
  },
390
390
  {
391
391
  name: 'TAX_LOADING_DATA_STEP',
392
- next: ['TAX_TAX_DETAILS_STEP', 'TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'],
393
- prev: '',
392
+ next: 'TAX_TAX_DETAILS_STEP',
393
+ prev: 'TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
394
394
  order: 1
395
395
  },
396
396
  {
397
397
  name: 'TAX_TAX_DETAILS_STEP',
398
398
  next: 'TAX_DETAILS_SUCCESS_STEP',
399
- prev: 'TAX_VERIFY_STEP',
399
+ prev: 'TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
400
400
  order: 2
401
401
  },
402
402
  {
@@ -298,13 +298,14 @@ export var verifyLeadOTP = createAsyncThunk('verifyLeadOTP', function (params, t
298
298
  });
299
299
  }); });
300
300
  export var verifyPACI = createAsyncThunk('businessVerifyPACI', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
301
- var _a, settings, business, responseBody, expiry, interval, maxCalls, count, data, isSuccess;
302
- var _b, _c, _d, _e;
303
- return __generator(this, function (_f) {
304
- switch (_f.label) {
301
+ var _a, settings, business, responseBody, _b, business_id, entity, expiry, interval, maxCalls, count, data, isSuccess;
302
+ var _c, _d, _e, _f;
303
+ return __generator(this, function (_g) {
304
+ switch (_g.label) {
305
305
  case 0:
306
306
  _a = thunkApi.getState(), settings = _a.settings, business = _a.business;
307
307
  responseBody = business.data.civilIdData.responseBody;
308
+ _b = business.data.verify.responseBody || {}, business_id = _b.business_id, entity = _b.entity;
308
309
  expiry = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.expiry) || 120;
309
310
  interval = 5;
310
311
  maxCalls = Math.floor(expiry / interval);
@@ -312,29 +313,32 @@ export var verifyPACI = createAsyncThunk('businessVerifyPACI', function (params,
312
313
  return [2, { response: null }];
313
314
  }
314
315
  count = 1;
315
- _f.label = 1;
316
+ _g.label = 1;
316
317
  case 1:
317
- if (!(count <= maxCalls)) return [3, 7];
318
+ if (!(count <= maxCalls)) return [3, 8];
318
319
  return [4, API.authService.getTokenVerify(responseBody === null || responseBody === void 0 ? void 0 : responseBody.verify_token)];
319
320
  case 2:
320
- data = _f.sent();
321
- isSuccess = ((_b = data.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'success';
322
- if (!isSuccess) return [3, 4];
323
- (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, {});
324
- (_e = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _e === void 0 ? void 0 : _e.call(params);
325
- return [4, sleep(3000)];
321
+ data = _g.sent();
322
+ isSuccess = ((_c = data.status) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'success';
323
+ if (!isSuccess) return [3, 5];
324
+ return [4, thunkApi.dispatch(retrieveAllEntityList({ businessId: business_id, entityId: entity === null || entity === void 0 ? void 0 : entity.id }))];
326
325
  case 3:
327
- _f.sent();
326
+ _g.sent();
327
+ (_e = (_d = settings.data.appConfig).onStepCompleted) === null || _e === void 0 ? void 0 : _e.call(_d, settings.data.activeScreen.name, {});
328
+ (_f = params === null || params === void 0 ? void 0 : params.onSuccess) === null || _f === void 0 ? void 0 : _f.call(params);
329
+ return [4, sleep(3000)];
330
+ case 4:
331
+ _g.sent();
328
332
  thunkApi.dispatch(handleNextScreenStep());
329
333
  return [2, { response: data }];
330
- case 4: return [4, sleep(interval * 1000)];
331
- case 5:
332
- _f.sent();
333
- _f.label = 6;
334
+ case 5: return [4, sleep(interval * 1000)];
334
335
  case 6:
336
+ _g.sent();
337
+ _g.label = 7;
338
+ case 7:
335
339
  count++;
336
340
  return [3, 1];
337
- case 7: throw new Error('paci_verification_failed');
341
+ case 8: throw new Error('paci_verification_failed');
338
342
  }
339
343
  });
340
344
  }); });
@@ -976,7 +980,7 @@ export var businessSlice = createSlice({
976
980
  var isKWCountry = isKW(businessCountryCode);
977
981
  var list = (data === null || data === void 0 ? void 0 : data.entities_info) || [];
978
982
  if (isKWCountry) {
979
- list = list.filter(function (l) { return l.license.type !== LicenseType.FL; });
983
+ list = list.filter(function (l) { var _a; return ((_a = l.license) === null || _a === void 0 ? void 0 : _a.type) !== LicenseType.FL; });
980
984
  }
981
985
  var entityLicenseList = [];
982
986
  if (list.length > 0) {
@@ -12,6 +12,9 @@ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
12
12
  export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<{
13
13
  data: any;
14
14
  }, void, {}>;
15
+ export declare const retrieveBoardStatus: import("@reduxjs/toolkit").AsyncThunk<{
16
+ flows: any;
17
+ }, void, {}>;
15
18
  export declare const retrieveEntityInfo: import("@reduxjs/toolkit").AsyncThunk<{
16
19
  data: any;
17
20
  }, string, {}>;
@@ -49,7 +49,7 @@ var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
50
  import API from '../../../api';
51
51
  import { DocumentPurpose, FlowsTypes } from '../../../@types';
52
- import { handleNextScreenStep, handleCurrentActiveScreen, handleSetCountryByIso2 } from '../../../app/settings';
52
+ import { handleNextScreenStep, handleCurrentActiveScreen, handleSetCountryByIso2, handlePrevScreenStep } from '../../../app/settings';
53
53
  import { TAX_STEP_NAMES } from '../../../constants';
54
54
  import { getRecentDocumentBasedOnPurpose, hasNoneEditableValue, sleep } from '../../../utils';
55
55
  export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (_a, thunkApi) {
@@ -68,12 +68,12 @@ export var verifyLeadToken = createAsyncThunk('taxVerifyLeadToken', function (_a
68
68
  case 1:
69
69
  data = (_e.sent()).data;
70
70
  boardData = undefined;
71
- if (((_b = data.errors) === null || _b === void 0 ? void 0 : _b.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
71
+ if (((_b = data === null || data === void 0 ? void 0 : data.errors) === null || _b === void 0 ? void 0 : _b.length) || (data === null || data === void 0 ? void 0 : data.mw_error))
72
72
  throw new Error(data.errors[0].description || (data === null || data === void 0 ? void 0 : data.mw_error));
73
73
  if (isInternally)
74
74
  data.step_name = TAX_STEP_NAMES.TAX_INFO;
75
- if (!data.id) return [3, 3];
76
- return [4, API.boardService.retrieveBoardDetails(data === null || data === void 0 ? void 0 : data.id)];
75
+ if (!(data === null || data === void 0 ? void 0 : data.id)) return [3, 3];
76
+ return [4, API.boardService.retrieveBoardDetails(data.id)];
77
77
  case 2:
78
78
  boardData = _e.sent();
79
79
  _e.label = 3;
@@ -113,6 +113,21 @@ export var resendOTP = createAsyncThunk('resendOTPTax', function (params, thunkA
113
113
  }
114
114
  });
115
115
  }); });
116
+ export var retrieveBoardStatus = createAsyncThunk('tax/retrieveBoardStatus', function (parmas, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
117
+ var tax, board_id, data;
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0:
121
+ tax = thunkApi.getState().tax;
122
+ board_id = (tax.data.verify.responseBody || {}).board_id;
123
+ return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
124
+ case 1:
125
+ data = _a.sent();
126
+ thunkApi.dispatch(handlePrevScreenStep());
127
+ return [2, { flows: (data === null || data === void 0 ? void 0 : data.info) || [] }];
128
+ }
129
+ });
130
+ }); });
116
131
  export var retrieveEntityInfo = createAsyncThunk('retrieveTaxEntityInfo', function (entityID) { return __awaiter(void 0, void 0, void 0, function () {
117
132
  var data;
118
133
  return __generator(this, function (_a) {
@@ -361,6 +376,20 @@ export var taxSlice = createSlice({
361
376
  .addCase(retrieveEntityInfo.rejected, function (state, action) {
362
377
  state.error = action.error.message;
363
378
  state.loading = false;
379
+ })
380
+ .addCase(retrieveBoardStatus.pending, function (state) {
381
+ state.error = null;
382
+ state.loading = true;
383
+ })
384
+ .addCase(retrieveBoardStatus.fulfilled, function (state, action) {
385
+ state.error = null;
386
+ state.loading = false;
387
+ var flows = action.payload.flows;
388
+ state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows });
389
+ })
390
+ .addCase(retrieveBoardStatus.rejected, function (state, action) {
391
+ state.error = action.error.message;
392
+ state.loading = false;
364
393
  })
365
394
  .addCase(updateLeadSuccess.fulfilled, function (state, action) {
366
395
  var _a;
@@ -17,12 +17,12 @@ import { yupResolver } from '@hookform/resolvers/yup';
17
17
  import { styled } from '@mui/material/styles';
18
18
  import Form from '../../../../components/Form';
19
19
  import { useAppDispatch, useLanguage, useAppSelector, useSetFromDefaultValues, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly } from '../../../../hooks';
20
- import { handleCurrentActiveScreen, settingsSelector } from '../../../../app/settings';
20
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
21
21
  import { DocumentPurpose } from '../../../../@types';
22
22
  import { getFileDetailsFromDocument, isSA } from '../../../../utils';
23
23
  import { ScreenContainer } from '../../../shared/Containers';
24
24
  import Button from '../../../shared/Button';
25
- import { taxSelector, updateTaxInfo } from '../../../app/tax/taxStore';
25
+ import { retrieveBoardStatus, taxSelector, updateTaxInfo } from '../../../app/tax/taxStore';
26
26
  import { Validation } from './validation';
27
27
  import VATId from './VATId';
28
28
  import ConfirmPolicy from './ConfirmPolicy';
@@ -36,9 +36,9 @@ var FormStyled = styled(Form)(function () { return ({
36
36
  var TaxDetails = function () {
37
37
  var dispatch = useAppDispatch();
38
38
  var _a = useAppSelector(taxSelector), data = _a.data, loading = _a.loading, error = _a.error, uploading = _a.uploading;
39
- var entity = (data.verify.responseBody || {}).entity;
39
+ var _b = data.verify.responseBody || {}, entity = _b.entity, flows = _b.flows;
40
40
  var settingsData = useAppSelector(settingsSelector).data;
41
- var _b = data.taxData, vatId = _b.vatId, confirmPolicy = _b.confirmPolicy, documentId = _b.documentId;
41
+ var _c = data.taxData, vatId = _c.vatId, confirmPolicy = _c.confirmPolicy, documentId = _c.documentId;
42
42
  var methods = useForm({
43
43
  resolver: yupResolver(Validation()),
44
44
  defaultValues: {
@@ -60,8 +60,12 @@ var TaxDetails = function () {
60
60
  dispatch(updateTaxInfo(data));
61
61
  };
62
62
  var onBack = function () {
63
- dispatch(handleCurrentActiveScreen('TAX_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
63
+ if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0) {
64
+ dispatch(handlePrevScreenStep());
65
+ return;
66
+ }
67
+ dispatch(retrieveBoardStatus());
64
68
  };
65
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(VATId, { readOnly: readOnly['vatId'] || noneEditable['tax_number'] }), _jsx(TaxDocument, { show: isSACountry, defaultFiles: defaultTaxFiles, readOnly: readOnly['documentId'] || noneEditable['documents'] }), _jsx(ConfirmPolicy, { readOnly: readOnly['documentId'] || noneEditable['is_vat_acknowledged'] }), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: !methods.formState.isValid || uploading, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
69
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(VATId, { readOnly: readOnly['vatId'] || noneEditable['tax_number'] }), _jsx(TaxDocument, { show: isSACountry, defaultFiles: defaultTaxFiles, readOnly: readOnly['documentId'] || noneEditable['documents'] }), _jsx(ConfirmPolicy, { readOnly: readOnly['documentId'] || noneEditable['is_vat_acknowledged'] }), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: !methods.formState.isValid || uploading, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
66
70
  };
67
71
  export default TaxDetails;
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
13
  import * as React from 'react';
25
14
  import { useAppDispatch, useSetFromDefaultValues } from '../../../../hooks';
@@ -28,7 +17,6 @@ import { useForm, FormProvider } from 'react-hook-form';
28
17
  import { yupResolver } from '@hookform/resolvers/yup';
29
18
  import Box from '@mui/material/Box/Box';
30
19
  import { styled } from '@mui/material/styles';
31
- import { handlePrevScreenStep } from '../../../../app/settings';
32
20
  import { useLanguage, useAppSelector } from '../../../../hooks';
33
21
  import { maskPhone } from '../../../../utils';
34
22
  import Form from '../../../../components/Form';
@@ -58,20 +46,19 @@ var FormStyled = styled(Form)(function () { return ({
58
46
  flexDirection: 'column'
59
47
  }); });
60
48
  var VerifyNumber = function (_a) {
61
- var _b, _c, _d;
49
+ var _b, _c, _d, _e;
62
50
  var dispatch = useAppDispatch();
63
- var _e = useAppSelector(taxSelector), data = _e.data, loading = _e.loading, error = _e.error;
64
- var _f = data.otpData, responseBody = _f.responseBody, defaultValues = __rest(_f, ["responseBody"]);
51
+ var _f = useAppSelector(taxSelector), data = _f.data, loading = _f.loading, error = _f.error;
65
52
  var methods = useForm({
66
53
  resolver: yupResolver(OTPValidation),
67
- defaultValues: defaultValues,
54
+ defaultValues: data.otpData,
68
55
  mode: 'onChange'
69
56
  });
70
- useSetFromDefaultValues(methods, defaultValues);
57
+ useSetFromDefaultValues(methods, data.otpData);
71
58
  var t = useTranslation().t;
72
59
  var isAr = useLanguage().isAr;
73
60
  var _g = React.useState(false), resendLoading = _g[0], setResendLoading = _g[1];
74
- var phone = (_d = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.user.contact) === null || _c === void 0 ? void 0 : _c.phone) === null || _d === void 0 ? void 0 : _d.number;
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;
75
62
  React.useEffect(function () {
76
63
  if (error && methods.formState.isValid && phone)
77
64
  dispatch(clearError());
@@ -82,10 +69,7 @@ var VerifyNumber = function (_a) {
82
69
  var onSubmit = function (formData) {
83
70
  dispatch(verifyTaxLeadOTP(formData));
84
71
  };
85
- var onBack = function () {
86
- dispatch(handlePrevScreenStep());
87
- };
88
72
  var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
89
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), !loading && phone && _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, { loading: resendLoading, setLoading: setResendLoading }), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
73
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), !loading && phone && _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, { loading: resendLoading, setLoading: setResendLoading }), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
90
74
  };
91
75
  export default React.memo(VerifyNumber);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.70-test",
3
+ "version": "2.3.72-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",