@tap-payments/auth-jsconnect 2.0.24-test → 2.0.26-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.
@@ -5,6 +5,7 @@ export declare type CheckEmailBody = {
5
5
  };
6
6
  export declare type CheckBrandBody = {
7
7
  profile_name: string;
8
+ country_code: string;
8
9
  encryption_contract: Array<string>;
9
10
  };
10
11
  export declare type CheckIBanBody = {
@@ -383,14 +383,12 @@ export var createAccount = createAsyncThunk('createAccount', function (params, t
383
383
  return [4, API.accountService.createAccount(requestBody)];
384
384
  case 1:
385
385
  data = _e.sent();
386
- if (!!data.errors) return [3, 3];
387
386
  return [4, thunkApi.dispatch(retrieveChannels())];
388
387
  case 2:
389
388
  _e.sent();
390
389
  thunkApi.dispatch(handleNextScreenStep());
391
390
  (_d = (_c = settings.data.appConfig).onStepCompleted) === null || _d === void 0 ? void 0 : _d.call(_c, settings.data.activeScreen.name, requestBody);
392
- _e.label = 3;
393
- case 3: return [2, { data: data }];
391
+ return [2, { data: data }];
394
392
  }
395
393
  });
396
394
  }); });
@@ -391,20 +391,23 @@ export var checkEmailAvailability = createAsyncThunk('checkEmailAvailability', f
391
391
  });
392
392
  });
393
393
  });
394
- export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (_a) {
394
+ export var checkBrandNameAvailability = createAsyncThunk('checkBrandNameAvailability', function (_a, thunkApi) {
395
395
  var cancelToken = _a.cancelToken, name = _a.name, onSuccess = _a.onSuccess;
396
396
  return __awaiter(void 0, void 0, void 0, function () {
397
- var requestBody, data;
398
- return __generator(this, function (_b) {
399
- switch (_b.label) {
397
+ var settings, requestBody, data;
398
+ var _b;
399
+ return __generator(this, function (_c) {
400
+ switch (_c.label) {
400
401
  case 0:
402
+ settings = thunkApi.getState().settings;
401
403
  requestBody = {
402
404
  profile_name: name,
405
+ country_code: (_b = settings.data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2,
403
406
  encryption_contract: ['profile_name']
404
407
  };
405
408
  return [4, API.availabilityServices.checkBrand(requestBody, { cancelToken: cancelToken })];
406
409
  case 1:
407
- data = (_b.sent()).data;
410
+ data = (_c.sent()).data;
408
411
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
409
412
  if (!data.errors)
410
413
  return [2, { response: data, formData: { name: name } }];
@@ -58,8 +58,9 @@ var VerifyNumber = function (_a) {
58
58
  var t = useTranslation().t;
59
59
  var isAr = useLanguage().isAr;
60
60
  var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
61
+ 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;
61
62
  React.useEffect(function () {
62
- if (error)
63
+ if (error && methods.formState.isValid && phone)
63
64
  dispatch(clearError());
64
65
  return function () {
65
66
  dispatch(resetOTPScreen());
@@ -71,7 +72,6 @@ var VerifyNumber = function (_a) {
71
72
  var onBack = function () {
72
73
  dispatch(handlePrevScreenStep());
73
74
  };
74
- 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;
75
75
  var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
76
76
  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') }))] })) })) }));
77
77
  };
@@ -5,13 +5,19 @@ import { useController, useFormContext } from 'react-hook-form';
5
5
  import DatePicker from '../../../../components/DatePicker';
6
6
  import { ScreenContainer } from '../../../shared/Containers';
7
7
  import { MandatoryStyled } from './SalesChannels';
8
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
9
+ import { businessSelector, clearError } from '../../../app/business/businessStore';
8
10
  var OperationStartDate = function (_a) {
9
11
  var _b;
10
12
  var onDateClicked = _a.onDateClicked;
11
13
  var t = useTranslation().t;
14
+ var dispatch = useAppDispatch();
12
15
  var control = useFormContext().control;
16
+ var error = useAppSelector(businessSelector).error;
13
17
  var oDateControl = useController({ control: control, name: 'operationStartDate' });
14
18
  var handleOperationStartDateChange = function (data) {
19
+ if (error)
20
+ dispatch(clearError());
15
21
  oDateControl.field.onChange(data);
16
22
  };
17
23
  var dateValue = (_b = oDateControl === null || oDateControl === void 0 ? void 0 : oDateControl.field) === null || _b === void 0 ? void 0 : _b.value;
@@ -24,9 +24,9 @@ import Box from '@mui/material/Box';
24
24
  import { alpha, styled } from '@mui/material/styles';
25
25
  import { useTranslation } from 'react-i18next';
26
26
  import { useController, useFormContext } from 'react-hook-form';
27
- import { useLanguage, useAppSelector } from '../../../../hooks';
27
+ import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
28
28
  import Text from '../../../../components/Text';
29
- import { businessSelector } from '../../../app/business/businessStore';
29
+ import { businessSelector, clearError } from '../../../app/business/businessStore';
30
30
  import CheckBox from '../../../../components/CheckBox';
31
31
  import Warning from '../../../../components/Warning';
32
32
  import Collapse from '../../../../components/Collapse';
@@ -79,10 +79,11 @@ var SalesChannels = function () {
79
79
  var t = useTranslation().t;
80
80
  var isAr = useLanguage().isAr;
81
81
  var control = useFormContext().control;
82
+ var dispatch = useAppDispatch();
82
83
  var channelsControl = useController({ name: 'salesChannels', control: control });
83
84
  var channelsChecked = channelsControl.field.value;
84
85
  var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
85
- var data = useAppSelector(businessSelector).data;
86
+ var _c = useAppSelector(businessSelector), data = _c.data, error = _c.error;
86
87
  var channelList = (data.businessTypeData.responseBody || {}).channelList;
87
88
  React.useEffect(function () {
88
89
  if ((channelList === null || channelList === void 0 ? void 0 : channelList.length) > 0) {
@@ -98,6 +99,8 @@ var SalesChannels = function () {
98
99
  return;
99
100
  }
100
101
  channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsChecked, true), [selected], false));
102
+ if (error)
103
+ dispatch(clearError());
101
104
  };
102
105
  var getSelectedChannelsFlag = function (item) {
103
106
  if (channelsChecked)
@@ -33,8 +33,8 @@ import ExpandIcon from '../../../../components/ExpandIcon';
33
33
  import Input from '../../../../components/Input';
34
34
  import SimpleList from '../../../../components/SimpleList';
35
35
  import { ScreenContainer } from '../../../shared/Containers';
36
- import { useLanguage, useAppSelector } from '../../../../hooks';
37
- import { businessSelector } from '../../../app/business/businessStore';
36
+ import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
37
+ import { businessSelector, clearError } from '../../../app/business/businessStore';
38
38
  export var InputLabelStyled = styled(Text)(function (_a) {
39
39
  var theme = _a.theme;
40
40
  return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
@@ -78,8 +78,9 @@ var customerLocations = function (_a) {
78
78
  var t = useTranslation().t;
79
79
  var isAr = useLanguage().isAr;
80
80
  var control = useFormContext().control;
81
+ var dispatch = useAppDispatch();
81
82
  var customerLocationsControl = useController({ name: 'customerLocations', control: control });
82
- var data = useAppSelector(businessSelector).data;
83
+ var _d = useAppSelector(businessSelector), data = _d.data, error = _d.error;
83
84
  var activitiesData = data.activitiesData;
84
85
  var response = activitiesData.responseBody;
85
86
  var onOpenList = function (event) {
@@ -106,6 +107,8 @@ var customerLocations = function (_a) {
106
107
  var onSelectItem = function (customerLocations) {
107
108
  onCloseList();
108
109
  var remaining = customerLocationsList.filter(function (location) { return location.id <= customerLocations.id; });
110
+ if (error)
111
+ dispatch(clearError());
109
112
  customerLocationsControl.field.onChange(remaining);
110
113
  };
111
114
  var customerLocationsValue = customerLocationsControl.field.value;
@@ -26,13 +26,13 @@ import Box from '@mui/material/Box';
26
26
  import { styled } from '@mui/material/styles';
27
27
  import { useTranslation } from 'react-i18next';
28
28
  import { useController, useFormContext } from 'react-hook-form';
29
- import { useLanguage, useAppSelector } from '../../../../hooks';
29
+ import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
30
30
  import SimpleList from '../../../../components/SimpleList';
31
31
  import Collapse from '../../../../components/Collapse';
32
32
  import ExpandIcon from '../../../../components/ExpandIcon';
33
33
  import { ScreenContainer } from '../../../shared/Containers';
34
34
  import { CheckIconStyled, InputLabelStyled, InputStyled, NameContainer } from './CustomerLocations';
35
- import { businessSelector } from '../../../app/business/businessStore';
35
+ import { businessSelector, clearError } from '../../../app/business/businessStore';
36
36
  var ListItemContainer = styled(Box)(function (_a) {
37
37
  var theme = _a.theme;
38
38
  return ({
@@ -49,9 +49,10 @@ var ExpectedCustomers = function (_a) {
49
49
  var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
50
50
  var t = useTranslation().t;
51
51
  var isAr = useLanguage().isAr;
52
+ var dispatch = useAppDispatch();
52
53
  var control = useFormContext().control;
53
54
  var expectedCustomerControl = useController({ name: 'expectedCustomer', control: control });
54
- var data = useAppSelector(businessSelector).data;
55
+ var _d = useAppSelector(businessSelector), data = _d.data, error = _d.error;
55
56
  var activitiesData = data.activitiesData;
56
57
  var response = activitiesData.responseBody;
57
58
  var onOpenList = function (event) {
@@ -72,6 +73,8 @@ var ExpectedCustomers = function (_a) {
72
73
  }, [response === null || response === void 0 ? void 0 : response.expectedCustomerSales]);
73
74
  var onSelectItem = function (expectedCustomers) {
74
75
  expectedCustomerControl.field.onChange(expectedCustomers);
76
+ if (error)
77
+ dispatch(clearError());
75
78
  onCloseList();
76
79
  };
77
80
  var expectedCustomersValue = expectedCustomerControl.field.value;
@@ -15,11 +15,11 @@ import Box from '@mui/material/Box';
15
15
  import { styled } from '@mui/material/styles';
16
16
  import { useTranslation } from 'react-i18next';
17
17
  import { useController, useFormContext } from 'react-hook-form';
18
- import { useLanguage, useAppSelector } from '../../../../hooks';
18
+ import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
19
19
  import SimpleList from '../../../../components/SimpleList';
20
20
  import Collapse from '../../../../components/Collapse';
21
21
  import ExpandIcon from '../../../../components/ExpandIcon';
22
- import { businessSelector } from '../../../../features/app/business/businessStore';
22
+ import { businessSelector, clearError } from '../../../app/business/businessStore';
23
23
  import { isExist } from '../../../../utils';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
25
25
  import { InputLabelStyled, CheckIconStyled, InputStyled, NameContainer } from './CustomerLocations';
@@ -51,8 +51,9 @@ var ExpectedSalesRange = function (_a) {
51
51
  var t = useTranslation().t;
52
52
  var isAr = useLanguage().isAr;
53
53
  var control = useFormContext().control;
54
+ var dispatch = useAppDispatch();
54
55
  var expectedSaleControl = useController({ name: 'expectedSale', control: control });
55
- var data = useAppSelector(businessSelector).data;
56
+ var _e = useAppSelector(businessSelector), data = _e.data, error = _e.error;
56
57
  var activitiesData = data.activitiesData;
57
58
  var expectedSales = (activitiesData.responseBody || {}).expectedSales;
58
59
  var expectedSalesRangeValue = expectedSaleControl.field.value;
@@ -81,6 +82,8 @@ var ExpectedSalesRange = function (_a) {
81
82
  }, [expectedSales]);
82
83
  var onSelectItem = function (expectedSalesRange) {
83
84
  handleCloseMainMenu();
85
+ if (error)
86
+ dispatch(clearError());
84
87
  expectedSaleControl.field.onChange(expectedSalesRange);
85
88
  };
86
89
  React.useEffect(function () {
@@ -58,8 +58,9 @@ var VerifyNumber = function (_a) {
58
58
  var t = useTranslation().t;
59
59
  var isAr = useLanguage().isAr;
60
60
  var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
61
+ 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;
61
62
  React.useEffect(function () {
62
- if (error && methods.formState.isValid)
63
+ if (error && methods.formState.isValid && phone)
63
64
  dispatch(clearError());
64
65
  return function () {
65
66
  dispatch(resetOTPScreen());
@@ -71,7 +72,6 @@ var VerifyNumber = function (_a) {
71
72
  var onBack = function () {
72
73
  dispatch(handlePrevScreenStep());
73
74
  };
74
- 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;
75
75
  var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
76
76
  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') }))] })) })) }));
77
77
  };
@@ -58,8 +58,9 @@ var VerifyNumber = function (_a) {
58
58
  var t = useTranslation().t;
59
59
  var isAr = useLanguage().isAr;
60
60
  var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
61
+ 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;
61
62
  React.useEffect(function () {
62
- if (error)
63
+ if (error && methods.formState.isValid && phone)
63
64
  dispatch(clearError());
64
65
  return function () {
65
66
  dispatch(resetOTPScreen());
@@ -71,7 +72,6 @@ var VerifyNumber = function (_a) {
71
72
  var onBack = function () {
72
73
  dispatch(handlePrevScreenStep());
73
74
  };
74
- 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;
75
75
  var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
76
76
  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') }))] })) })) }));
77
77
  };
@@ -58,8 +58,9 @@ var VerifyNumber = function (_a) {
58
58
  var t = useTranslation().t;
59
59
  var isAr = useLanguage().isAr;
60
60
  var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
61
+ 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;
61
62
  React.useEffect(function () {
62
- if (error)
63
+ if (error && methods.formState.isValid && phone)
63
64
  dispatch(clearError());
64
65
  return function () {
65
66
  dispatch(resetOTPScreen());
@@ -71,7 +72,6 @@ var VerifyNumber = function (_a) {
71
72
  var onBack = function () {
72
73
  dispatch(handlePrevScreenStep());
73
74
  };
74
- 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;
75
75
  var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
76
76
  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 || resendLoading, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
77
77
  };
@@ -58,8 +58,9 @@ var VerifyNumber = function (_a) {
58
58
  var t = useTranslation().t;
59
59
  var isAr = useLanguage().isAr;
60
60
  var _f = React.useState(false), resendLoading = _f[0], setResendLoading = _f[1];
61
+ 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
62
  React.useEffect(function () {
62
- if (error)
63
+ if (error && methods.formState.isValid && phone)
63
64
  dispatch(clearError());
64
65
  return function () {
65
66
  dispatch(resetOTPScreen());
@@ -71,7 +72,6 @@ var VerifyNumber = function (_a) {
71
72
  var onBack = function () {
72
73
  dispatch(handlePrevScreenStep());
73
74
  };
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;
75
75
  var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
76
76
  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') }))] })) })) }));
77
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.0.24-test",
3
+ "version": "2.0.26-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",