@tap-payments/auth-jsconnect 1.0.50 → 1.0.53

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 (99) hide show
  1. package/build/@types/app.d.ts +3 -3
  2. package/build/@types/form.d.ts +22 -2
  3. package/build/api/entity.d.ts +5 -2
  4. package/build/api/index.d.ts +3 -3
  5. package/build/api/lead.d.ts +1 -1
  6. package/build/app/rootReducer.d.ts +4 -0
  7. package/build/app/rootReducer.js +9 -1
  8. package/build/app/store.d.ts +8 -0
  9. package/build/assets/locales/ar.json +2 -1
  10. package/build/assets/locales/en.json +3 -2
  11. package/build/components/AnimationFlow/AnimationFlow.d.ts +3 -1
  12. package/build/components/AnimationFlow/AnimationFlow.js +5 -1
  13. package/build/components/AnimationFlow/Loader.d.ts +2 -0
  14. package/build/components/AnimationFlow/Loader.js +14 -0
  15. package/build/components/Loader/Loader.d.ts +1 -0
  16. package/build/components/Loader/Loader.js +1 -1
  17. package/build/components/SimpleList/SimpleList.js +1 -0
  18. package/build/constants/app.d.ts +24 -0
  19. package/build/constants/app.js +61 -19
  20. package/build/constants/dummy.d.ts +2 -0
  21. package/build/constants/dummy.js +12 -6
  22. package/build/features/app/bank/bankStore.d.ts +36 -0
  23. package/build/features/app/bank/bankStore.js +218 -0
  24. package/build/features/app/business/businessStore.d.ts +1 -2
  25. package/build/features/app/business/businessStore.js +56 -56
  26. package/build/features/app/connect/connectStore.js +31 -30
  27. package/build/features/app/individual/individualStore.d.ts +36 -0
  28. package/build/features/app/individual/individualStore.js +222 -0
  29. package/build/features/app/password/passwordStore.d.ts +36 -0
  30. package/build/features/app/password/passwordStore.js +218 -0
  31. package/build/features/app/tax/taxStore.d.ts +36 -0
  32. package/build/features/app/tax/taxStore.js +217 -0
  33. package/build/features/bank/Bank.d.ts +2 -1
  34. package/build/features/bank/Bank.js +15 -5
  35. package/build/features/bank/screens/BankDetails/BankDetails.js +1 -2
  36. package/build/features/bank/screens/Verify/OTPInput.d.ts +5 -0
  37. package/build/features/bank/screens/Verify/OTPInput.js +42 -0
  38. package/build/features/bank/screens/Verify/Verify.d.ts +5 -0
  39. package/build/features/bank/screens/Verify/Verify.js +78 -0
  40. package/build/features/bank/screens/Verify/index.d.ts +2 -0
  41. package/build/features/bank/screens/Verify/index.js +2 -0
  42. package/build/features/bank/screens/Verify/validation.d.ts +8 -0
  43. package/build/features/bank/screens/Verify/validation.js +4 -0
  44. package/build/features/business/screens/Activities/Activities.js +8 -8
  45. package/build/features/business/screens/Activities/ActivitiesList.js +7 -7
  46. package/build/features/business/screens/Activities/SalesChannels.js +1 -1
  47. package/build/features/business/screens/BusinessType/CRNumber.d.ts +2 -1
  48. package/build/features/business/screens/BusinessType/CRNumber.js +2 -2
  49. package/build/features/business/screens/BusinessType/CompanyLicense.js +2 -1
  50. package/build/features/business/screens/BusinessType/FLNumber.d.ts +2 -1
  51. package/build/features/business/screens/BusinessType/FLNumber.js +2 -2
  52. package/build/features/business/screens/BusinessType/FreelanceLicense.js +2 -1
  53. package/build/features/business/screens/Confirm/Confirm.js +1 -1
  54. package/build/features/connect/Connect.js +2 -2
  55. package/build/features/connect/screens/Individual/MobileNumber.js +1 -1
  56. package/build/features/connect/screens/Individual/validation.js +1 -1
  57. package/build/features/connect/screens/Merchant/BrandList.d.ts +0 -2
  58. package/build/features/connect/screens/Merchant/BrandList.js +16 -40
  59. package/build/features/connect/screens/Merchant/Merchant.js +42 -23
  60. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +2 -1
  61. package/build/features/connect/screens/Merchant/SocialMedia.js +30 -3
  62. package/build/features/connect/screens/Merchant/validation.d.ts +6 -1
  63. package/build/features/connect/screens/Merchant/validation.js +67 -7
  64. package/build/features/connect/screens/Mobile/MobileNumber.js +1 -1
  65. package/build/features/connect/screens/Mobile/validation.js +1 -1
  66. package/build/features/featuresScreens.js +20 -10
  67. package/build/features/individual/Individual.d.ts +2 -1
  68. package/build/features/individual/Individual.js +15 -7
  69. package/build/features/individual/screens/Verify/OTPInput.d.ts +5 -0
  70. package/build/features/individual/screens/Verify/OTPInput.js +42 -0
  71. package/build/features/individual/screens/Verify/Verify.d.ts +5 -0
  72. package/build/features/individual/screens/Verify/Verify.js +78 -0
  73. package/build/features/individual/screens/Verify/index.d.ts +2 -0
  74. package/build/features/individual/screens/Verify/index.js +2 -0
  75. package/build/features/individual/screens/Verify/validation.d.ts +8 -0
  76. package/build/features/individual/screens/Verify/validation.js +4 -0
  77. package/build/features/password/Password.d.ts +2 -1
  78. package/build/features/password/Password.js +15 -7
  79. package/build/features/password/screens/Verify/OTPInput.d.ts +5 -0
  80. package/build/features/password/screens/Verify/OTPInput.js +42 -0
  81. package/build/features/password/screens/Verify/Verify.d.ts +5 -0
  82. package/build/features/password/screens/Verify/Verify.js +78 -0
  83. package/build/features/password/screens/Verify/index.d.ts +2 -0
  84. package/build/features/password/screens/Verify/index.js +2 -0
  85. package/build/features/password/screens/Verify/validation.d.ts +8 -0
  86. package/build/features/password/screens/Verify/validation.js +4 -0
  87. package/build/features/tax/Tax.d.ts +2 -1
  88. package/build/features/tax/Tax.js +15 -7
  89. package/build/features/tax/screens/Verify/OTPInput.d.ts +5 -0
  90. package/build/features/tax/screens/Verify/OTPInput.js +42 -0
  91. package/build/features/tax/screens/Verify/Verify.d.ts +5 -0
  92. package/build/features/tax/screens/Verify/Verify.js +78 -0
  93. package/build/features/tax/screens/Verify/index.d.ts +2 -0
  94. package/build/features/tax/screens/Verify/index.js +2 -0
  95. package/build/features/tax/screens/Verify/validation.d.ts +8 -0
  96. package/build/features/tax/screens/Verify/validation.js +4 -0
  97. package/build/hooks/useAppDispatch.d.ts +4 -0
  98. package/build/utils/string.js +0 -1
  99. package/package.json +1 -1
@@ -0,0 +1,42 @@
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
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ var BoxStyled = styled(Box)(function (_a) {
21
+ var theme = _a.theme;
22
+ return ({
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ fontFamily: theme.typography.fontFamily
26
+ });
27
+ });
28
+ var OTPInput = function (_a) {
29
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
30
+ var t = useTranslation().t;
31
+ var otpControl = useController({ name: 'otp', control: control });
32
+ var handleOnOTPChange = function (otp) {
33
+ otpControl.field.onChange(otp);
34
+ };
35
+ var handleOnResendOTP = function () {
36
+ if (otpControl.field.value)
37
+ setValue('otp', '', { shouldValidate: true });
38
+ };
39
+ var otpValue = otpControl.field.value;
40
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
41
+ };
42
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,78 @@
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
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { useAppDispatch } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useSelector } from 'react-redux';
17
+ import { useForm, FormProvider } from 'react-hook-form';
18
+ import { yupResolver } from '@hookform/resolvers/yup';
19
+ import Box from '@mui/material/Box/Box';
20
+ import { styled } from '@mui/material/styles';
21
+ import { handlePrevScreenStep } from '../../../../app/settings';
22
+ import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
24
+ import Form from '../../../../components/Form';
25
+ import Text from '../../../../components/Text';
26
+ import { ScreenContainer } from '../../../shared/Containers';
27
+ import { individualSelector, clearError, resetOTPScreen, verifyLeadOTP } from '../../../app/individual/individualStore';
28
+ import Button from '../../../shared/Button';
29
+ import { OTPValidation } from './validation';
30
+ import OTPInput from './OTPInput';
31
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ background: theme.palette.common.white,
35
+ border: '1px solid',
36
+ borderColor: theme.palette.divider,
37
+ direction: theme.direction,
38
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
39
+ marginBottom: theme.spacing(5.75)
40
+ });
41
+ });
42
+ var OTPTitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.75 }));
45
+ });
46
+ var FormStyled = styled(Form)(function () { return ({
47
+ display: 'flex',
48
+ flexDirection: 'column'
49
+ }); });
50
+ var VerifyNumber = function (_a) {
51
+ var _b, _c, _d;
52
+ var dispatch = useAppDispatch();
53
+ var _e = useSelector(individualSelector), data = _e.data, loading = _e.loading, error = _e.error;
54
+ var methods = useForm({
55
+ resolver: yupResolver(OTPValidation),
56
+ defaultValues: data.otpData,
57
+ mode: 'onChange'
58
+ });
59
+ var t = useTranslation().t;
60
+ var isAr = useLanguage().isAr;
61
+ React.useEffect(function () {
62
+ if (error)
63
+ dispatch(clearError());
64
+ return function () {
65
+ dispatch(resetOTPScreen());
66
+ };
67
+ }, [methods.formState.isValid]);
68
+ var onSubmit = function (formData) {
69
+ dispatch(verifyLeadOTP(formData));
70
+ };
71
+ var onBack = function () {
72
+ dispatch(handlePrevScreenStep());
73
+ };
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
+ var disabled = !methods.formState.isValid || !!error || !phone;
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, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, type: 'submit', isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
77
+ };
78
+ export default React.memo(VerifyNumber);
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- export interface PasswordLibProps {
2
+ import { LibConfig } from '../../@types';
3
+ export interface PasswordLibProps extends LibConfig {
3
4
  }
4
5
  export declare function PasswordLib(props: PasswordLibProps): JSX.Element;
5
6
  export declare function renderPasswordLib(config: PasswordLibProps, elementId: string): void;
@@ -11,28 +11,36 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React, { memo, useEffect } from 'react';
14
- import { useTranslation } from 'react-i18next';
15
- import { useAppTheme, useAppDispatch, useAppSelector } from '../../hooks';
16
- import { handleActiveFlowScreens, settingsSelector } from '../../app/settings';
14
+ import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener } from '../../hooks';
15
+ import { settingsSelector } from '../../app/settings';
17
16
  import AnimationFlow from '../../components/AnimationFlow';
18
17
  import { store } from '../../app/store';
19
18
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
19
  import Collapse from '../../components/Collapse';
21
20
  import { FeatureContainer } from '../shared/Containers';
22
- import { reactElement } from '../../utils';
21
+ import { getParameterByName, reactElement } from '../../utils';
23
22
  import { PASSWORD_SCREENS_NAVIGATION } from '../../constants';
24
23
  import { passwordFeatureScreens } from '../featuresScreens';
24
+ import { verifyLeadToken } from '../app/password/passwordStore';
25
25
  import CustomFooter from '../shared/Footer';
26
26
  var Password = memo(function (props) {
27
27
  var open = React.useState(true)[0];
28
- var t = useTranslation().t;
29
28
  var theme = useAppTheme().theme;
30
29
  var dispatch = useAppDispatch();
31
30
  var data = useAppSelector(settingsSelector).data;
31
+ var loading = useAppConfig(__assign({ navigation: PASSWORD_SCREENS_NAVIGATION }, props)).loading;
32
+ useErrorListener();
32
33
  var activeScreen = data.activeScreen;
34
+ var verifyToken = function () {
35
+ var token = getParameterByName('token');
36
+ if (!token)
37
+ throw new Error('Auth token is not found!');
38
+ dispatch(verifyLeadToken(token));
39
+ };
33
40
  useEffect(function () {
34
- dispatch(handleActiveFlowScreens(PASSWORD_SCREENS_NAVIGATION));
35
- }, []);
41
+ if (!loading)
42
+ verifyToken();
43
+ }, [loading]);
36
44
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: passwordFeatureScreens.map(function (_a, index) {
37
45
  var Element = _a.element, name = _a.name;
38
46
  var isActive = activeScreen.name === name;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,42 @@
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
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ var BoxStyled = styled(Box)(function (_a) {
21
+ var theme = _a.theme;
22
+ return ({
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ fontFamily: theme.typography.fontFamily
26
+ });
27
+ });
28
+ var OTPInput = function (_a) {
29
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
30
+ var t = useTranslation().t;
31
+ var otpControl = useController({ name: 'otp', control: control });
32
+ var handleOnOTPChange = function (otp) {
33
+ otpControl.field.onChange(otp);
34
+ };
35
+ var handleOnResendOTP = function () {
36
+ if (otpControl.field.value)
37
+ setValue('otp', '', { shouldValidate: true });
38
+ };
39
+ var otpValue = otpControl.field.value;
40
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
41
+ };
42
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,78 @@
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
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { useAppDispatch } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useSelector } from 'react-redux';
17
+ import { useForm, FormProvider } from 'react-hook-form';
18
+ import { yupResolver } from '@hookform/resolvers/yup';
19
+ import Box from '@mui/material/Box/Box';
20
+ import { styled } from '@mui/material/styles';
21
+ import { handlePrevScreenStep } from '../../../../app/settings';
22
+ import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
24
+ import Form from '../../../../components/Form';
25
+ import Text from '../../../../components/Text';
26
+ import { ScreenContainer } from '../../../shared/Containers';
27
+ import { passwordSelector, clearError, resetOTPScreen, verifyPasswordLeadOTP } from '../../../app/password/passwordStore';
28
+ import Button from '../../../shared/Button';
29
+ import { OTPValidation } from './validation';
30
+ import OTPInput from './OTPInput';
31
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ background: theme.palette.common.white,
35
+ border: '1px solid',
36
+ borderColor: theme.palette.divider,
37
+ direction: theme.direction,
38
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
39
+ marginBottom: theme.spacing(5.75)
40
+ });
41
+ });
42
+ var OTPTitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.75 }));
45
+ });
46
+ var FormStyled = styled(Form)(function () { return ({
47
+ display: 'flex',
48
+ flexDirection: 'column'
49
+ }); });
50
+ var VerifyNumber = function (_a) {
51
+ var _b, _c, _d;
52
+ var dispatch = useAppDispatch();
53
+ var _e = useSelector(passwordSelector), data = _e.data, loading = _e.loading, error = _e.error;
54
+ var methods = useForm({
55
+ resolver: yupResolver(OTPValidation),
56
+ defaultValues: data.otpData,
57
+ mode: 'onChange'
58
+ });
59
+ var t = useTranslation().t;
60
+ var isAr = useLanguage().isAr;
61
+ React.useEffect(function () {
62
+ if (error)
63
+ dispatch(clearError());
64
+ return function () {
65
+ dispatch(resetOTPScreen());
66
+ };
67
+ }, [methods.formState.isValid]);
68
+ var onSubmit = function (formData) {
69
+ dispatch(verifyPasswordLeadOTP(formData));
70
+ };
71
+ var onBack = function () {
72
+ dispatch(handlePrevScreenStep());
73
+ };
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
+ var disabled = !methods.formState.isValid || !!error || !phone;
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, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, type: 'submit', isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
77
+ };
78
+ export default React.memo(VerifyNumber);
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- export interface TaxLibProps {
2
+ import { LibConfig } from '../../@types';
3
+ export interface TaxLibProps extends LibConfig {
3
4
  }
4
5
  export declare function TaxLib(props: TaxLibProps): JSX.Element;
5
6
  export declare function renderTaxLib(config: TaxLibProps, elementId: string): void;
@@ -11,28 +11,36 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React, { memo, useEffect } from 'react';
14
- import { useTranslation } from 'react-i18next';
15
- import { useAppTheme, useAppDispatch, useAppSelector } from '../../hooks';
16
- import { handleActiveFlowScreens, settingsSelector } from '../../app/settings';
14
+ import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener } from '../../hooks';
15
+ import { settingsSelector } from '../../app/settings';
17
16
  import AnimationFlow from '../../components/AnimationFlow';
18
17
  import { store } from '../../app/store';
19
18
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
19
  import Collapse from '../../components/Collapse';
21
- import { reactElement } from '../../utils';
20
+ import { getParameterByName, reactElement } from '../../utils';
22
21
  import { FeatureContainer } from '../shared/Containers';
23
22
  import { TAX_SCREENS_NAVIGATION } from '../../constants';
24
23
  import { taxFeatureScreens } from '../featuresScreens';
25
24
  import CustomFooter from '../shared/Footer';
25
+ import { verifyLeadToken } from '../app/tax/taxStore';
26
26
  var Tax = memo(function (props) {
27
27
  var open = React.useState(true)[0];
28
- var t = useTranslation().t;
29
28
  var theme = useAppTheme().theme;
30
29
  var dispatch = useAppDispatch();
31
30
  var data = useAppSelector(settingsSelector).data;
31
+ var loading = useAppConfig(__assign({ navigation: TAX_SCREENS_NAVIGATION }, props)).loading;
32
+ useErrorListener();
32
33
  var activeScreen = data.activeScreen;
34
+ var verifyToken = function () {
35
+ var token = getParameterByName('token');
36
+ if (!token)
37
+ throw new Error('Auth token is not found!');
38
+ dispatch(verifyLeadToken(token));
39
+ };
33
40
  useEffect(function () {
34
- dispatch(handleActiveFlowScreens(TAX_SCREENS_NAVIGATION));
35
- }, []);
41
+ if (!loading)
42
+ verifyToken();
43
+ }, [loading]);
36
44
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: taxFeatureScreens.map(function (_a, index) {
37
45
  var Element = _a.element, name = _a.name;
38
46
  var isActive = activeScreen.name === name;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,42 @@
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
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ var BoxStyled = styled(Box)(function (_a) {
21
+ var theme = _a.theme;
22
+ return ({
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ fontFamily: theme.typography.fontFamily
26
+ });
27
+ });
28
+ var OTPInput = function (_a) {
29
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
30
+ var t = useTranslation().t;
31
+ var otpControl = useController({ name: 'otp', control: control });
32
+ var handleOnOTPChange = function (otp) {
33
+ otpControl.field.onChange(otp);
34
+ };
35
+ var handleOnResendOTP = function () {
36
+ if (otpControl.field.value)
37
+ setValue('otp', '', { shouldValidate: true });
38
+ };
39
+ var otpValue = otpControl.field.value;
40
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
41
+ };
42
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,78 @@
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
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { useAppDispatch } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useSelector } from 'react-redux';
17
+ import { useForm, FormProvider } from 'react-hook-form';
18
+ import { yupResolver } from '@hookform/resolvers/yup';
19
+ import Box from '@mui/material/Box/Box';
20
+ import { styled } from '@mui/material/styles';
21
+ import { handlePrevScreenStep } from '../../../../app/settings';
22
+ import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
24
+ import Form from '../../../../components/Form';
25
+ import Text from '../../../../components/Text';
26
+ import { ScreenContainer } from '../../../shared/Containers';
27
+ import { taxSelector, clearError, resetOTPScreen, verifyTaxLeadOTP } from '../../../app/tax/taxStore';
28
+ import Button from '../../../shared/Button';
29
+ import { OTPValidation } from './validation';
30
+ import OTPInput from './OTPInput';
31
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ background: theme.palette.common.white,
35
+ border: '1px solid',
36
+ borderColor: theme.palette.divider,
37
+ direction: theme.direction,
38
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
39
+ marginBottom: theme.spacing(5.75)
40
+ });
41
+ });
42
+ var OTPTitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.75 }));
45
+ });
46
+ var FormStyled = styled(Form)(function () { return ({
47
+ display: 'flex',
48
+ flexDirection: 'column'
49
+ }); });
50
+ var VerifyNumber = function (_a) {
51
+ var _b, _c, _d;
52
+ var dispatch = useAppDispatch();
53
+ var _e = useSelector(taxSelector), data = _e.data, loading = _e.loading, error = _e.error;
54
+ var methods = useForm({
55
+ resolver: yupResolver(OTPValidation),
56
+ defaultValues: data.otpData,
57
+ mode: 'onChange'
58
+ });
59
+ var t = useTranslation().t;
60
+ var isAr = useLanguage().isAr;
61
+ React.useEffect(function () {
62
+ if (error)
63
+ dispatch(clearError());
64
+ return function () {
65
+ dispatch(resetOTPScreen());
66
+ };
67
+ }, [methods.formState.isValid]);
68
+ var onSubmit = function (formData) {
69
+ dispatch(verifyTaxLeadOTP(formData));
70
+ };
71
+ var onBack = function () {
72
+ dispatch(handlePrevScreenStep());
73
+ };
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
+ var disabled = !methods.formState.isValid || !!error || !phone;
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, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, type: 'submit', isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
77
+ };
78
+ export default React.memo(VerifyNumber);
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
@@ -2,4 +2,8 @@ export declare const useAppDispatch: () => import("redux-thunk").ThunkDispatch<{
2
2
  settings: import("../app/settings").SettingsState;
3
3
  connect: import("../features/app/connect/connectStore").ConnectState;
4
4
  business: import("../features/app/business/businessStore").BusinessState;
5
+ bank: import("../features/app/bank/bankStore").BankState;
6
+ tax: import("../features/app/tax/taxStore").TaxState;
7
+ individual: import("../features/app/individual/individualStore").IndividualState;
8
+ password: import("../features/app/password/passwordStore").PasswordState;
5
9
  }, undefined, import("redux").AnyAction> & import("redux").Dispatch<import("redux").AnyAction>;
@@ -60,7 +60,6 @@ export var capitalizeTheFirstLetterOfEachWord = function (words) {
60
60
  return separateWord.join(' ');
61
61
  };
62
62
  export var getRequestHeaders = function (deviceInfo) {
63
- console.log(deviceInfo);
64
63
  var app = deviceInfo.app, browser = deviceInfo.browser, connection = deviceInfo.connection, device = deviceInfo.device, source = deviceInfo.source;
65
64
  return {
66
65
  al: encryptString(app.language || ''),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.50",
3
+ "version": "1.0.53",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",