@tap-payments/auth-jsconnect 2.6.26-test → 2.6.28-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.
@@ -22,6 +22,14 @@ var SuccessWithFlowButtons = function () {
22
22
  var settingsData = useAppSelector(settingsSelector).data;
23
23
  var isScopeAuthentication = settingsData.appConfig.scope === SCOPE_AUTH;
24
24
  var _b = data.verify.responseBody || {}, flows = _b.flows, entity = _b.entity, brand = _b.brand, bank = _b.bank_account, merchant = _b.merchant, user = _b.user, business = _b.business, board_id = _b.board_id, board_info_id = _b.board_info_id, name = _b.name, individuals = _b.individuals;
25
- return (_jsx(SuccessFlowButtons, { flowName: data.flowName, loading: loading, bank: bank, brand: brand, entity: entity, merchant: merchant, user: __assign({ names: { en: name } }, user), business: business, boardId: board_id, boardInfoId: board_info_id, individuals: individuals, flows: flows || [] }));
25
+ var onClose = function () {
26
+ var url = settingsData.appConfig.redirectUrl;
27
+ if (!url)
28
+ return;
29
+ var newUrl = new URL(url);
30
+ newUrl.searchParams.append('action', 'close');
31
+ window.open("".concat(newUrl), '_self', '_blank');
32
+ };
33
+ return (_jsx(SuccessFlowButtons, { flowName: data.flowName, loading: loading, bank: bank, brand: brand, entity: entity, merchant: merchant, user: __assign({ names: { en: name } }, user), business: business, boardId: board_id, boardInfoId: board_info_id, individuals: individuals, flows: flows || [], onClose: onClose }));
26
34
  };
27
35
  export default memo(SuccessWithFlowButtons);
@@ -1,3 +1,14 @@
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
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -34,41 +45,50 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
46
  }
36
47
  };
37
- import { jsx as _jsx } from "react/jsx-runtime";
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
38
49
  import * as React from 'react';
39
- import { useAppSelector, useAppDispatch } from '../../../../hooks';
50
+ import { useTranslation } from 'react-i18next';
51
+ import { useAppSelector, useAppDispatch, useLanguage } from '../../../../hooks';
40
52
  import { ScreenContainer } from '../../../shared/Containers';
41
53
  import BusinessCountry from '../../../shared/BusinessCountry';
54
+ import Button from '../../../shared/Button';
42
55
  import { findCountryByIso2, isKW, isOtherThanKWOrSA } from '../../../../utils';
56
+ import Collapse from '../../../../components/Collapse';
43
57
  import { handleNextScreenStep, handleSetCountryByIso2, settingsSelector } from '../../../../app/settings';
44
- import { connectSelector, setDefaultCountryCode, updateBusinessCountry, storeIsStartFromBusinessCountry } from '../../../app/connect/connectStore';
58
+ import { connectSelector, setDefaultCountryCode, updateBusinessCountry, storeIsStartFromBusinessCountry, clearError } from '../../../app/connect/connectStore';
45
59
  var BusinessCountryScreen = function (_a) {
46
60
  var dispatch = useAppDispatch();
61
+ var isAr = useLanguage().isAr;
62
+ var t = useTranslation().t;
63
+ var _b = React.useState(false), isListOpen = _b[0], setListOpen = _b[1];
47
64
  var settingsData = useAppSelector(settingsSelector).data;
48
- var _b = useAppSelector(connectSelector), data = _b.data, loading = _b.loading;
65
+ var _c = useAppSelector(connectSelector), data = _c.data, loading = _c.loading, error = _c.error;
49
66
  React.useEffect(function () {
67
+ dispatch(clearError());
50
68
  dispatch(storeIsStartFromBusinessCountry(true));
51
69
  }, []);
52
70
  var defaultValue = React.useMemo(function () {
53
71
  var _a, _b;
54
- return ((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || ((_b = settingsData.ipCountry) === null || _b === void 0 ? void 0 : _b.iso2);
72
+ var value = ((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || ((_b = settingsData.ipCountry) === null || _b === void 0 ? void 0 : _b.iso2);
73
+ setListOpen(!!value);
74
+ return value;
55
75
  }, [settingsData.businessCountry, settingsData.ipCountry]);
56
- var onSelectCountry = function (item) { return __awaiter(void 0, void 0, void 0, function () {
76
+ var onSelectCountry = function (iso2) { return __awaiter(void 0, void 0, void 0, function () {
57
77
  var countryCode;
58
78
  return __generator(this, function (_a) {
59
79
  switch (_a.label) {
60
80
  case 0:
61
- countryCode = findCountryByIso2(settingsData.countries, item.country.iso2);
62
- dispatch(handleSetCountryByIso2(item.country.iso2));
81
+ countryCode = findCountryByIso2(settingsData.countries, iso2);
82
+ dispatch(handleSetCountryByIso2(iso2));
63
83
  if (!data.leadId) return [3, 2];
64
- return [4, dispatch(updateBusinessCountry(item.country.iso2))];
84
+ return [4, dispatch(updateBusinessCountry(iso2))];
65
85
  case 1:
66
86
  _a.sent();
67
87
  _a.label = 2;
68
88
  case 2:
69
89
  if (countryCode)
70
90
  dispatch(setDefaultCountryCode(countryCode));
71
- if (isOtherThanKWOrSA(item.country.iso2) || isKW(item.country.iso2)) {
91
+ if (isOtherThanKWOrSA(iso2) || isKW(iso2)) {
72
92
  dispatch(handleNextScreenStep('CONNECT_MOBILE_STEP'));
73
93
  return [2];
74
94
  }
@@ -77,6 +97,8 @@ var BusinessCountryScreen = function (_a) {
77
97
  }
78
98
  });
79
99
  }); };
80
- return (_jsx(ScreenContainer, { children: _jsx(BusinessCountry, { countries: settingsData.businessCountries, loading: loading, defaultCountryIso2: defaultValue, onSelectCountry: onSelectCountry }) }));
100
+ return (_jsxs(ScreenContainer, { children: [_jsx(BusinessCountry, { sx: { mb: 2.5 }, countries: settingsData.businessCountries, loading: loading, defaultCountryIso2: defaultValue, onSelectCountry: onSelectCountry, onListOpen: function () { return setListOpen(true); }, onListClose: function () { return setListOpen(false); } }), _jsx(Collapse, __assign({ in: !isListOpen }, { children: _jsx(Button, __assign({ onClick: function () {
101
+ onSelectCountry(defaultValue);
102
+ }, loading: loading, isAr: isAr, disableBack: true, disabled: !defaultValue, error: t(error || '') }, { children: t('next') })) }))] }));
81
103
  };
82
104
  export default React.memo(BusinessCountryScreen);
@@ -1,3 +1,14 @@
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
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -34,41 +45,52 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
46
  }
36
47
  };
37
- import { jsx as _jsx } from "react/jsx-runtime";
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
38
49
  import * as React from 'react';
39
- import { useAppSelector, useAppDispatch } from '../../../../hooks';
50
+ import { useTranslation } from 'react-i18next';
51
+ import { useAppSelector, useAppDispatch, useLanguage } from '../../../../hooks';
40
52
  import { ScreenContainer } from '../../../shared/Containers';
41
53
  import BusinessCountry from '../../../shared/BusinessCountry';
54
+ import Button from '../../../shared/Button';
55
+ import Collapse from '../../../../components/Collapse';
42
56
  import { findCountryByIso2, isKW, isOtherThanKWOrSA } from '../../../../utils';
43
57
  import { handleNextScreenStep, handleSetCountryByIso2, settingsSelector } from '../../../../app/settings';
44
- import { connectExpressSelector, setDefaultCountryCode, storeIsStartFromBusinessCountry, updateBusinessCountryAsync } from '../../../app/connectExpress/connectExpressStore';
58
+ import { clearError, connectExpressSelector, setDefaultCountryCode, storeIsStartFromBusinessCountry, updateBusinessCountryAsync } from '../../../app/connectExpress/connectExpressStore';
45
59
  var BusinessCountryScreen = function (_a) {
46
60
  var dispatch = useAppDispatch();
61
+ var isAr = useLanguage().isAr;
62
+ var t = useTranslation().t;
63
+ var _b = React.useState(false), isListOpen = _b[0], setListOpen = _b[1];
47
64
  var settingsData = useAppSelector(settingsSelector).data;
48
- var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading;
65
+ var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error;
49
66
  React.useEffect(function () {
67
+ dispatch(clearError());
50
68
  dispatch(storeIsStartFromBusinessCountry(true));
51
69
  }, []);
52
70
  var defaultValue = React.useMemo(function () {
53
71
  var _a, _b;
54
- return ((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || ((_b = settingsData.ipCountry) === null || _b === void 0 ? void 0 : _b.iso2);
72
+ var value = ((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || ((_b = settingsData.ipCountry) === null || _b === void 0 ? void 0 : _b.iso2);
73
+ setListOpen(!!value);
74
+ return value;
55
75
  }, [settingsData.businessCountry, settingsData.ipCountry]);
56
- var onSelectCountry = function (item) { return __awaiter(void 0, void 0, void 0, function () {
76
+ var onSelectCountry = function (iso2) { return __awaiter(void 0, void 0, void 0, function () {
57
77
  var countryCode;
58
78
  return __generator(this, function (_a) {
59
79
  switch (_a.label) {
60
80
  case 0:
61
- countryCode = findCountryByIso2(settingsData.countries, item.country.iso2);
62
- dispatch(handleSetCountryByIso2(item.country.iso2));
81
+ if (!iso2)
82
+ return [2];
83
+ countryCode = findCountryByIso2(settingsData.countries, iso2);
84
+ dispatch(handleSetCountryByIso2(iso2));
63
85
  if (!data.leadId) return [3, 2];
64
- return [4, dispatch(updateBusinessCountryAsync(item.country.iso2))];
86
+ return [4, dispatch(updateBusinessCountryAsync(iso2))];
65
87
  case 1:
66
88
  _a.sent();
67
89
  _a.label = 2;
68
90
  case 2:
69
91
  if (countryCode)
70
92
  dispatch(setDefaultCountryCode(countryCode));
71
- if (isOtherThanKWOrSA(item.country.iso2) || isKW(item.country.iso2)) {
93
+ if (isOtherThanKWOrSA(iso2) || isKW(iso2)) {
72
94
  dispatch(handleNextScreenStep('CONNECT_EXPRESS_MOBILE_STEP'));
73
95
  return [2];
74
96
  }
@@ -77,6 +99,8 @@ var BusinessCountryScreen = function (_a) {
77
99
  }
78
100
  });
79
101
  }); };
80
- return (_jsx(ScreenContainer, { children: _jsx(BusinessCountry, { countries: settingsData.businessCountries, loading: loading, defaultCountryIso2: defaultValue, onSelectCountry: onSelectCountry }) }));
102
+ return (_jsxs(ScreenContainer, { children: [_jsx(BusinessCountry, { sx: { mb: 2.5 }, countries: settingsData.businessCountries, loading: loading, defaultCountryIso2: defaultValue, onSelectCountry: onSelectCountry, onListOpen: function () { return setListOpen(true); }, onListClose: function () { return setListOpen(false); } }), _jsx(Collapse, __assign({ in: !isListOpen }, { children: _jsx(Button, __assign({ onClick: function () {
103
+ onSelectCountry(defaultValue);
104
+ }, loading: loading, isAr: isAr, disableBack: true, disabled: !defaultValue, error: t(error || '') }, { children: t('next') })) }))] }));
81
105
  };
82
106
  export default React.memo(BusinessCountryScreen);
@@ -28,7 +28,7 @@ import Box from '@mui/material/Box';
28
28
  import { styled } from '@mui/material/styles';
29
29
  import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
30
30
  import { BusinessType } from '../../../../@types';
31
- import { isKW, isOtherLicense, isSA } from '../../../../utils';
31
+ import { isKW, isOtherLicense, isOtherThanKWOrSA, isSA } from '../../../../utils';
32
32
  import { settingsSelector } from '../../../../app/settings';
33
33
  import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
34
34
  import SimpleList from '../../../../components/SimpleList';
@@ -80,8 +80,9 @@ var LicenseList = function (_a) {
80
80
  setAnchorEl(null);
81
81
  (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
82
82
  };
83
- var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
83
+ var isOtherThanKWOrSACountry = React.useMemo(function () { return isOtherThanKWOrSA(country_code); }, [country_code]);
84
84
  var isKWCountry = React.useMemo(function () { return isKW(country_code); }, [country_code]);
85
+ var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
85
86
  React.useEffect(function () {
86
87
  if ((licenseList || []).length > 0)
87
88
  setValue('licenseList', licenseList);
@@ -132,8 +133,8 @@ var LicenseList = function (_a) {
132
133
  var licenseReadonly = !isOtherLicense(selected);
133
134
  var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
134
135
  var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
135
- return (_jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, 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) {
136
- 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, {})] }));
137
- } }) })), _jsx(LicenseType, { show: show && isKWCountry, readOnly: readOnly }), _jsx(LicenseNumber, { show: isKWCountry ? isCR : show, readOnly: licenseReadonly })] }));
136
+ return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry || isOtherThanKWOrSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, 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) {
137
+ 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, {})] }));
138
+ } }) }))] })), _jsx(LicenseType, { show: show && isKWCountry, readOnly: readOnly }), _jsx(LicenseNumber, { show: isKWCountry ? isCR : show, readOnly: licenseReadonly })] }));
138
139
  };
139
140
  export default React.memo(LicenseList);
@@ -1,10 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { BusinessCountryInfo, CountryInfo } from '../../../@types';
2
+ import { SxProps, Theme } from '@mui/material/styles';
3
+ import { BusinessCountryInfo } from '../../../@types';
3
4
  interface BusinessCountryProps {
5
+ onListOpen?: () => void;
6
+ onListClose?: () => void;
4
7
  countries: Array<BusinessCountryInfo>;
5
8
  loading: boolean;
6
9
  defaultCountryIso2: string;
7
- onSelectCountry: (country: CountryInfo) => void;
10
+ onSelectCountry: (iso2: string) => void;
11
+ sx?: SxProps<Theme>;
8
12
  }
9
- declare const BusinessCountry: ({ countries, loading, defaultCountryIso2, onSelectCountry }: BusinessCountryProps) => JSX.Element;
13
+ declare const BusinessCountry: ({ sx, onListOpen, onListClose, countries, loading, defaultCountryIso2, onSelectCountry }: BusinessCountryProps) => JSX.Element;
10
14
  export default BusinessCountry;
@@ -96,9 +96,9 @@ var CountryListStyled = styled((SimpleList))(function () { return ({
96
96
  }); });
97
97
  var BusinessCountry = function (_a) {
98
98
  var _b, _c;
99
- var countries = _a.countries, loading = _a.loading, defaultCountryIso2 = _a.defaultCountryIso2, onSelectCountry = _a.onSelectCountry;
99
+ var sx = _a.sx, onListOpen = _a.onListOpen, onListClose = _a.onListClose, countries = _a.countries, loading = _a.loading, defaultCountryIso2 = _a.defaultCountryIso2, onSelectCountry = _a.onSelectCountry;
100
100
  var _d = React.useState(countries || []), countryList = _d[0], setCountryList = _d[1];
101
- var _e = React.useState(true), open = _e[0], setOpen = _e[1];
101
+ var _e = React.useState(!!defaultCountryIso2), open = _e[0], setOpen = _e[1];
102
102
  var _f = React.useState(''), subIndex = _f[0], setSubIndex = _f[1];
103
103
  var _g = React.useState(), selectedCountry = _g[0], setSelectedCountry = _g[1];
104
104
  var t = useTranslation().t;
@@ -107,17 +107,19 @@ var BusinessCountry = function (_a) {
107
107
  var onSelectItem = function (item) { return __awaiter(void 0, void 0, void 0, function () {
108
108
  return __generator(this, function (_a) {
109
109
  setSelectedCountry(item);
110
- onSelectCountry(item);
110
+ onSelectCountry(item.country.iso2);
111
111
  return [2];
112
112
  });
113
113
  }); };
114
114
  var handleCloseMainMenu = function () {
115
115
  setOpen(false);
116
116
  handleSearch('');
117
+ onListClose === null || onListClose === void 0 ? void 0 : onListClose();
117
118
  };
118
119
  var handleOpenMainMenu = function () {
119
120
  setCountryList(countries);
120
121
  setOpen(true);
122
+ onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
121
123
  };
122
124
  var handleOpenSubMenu = function (index) {
123
125
  if (subIndex === index)
@@ -150,7 +152,7 @@ var BusinessCountry = function (_a) {
150
152
  });
151
153
  setCountryList(filteredList);
152
154
  };
153
- return (_jsxs(ScreenContainer, __assign({ sx: { pb: 2.5 } }, { children: [_jsx(InputSelect, { required: true, label: t('country_list_title'), value: (isAr ? (_b = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _b === void 0 ? void 0 : _b.name_ar : (_c = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _c === void 0 ? void 0 : _c.name_en) || '', onClick: open ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_any_country'), endAdornment: _jsx(ExpandIcon, { anchorEl: open }) }), _jsxs(Collapse, __assign({ in: open }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: countryList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item, e) {
155
+ return (_jsxs(ScreenContainer, __assign({ sx: __assign({ pb: 2.5 }, sx) }, { children: [_jsx(InputSelect, { required: true, label: t('country_list_title'), value: (isAr ? (_b = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _b === void 0 ? void 0 : _b.name_ar : (_c = countryValue === null || countryValue === void 0 ? void 0 : countryValue.country) === null || _c === void 0 ? void 0 : _c.name_en) || '', onClick: open ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_any_country'), endAdornment: _jsx(ExpandIcon, { anchorEl: open }) }), _jsxs(Collapse, __assign({ in: open }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: countryList, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (item, e) {
154
156
  e.stopPropagation();
155
157
  handleOpenSubMenu(item.id.toString());
156
158
  }, renderItem: function (item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.6.26-test",
3
+ "version": "2.6.28-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",