@tap-payments/auth-jsconnect 2.1.93-test → 2.1.96-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/build/assets/locales/ar.json +2 -1
  2. package/build/assets/locales/en.json +2 -1
  3. package/build/features/app/brand/brandStore.js +2 -0
  4. package/build/features/app/connectExpress/connectExpressStore.js +12 -5
  5. package/build/features/app/tax/taxStore.js +3 -3
  6. package/build/features/bank/Bank.js +2 -2
  7. package/build/features/brand/Brand.js +2 -2
  8. package/build/features/brand/screens/BrandInfo/BrandInfo.js +1 -1
  9. package/build/features/brand/screens/BrandInfo/SalesChannels.js +2 -1
  10. package/build/features/business/Business.js +2 -2
  11. package/build/features/connect/Connect.js +2 -2
  12. package/build/features/connectExpress/ConnectExpress.js +2 -2
  13. package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.js +23 -3
  14. package/build/features/entity/Entity.js +2 -2
  15. package/build/features/individual/Individual.js +2 -2
  16. package/build/features/password/Password.js +2 -2
  17. package/build/features/shared/Button/Button.js +11 -0
  18. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.d.ts +2 -1
  19. package/build/features/shared/CreateAccountLoading/CreateAccountLoading.js +2 -2
  20. package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +1 -1
  21. package/build/features/signIn/SignIn.js +2 -2
  22. package/build/features/tax/Tax.js +2 -2
  23. package/build/utils/error.d.ts +1 -0
  24. package/build/utils/error.js +3 -0
  25. package/build/utils/html.d.ts +1 -1
  26. package/build/utils/html.js +4 -1
  27. package/build/utils/index.d.ts +1 -0
  28. package/build/utils/index.js +1 -0
  29. package/package.json +1 -1
@@ -387,5 +387,6 @@
387
387
  "share_count_hint": "0",
388
388
  "share_value_label": "قيمة السهم ({{currency}})",
389
389
  "share_value_hint": "0000",
390
- "brand": "الاسم التجاري"
390
+ "brand": "الاسم التجاري",
391
+ "try_again": "حاول مرة أخرى"
391
392
  }
@@ -417,5 +417,6 @@
417
417
  "share_count_hint": "0",
418
418
  "share_value_label": "Share Value ({{currency}})",
419
419
  "share_value_hint": "0000",
420
- "brand": "Brand"
420
+ "brand": "Brand",
421
+ "try_again": "Try again"
421
422
  }
@@ -498,6 +498,7 @@ export var brandSlice = createSlice({
498
498
  });
499
499
  state.data.brandData.segment = selectedSegment;
500
500
  state.data.brandData.teamSize = selectedTeamSize;
501
+ state.data.brandData.salesChannels = (brand === null || brand === void 0 ? void 0 : brand.channel_services) || [];
501
502
  state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id, channel_list: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.list) || [], salesChannels: brand === null || brand === void 0 ? void 0 : brand.channel_services, activities: entity === null || entity === void 0 ? void 0 : entity.activities, segmentsList: segmentsList, teamSizeList: teamSizeList });
502
503
  state.data.verify.token = token;
503
504
  })
@@ -539,6 +540,7 @@ export var brandSlice = createSlice({
539
540
  })) === null || _c === void 0 ? void 0 : _c[0];
540
541
  state.data.brandData.segment = selectedSegment;
541
542
  state.data.brandData.teamSize = selectedTeamSize;
543
+ state.data.brandData.salesChannels = (brand === null || brand === void 0 ? void 0 : brand.channel_services) || [];
542
544
  (_d = brand === null || brand === void 0 ? void 0 : brand.terms) === null || _d === void 0 ? void 0 : _d.forEach(function (element) {
543
545
  if ((element === null || element === void 0 ? void 0 : element.term) === 'general') {
544
546
  state.data.brandActivities.termAndConditionChecked = element.agree;
@@ -63,7 +63,7 @@ import { CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHE
63
63
  import { defaultCountry } from '../../../constants';
64
64
  import { getIndividualName, capitalizeTheFirstLetterOfEachWord, getEighteenYearsAgo, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA } from '../../../utils';
65
65
  export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retrieveLeadIdentityByIdAsync', function (leadId, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
66
- var _a, settings, connectExpress, countryCode, showBoard, data, phone, status, board_id, board_info_id, isRegistered, _b, boardInfo, boardData;
66
+ var _a, settings, connectExpress, countryCode, showBoard, data, phone, status, board_id, board_info_id, isRegistered, _b, boardInfo, boardData, error_1;
67
67
  var _c, _d;
68
68
  return __generator(this, function (_e) {
69
69
  switch (_e.label) {
@@ -92,16 +92,23 @@ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retr
92
92
  thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_ACCOUNT_ALREADY_CREATED_STEP'));
93
93
  return [2, { data: data, countryCode: countryCode }];
94
94
  }
95
- if (!(isRegistered && board_id && board_info_id)) return [3, 3];
95
+ if (!(isRegistered && board_id && board_info_id)) return [3, 5];
96
+ _e.label = 2;
97
+ case 2:
98
+ _e.trys.push([2, 4, , 5]);
96
99
  return [4, Promise.all([
97
100
  API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id }),
98
101
  API.boardService.retrieveBoardDetails(board_id)
99
102
  ])];
100
- case 2:
103
+ case 3:
101
104
  _b = _e.sent(), boardInfo = _b[0], boardData = _b[1];
102
105
  thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_SUCCESS_WITH_FLOW_BUTTONS_STEP'));
103
106
  return [2, { data: data, countryCode: countryCode, boardInfo: boardInfo, boardData: boardData }];
104
- case 3: return [2, { data: data, countryCode: countryCode }];
107
+ case 4:
108
+ error_1 = _e.sent();
109
+ thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_ACCOUNT_ALREADY_CREATED_STEP'));
110
+ return [2, { data: data, countryCode: countryCode }];
111
+ case 5: return [2, { data: data, countryCode: countryCode }];
105
112
  }
106
113
  });
107
114
  }); });
@@ -995,10 +1002,10 @@ export var connectSlice = createSlice({
995
1002
  })
996
1003
  .addCase(createAccountAsync.pending, function (state) {
997
1004
  state.loading = true;
998
- state.error = null;
999
1005
  })
1000
1006
  .addCase(createAccountAsync.fulfilled, function (state, action) {
1001
1007
  state.loading = false;
1008
+ state.error = null;
1002
1009
  state.data.responseData = __assign(__assign({}, state.data.responseData), action.payload);
1003
1010
  })
1004
1011
  .addCase(createAccountAsync.rejected, function (state, action) {
@@ -236,7 +236,7 @@ export var updateLeadSuccess = createAsyncThunk('taxUpdateLeadSuccess', function
236
236
  (_f = (_e = settings.data.appConfig).onFlowCompleted) === null || _f === void 0 ? void 0 : _f.call(_e, { data: data });
237
237
  thunkApi.dispatch(handleNextScreenStep());
238
238
  return [2, {
239
- response: __assign(__assign({}, data), { flows: (boardInfoData === null || boardInfoData === void 0 ? void 0 : boardInfoData.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, individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals, business: boardData === null || boardData === void 0 ? void 0 : boardData.business }),
239
+ 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: 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, individuals: boardData === null || boardData === void 0 ? void 0 : boardData.individuals, business: boardData === null || boardData === void 0 ? void 0 : boardData.business }),
240
240
  formData: params
241
241
  }];
242
242
  }
@@ -374,8 +374,8 @@ export var taxSlice = createSlice({
374
374
  state.error = description;
375
375
  return;
376
376
  }
377
- var flows = response.flows, steps = response.steps, user = response.user, bank_account = response.bank_account, vatID = response.vatID, merchant = response.merchant, individuals = response.individuals;
378
- state.data.verify.responseBody = __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 });
377
+ 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;
378
+ state.data.verify.responseBody = __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 });
379
379
  })
380
380
  .addCase(updateLeadSuccess.pending, function (state) {
381
381
  state.loading = true;
@@ -29,7 +29,7 @@ import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
30
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
31
31
  import Collapse from '../../components/Collapse';
32
- import { createElementAndInject } from '../../utils';
32
+ import { findOrCreateElementAndInject } from '../../utils';
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { BANK_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { bankFeatureScreens } from '../featuresScreens';
@@ -64,7 +64,7 @@ export function BankElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Bank, __assign({}, props)) })));
65
65
  }
66
66
  export function renderBankLib(config, elementId) {
67
- var element = createElementAndInject(elementId);
67
+ var element = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(element);
69
69
  root.render(_jsx(BankElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -29,7 +29,7 @@ import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
30
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
31
31
  import Collapse from '../../components/Collapse';
32
- import { createElementAndInject } from '../../utils';
32
+ import { findOrCreateElementAndInject } from '../../utils';
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { BRAND_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { brandFeatureScreens } from '../featuresScreens';
@@ -64,7 +64,7 @@ export function BrandElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Brand, __assign({}, props)) })));
65
65
  }
66
66
  export function renderBrandLib(config, elementId) {
67
- var element = createElementAndInject(elementId);
67
+ var element = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(element);
69
69
  root.render(_jsx(BrandElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -48,7 +48,7 @@ var BrandInfo = function (_a) {
48
48
  },
49
49
  mode: 'onChange'
50
50
  });
51
- useSetFromDefaultValues(methods, data.brandData);
51
+ useSetFromDefaultValues(methods, data.brandData, true);
52
52
  var onSubmit = function (data) {
53
53
  dispatch(updateBrand(data));
54
54
  };
@@ -25,7 +25,8 @@ var SalesChannels = function (_a) {
25
25
  }
26
26
  }, [selectedBrandItem]);
27
27
  React.useEffect(function () {
28
- if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0) {
28
+ var _a;
29
+ if ((defaultSalesChannels === null || defaultSalesChannels === void 0 ? void 0 : defaultSalesChannels.length) > 0 && ((_a = field === null || field === void 0 ? void 0 : field.value) === null || _a === void 0 ? void 0 : _a.length) === 0) {
29
30
  var sales = mapSalesChannel(defaultSalesChannels);
30
31
  field.onChange(sales);
31
32
  }
@@ -20,7 +20,7 @@ import AnimationFlow from '../../components/AnimationFlow';
20
20
  import { store } from '../../app/store';
21
21
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
22
22
  import Collapse from '../../components/Collapse';
23
- import { getParameterByName, createElementAndInject } from '../../utils';
23
+ import { getParameterByName, findOrCreateElementAndInject } from '../../utils';
24
24
  import { BUSINESS_SCREENS_NAVIGATION } from '../../constants';
25
25
  import { businessFeatureScreens } from '../featuresScreens';
26
26
  import CustomFooter from '../shared/Footer';
@@ -57,7 +57,7 @@ export function BusinessElement(props) {
57
57
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Business, __assign({}, props)) })));
58
58
  }
59
59
  export function renderBusinessLib(config, elementId) {
60
- var element = createElementAndInject(elementId);
60
+ var element = findOrCreateElementAndInject(elementId);
61
61
  var root = createRoot(element);
62
62
  root.render(_jsx(BusinessElement, __assign({}, config)));
63
63
  var unmount = function () { return root.unmount(); };
@@ -20,7 +20,7 @@ import { store } from '../../app/store';
20
20
  import { connectSelector, setDefaultCountryCode } from '../app/connect/connectStore';
21
21
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
22
22
  import Collapse from '../../components/Collapse';
23
- import { isKW, createElementAndInject } from '../../utils';
23
+ import { isKW, findOrCreateElementAndInject } from '../../utils';
24
24
  import { CONNECT_SCREENS_NAVIGATION } from '../../constants';
25
25
  import { connectFeatureScreens } from '../featuresScreens';
26
26
  import CustomFooter from '../shared/Footer';
@@ -59,7 +59,7 @@ export function ConnectElement(props) {
59
59
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Connect, __assign({}, props)) })));
60
60
  }
61
61
  export function renderConnectLib(config, elementId) {
62
- var element = createElementAndInject(elementId);
62
+ var element = findOrCreateElementAndInject(elementId);
63
63
  var root = createRoot(element);
64
64
  root.render(_jsx(ConnectElement, __assign({}, config)));
65
65
  var unmount = function () { return root.unmount(); };
@@ -31,7 +31,7 @@ import { store } from '../../app/store';
31
31
  import { connectExpressSelector, setIsLeadIdPassed, setPostUrl, setLeadId, retrieveLeadIdentityByIdAsync, setShowBoard } from '../app/connectExpress/connectExpressStore';
32
32
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
33
33
  import Collapse from '../../components/Collapse';
34
- import { isKW, createElementAndInject } from '../../utils';
34
+ import { isKW, findOrCreateElementAndInject } from '../../utils';
35
35
  import { CONNECT_EXPRESS_SCREENS_NAVIGATION } from '../../constants';
36
36
  import { connectExpressFeatureScreens } from '../featuresScreens';
37
37
  import CustomFooter from '../shared/Footer';
@@ -76,7 +76,7 @@ export function ConnectExpressElement(props) {
76
76
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(ConnectExpress, __assign({}, props)) })));
77
77
  }
78
78
  export function renderConnectExpressLib(config, elementId) {
79
- var el = createElementAndInject(elementId);
79
+ var el = findOrCreateElementAndInject(elementId);
80
80
  var root = createRoot(el);
81
81
  root.render(_jsx(ConnectExpressElement, __assign({}, config)));
82
82
  var unmount = function () { return root.unmount(); };
@@ -1,14 +1,34 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import * as React from 'react';
3
- import { useAppDispatch, useAppSelector } from '../../../../hooks';
14
+ import { useTranslation } from 'react-i18next';
15
+ import { isNetworkError } from '../../../../utils';
16
+ import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
4
17
  import { connectExpressSelector, createAccountAsync } from '../../../app/connectExpress/connectExpressStore';
5
18
  import CreateAccountLoading from '../../../shared/CreateAccountLoading';
19
+ import Button from '../../../shared/Button';
6
20
  var CreateAccountLoader = function (_a) {
7
21
  var dispatch = useAppDispatch();
8
- var error = useAppSelector(connectExpressSelector).error;
22
+ var isAr = useLanguage().isAr;
23
+ var t = useTranslation().t;
24
+ var _b = useAppSelector(connectExpressSelector), error = _b.error, loading = _b.loading;
9
25
  React.useEffect(function () {
10
26
  dispatch(createAccountAsync());
11
27
  }, []);
12
- return _jsx(CreateAccountLoading, { error: error });
28
+ var onReTry = function () {
29
+ dispatch(createAccountAsync());
30
+ };
31
+ var isNE = React.useMemo(function () { return isNetworkError(error); }, [error]);
32
+ return (_jsx(CreateAccountLoading, __assign({ error: error }, { children: isNE && (_jsx(Button, __assign({ onClick: onReTry, disableBack: true, isAr: isAr, loading: loading }, { children: t('try_again') }))) })));
13
33
  };
14
34
  export default React.memo(CreateAccountLoader);
@@ -29,7 +29,7 @@ import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
30
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
31
31
  import Collapse from '../../components/Collapse';
32
- import { createElementAndInject } from '../../utils';
32
+ import { findOrCreateElementAndInject } from '../../utils';
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { ENTITY_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { entityFeatureScreens } from '../featuresScreens';
@@ -64,7 +64,7 @@ export function EntityElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Entity, __assign({}, props)) })));
65
65
  }
66
66
  export function renderEntityLib(config, elementId) {
67
- var element = createElementAndInject(elementId);
67
+ var element = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(element);
69
69
  root.render(_jsx(EntityElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -29,7 +29,7 @@ import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
30
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
31
31
  import Collapse from '../../components/Collapse';
32
- import { createElementAndInject } from '../../utils';
32
+ import { findOrCreateElementAndInject } from '../../utils';
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { INDIVIDUAL_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { individualFeatureScreens } from '../featuresScreens';
@@ -64,7 +64,7 @@ export function IndividualElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Individual, __assign({}, props)) })));
65
65
  }
66
66
  export function renderIndividualLib(config, elementId) {
67
- var element = createElementAndInject(elementId);
67
+ var element = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(element);
69
69
  root.render(_jsx(IndividualElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -19,7 +19,7 @@ import { store } from '../../app/store';
19
19
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
20
  import Collapse from '../../components/Collapse';
21
21
  import { FeatureContainer } from '../shared/Containers';
22
- import { getParameterByName, createElementAndInject } from '../../utils';
22
+ import { getParameterByName, findOrCreateElementAndInject } from '../../utils';
23
23
  import { PASSWORD_OPERATION_TYPE, PASSWORD_SCREENS_NAVIGATION } from '../../constants';
24
24
  import { passwordFeatureScreens } from '../featuresScreens';
25
25
  import { passwordSelector, verifyLeadToken, verifyOperationToken } from '../app/password/passwordStore';
@@ -64,7 +64,7 @@ export function PasswordElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Password, __assign({}, props)) })));
65
65
  }
66
66
  export function renderPasswordLib(config, elementId) {
67
- var el = createElementAndInject(elementId);
67
+ var el = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(el);
69
69
  root.render(_jsx(PasswordElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -93,8 +93,19 @@ export default function CustomButton(_a) {
93
93
  if (error)
94
94
  setBtnLoading(false);
95
95
  }, [loading, error]);
96
+ React.useEffect(function () {
97
+ if (!loading)
98
+ setTimeout(function () {
99
+ setBtnLoading(false);
100
+ }, 1500);
101
+ }, [loading]);
96
102
  React.useEffect(function () {
97
103
  setBtnLoading(false);
104
+ return function () {
105
+ setTimeout(function () {
106
+ setBtnLoading(false);
107
+ }, 500);
108
+ };
98
109
  }, []);
99
110
  return (_jsxs(Fragment, { children: [_jsx(Collapse, __assign({ in: !!error && !hideError }, { children: _jsx(Warning, __assign({ sx: { mb: 1 }, warningType: 'error' }, { children: error })) })), _jsxs(ButtonBoxStyled, { children: [isBackEnabled && (_jsx(BackButtonStyled, __assign({ onClick: function () { return onBackClicked === null || onBackClicked === void 0 ? void 0 : onBackClicked(); }, isAr: isAr, type: 'reset', startIcon: _jsx(BackIconStyled, { isAr: isAr, src: ICONS_NAMES.WHITE_ARROW }) }, props))), _jsx(ButtonStyled, __assign({ disabled: disabled, isLoading: btnLoading, type: !btnLoading ? 'submit' : 'button', isBack: isBackEnabled, endIcon: btnLoading === false ? !disableNextIcon && _jsx(IconStyled, { isAr: isAr, src: ICONS_NAMES.WHITE_ARROW }) : undefined }, props, { children: !btnLoading ? (_jsxs(Text, __assign({ sx: { marginInlineEnd: isBackEnabled ? '-24px' : '-15px' } }, { children: [" ", children] }))) : (_jsx(Loader, { innerColor: 'white', outerColor: 'white', size: 15, toggleAnimation: !!btnLoading })) }))] })] }));
100
111
  }
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface CreateAccountLoadingProps {
3
3
  error?: string | null;
4
+ children?: React.ReactNode;
4
5
  }
5
- declare const _default: React.MemoExoticComponent<({ error }: CreateAccountLoadingProps) => JSX.Element>;
6
+ declare const _default: React.MemoExoticComponent<({ error, children }: CreateAccountLoadingProps) => JSX.Element>;
6
7
  export default _default;
@@ -51,8 +51,8 @@ var SubTitleStyled = styled(Text)(function (_a) {
51
51
  return (__assign(__assign({}, theme.typography.body2), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightMedium, lineHeight: '16.8px', textAlign: 'center' }));
52
52
  });
53
53
  var CreateAccountLoading = function (_a) {
54
- var error = _a.error;
54
+ var error = _a.error, children = _a.children;
55
55
  var t = useTranslation().t;
56
- return (_jsx(ScreenContainer, __assign({ sx: { mb: 2.5 } }, { children: _jsxs(TitleContainerStyled, { children: [_jsx(Collapse, __assign({ in: !!error }, { children: _jsx(GenericError, { error: error || '', errorTitle: 'oops' }) })), _jsxs(Collapse, __assign({ in: !error }, { children: [_jsx(Container, { children: _jsx(LottieFile, { file: LottieAnimationFiles.account_creation, loop: true, height: '375px' }) }), _jsxs(_Fragment, { children: [_jsx(TitleStyled, { children: t('creating_account_title') }), _jsx(SubTitleStyled, { children: t('creating_account_description') })] })] }))] }) })));
56
+ return (_jsxs(ScreenContainer, __assign({ sx: __assign({}, (!children && { mb: 2.5 })) }, { children: [_jsxs(TitleContainerStyled, __assign({ sx: __assign({}, (children && { mb: 0 })) }, { children: [_jsx(Collapse, __assign({ in: !!error }, { children: _jsx(GenericError, { error: error || '', errorTitle: 'oops' }) })), _jsxs(Collapse, __assign({ in: !error }, { children: [_jsx(Container, { children: _jsx(LottieFile, { file: LottieAnimationFiles.account_creation, loop: true, height: '375px' }) }), _jsxs(_Fragment, { children: [_jsx(TitleStyled, { children: t('creating_account_title') }), _jsx(SubTitleStyled, { children: t('creating_account_description') })] })] }))] })), children] })));
57
57
  };
58
58
  export default React.memo(CreateAccountLoading);
@@ -59,7 +59,7 @@ var SuccessFlowButtons = function (_a) {
59
59
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
60
60
  var taxID = vat_id || '';
61
61
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || t('brand');
62
- var entityLegalName = shortenString(isAr ? legal_name === null || legal_name === void 0 ? void 0 : legal_name.ar : legal_name === null || legal_name === void 0 ? void 0 : legal_name.en, 20) || '';
62
+ var entityLegalName = shortenString(isAr ? legal_name === null || legal_name === void 0 ? void 0 : legal_name.ar : legal_name === null || legal_name === void 0 ? void 0 : legal_name.en, 20) || t('entity');
63
63
  var isAcceptance = merchant === null || merchant === void 0 ? void 0 : merchant.is_acceptance_allowed;
64
64
  var isPayout = merchant === null || merchant === void 0 ? void 0 : merchant.is_payout_allowed;
65
65
  var maskedId = (identification === null || identification === void 0 ? void 0 : identification.id) ? " ".concat(t('masking_symbols')).concat((_d = identification === null || identification === void 0 ? void 0 : identification.id) === null || _d === void 0 ? void 0 : _d.slice(-2)) : '';
@@ -18,7 +18,7 @@ import AnimationFlow from '../../components/AnimationFlow';
18
18
  import { store } from '../../app/store';
19
19
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
20
  import Collapse from '../../components/Collapse';
21
- import { createElementAndInject } from '../../utils';
21
+ import { findOrCreateElementAndInject } from '../../utils';
22
22
  import { FeatureContainer } from '../shared/Containers';
23
23
  import { SigIn_SCREENS_NAVIGATION } from '../../constants';
24
24
  import { signInFeatureScreens } from '../featuresScreens';
@@ -43,7 +43,7 @@ export function SignInElement(props) {
43
43
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(SignIn, __assign({}, props)) })));
44
44
  }
45
45
  export function renderSignInLib(config, elementId) {
46
- var element = createElementAndInject(elementId);
46
+ var element = findOrCreateElementAndInject(elementId);
47
47
  var root = createRoot(element);
48
48
  root.render(_jsx(SignInElement, __assign({}, config)));
49
49
  var unmount = function () { return root.unmount(); };
@@ -29,7 +29,7 @@ import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
30
30
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
31
31
  import Collapse from '../../components/Collapse';
32
- import { createElementAndInject } from '../../utils';
32
+ import { findOrCreateElementAndInject } from '../../utils';
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { TAX_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { taxFeatureScreens } from '../featuresScreens';
@@ -64,7 +64,7 @@ export function TaxElement(props) {
64
64
  return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(Tax, __assign({}, props)) })));
65
65
  }
66
66
  export function renderTaxLib(config, elementId) {
67
- var element = createElementAndInject(elementId);
67
+ var element = findOrCreateElementAndInject(elementId);
68
68
  var root = createRoot(element);
69
69
  root.render(_jsx(TaxElement, __assign({}, config)));
70
70
  var unmount = function () { return root.unmount(); };
@@ -0,0 +1 @@
1
+ export declare const isNetworkError: (error: string | null) => boolean;
@@ -0,0 +1,3 @@
1
+ export var isNetworkError = function (error) {
2
+ return ['network error', 'network request failed'].includes((error || '').trim().toLowerCase());
3
+ };
@@ -1,4 +1,4 @@
1
- export declare const createElementAndInject: (id: string) => HTMLDivElement;
1
+ export declare const findOrCreateElementAndInject: (id: string) => HTMLElement;
2
2
  export declare const scrollUp: (elementId: string, top?: number) => void;
3
3
  export declare const scrollDown: (elementId: string) => void;
4
4
  export declare const removeElement: (elementId: string) => void;
@@ -1,4 +1,7 @@
1
- export var createElementAndInject = function (id) {
1
+ export var findOrCreateElementAndInject = function (id) {
2
+ var elementExist = document.getElementById(id);
3
+ if (elementExist)
4
+ return elementExist;
2
5
  var element = document.createElement('div');
3
6
  element.setAttribute('id', id || 'tap-connect-sdk-element');
4
7
  document.body.prepend(element);
@@ -9,3 +9,4 @@ export * from './device';
9
9
  export * from './rsa';
10
10
  export * from './common';
11
11
  export * from './date';
12
+ export * from './error';
@@ -9,3 +9,4 @@ export * from './device';
9
9
  export * from './rsa';
10
10
  export * from './common';
11
11
  export * from './date';
12
+ export * from './error';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.1.93-test",
3
+ "version": "2.1.96-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",