@tap-payments/auth-jsconnect 1.1.5-test → 1.1.7-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 (103) hide show
  1. package/README.md +2 -2
  2. package/build/@types/app.d.ts +2 -1
  3. package/build/@types/form.d.ts +3 -0
  4. package/build/@types/redux.d.ts +0 -1
  5. package/build/api/account.d.ts +1 -2
  6. package/build/api/account.js +7 -3
  7. package/build/api/axios.d.ts +1 -0
  8. package/build/api/axios.js +3 -0
  9. package/build/api/board.d.ts +25 -0
  10. package/build/api/board.js +49 -0
  11. package/build/api/brand.d.ts +7 -0
  12. package/build/api/brand.js +40 -0
  13. package/build/api/entity.js +2 -2
  14. package/build/api/index.d.ts +21 -7
  15. package/build/api/index.js +9 -3
  16. package/build/api/individual.d.ts +25 -2
  17. package/build/api/individual.js +1 -5
  18. package/build/api/lead.d.ts +1 -5
  19. package/build/api/lead.js +10 -5
  20. package/build/api/user.d.ts +8 -0
  21. package/build/api/user.js +12 -0
  22. package/build/app/rootReducer.d.ts +1 -0
  23. package/build/app/rootReducer.js +3 -1
  24. package/build/app/store.d.ts +2 -0
  25. package/build/assets/locales/ar.json +2 -1
  26. package/build/assets/locales/en.json +2 -1
  27. package/build/components/AnimationFlow/Loader.js +17 -9
  28. package/build/components/FileInput/DragAndDrop.js +1 -1
  29. package/build/constants/api.d.ts +4 -1
  30. package/build/constants/api.js +14 -8
  31. package/build/constants/app.d.ts +10 -1
  32. package/build/constants/app.js +35 -1
  33. package/build/constants/validation.d.ts +1 -0
  34. package/build/constants/validation.js +2 -1
  35. package/build/features/app/bank/bankStore.d.ts +3 -2
  36. package/build/features/app/bank/bankStore.js +45 -36
  37. package/build/features/app/business/businessStore.d.ts +6 -3
  38. package/build/features/app/business/businessStore.js +204 -125
  39. package/build/features/app/connect/connectStore.d.ts +2 -1
  40. package/build/features/app/connect/connectStore.js +84 -62
  41. package/build/features/app/individual/individualStore.d.ts +3 -10
  42. package/build/features/app/individual/individualStore.js +69 -93
  43. package/build/features/app/password/passwordStore.d.ts +7 -5
  44. package/build/features/app/password/passwordStore.js +70 -54
  45. package/build/features/app/signIn/signInStore.d.ts +33 -0
  46. package/build/features/app/signIn/signInStore.js +390 -0
  47. package/build/features/app/tax/taxStore.d.ts +2 -1
  48. package/build/features/app/tax/taxStore.js +44 -39
  49. package/build/features/bank/screens/Success/Success.js +2 -2
  50. package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
  51. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  52. package/build/features/connect/screens/Merchant/BrandName.js +2 -6
  53. package/build/features/connect/screens/Merchant/validation.js +1 -1
  54. package/build/features/featuresScreens.d.ts +1 -0
  55. package/build/features/featuresScreens.js +22 -0
  56. package/build/features/individual/screens/Success/Success.js +2 -2
  57. package/build/features/password/Password.js +2 -2
  58. package/build/features/password/screens/Success/Success.js +2 -2
  59. package/build/features/shared/UploadFile/UploadFile.js +8 -7
  60. package/build/features/signIn/SignIn.d.ts +7 -0
  61. package/build/features/signIn/SignIn.js +49 -0
  62. package/build/features/signIn/index.d.ts +1 -0
  63. package/build/features/signIn/index.js +1 -0
  64. package/build/features/signIn/screens/Email/Email.d.ts +5 -0
  65. package/build/features/signIn/screens/Email/Email.js +95 -0
  66. package/build/features/signIn/screens/Email/EmailField.d.ts +5 -0
  67. package/build/features/signIn/screens/Email/EmailField.js +55 -0
  68. package/build/features/signIn/screens/Email/index.d.ts +3 -0
  69. package/build/features/signIn/screens/Email/index.js +2 -0
  70. package/build/features/signIn/screens/Email/validation.d.ts +8 -0
  71. package/build/features/signIn/screens/Email/validation.js +5 -0
  72. package/build/features/signIn/screens/Mobile/Mobile.d.ts +5 -0
  73. package/build/features/signIn/screens/Mobile/Mobile.js +106 -0
  74. package/build/features/signIn/screens/Mobile/MobileNumber.d.ts +11 -0
  75. package/build/features/signIn/screens/Mobile/MobileNumber.js +151 -0
  76. package/build/features/signIn/screens/Mobile/index.d.ts +3 -0
  77. package/build/features/signIn/screens/Mobile/index.js +2 -0
  78. package/build/features/signIn/screens/Mobile/validation.d.ts +8 -0
  79. package/build/features/signIn/screens/Mobile/validation.js +28 -0
  80. package/build/features/signIn/screens/OTP/OTP.d.ts +5 -0
  81. package/build/features/signIn/screens/OTP/OTP.js +80 -0
  82. package/build/features/signIn/screens/OTP/OTPInput.d.ts +5 -0
  83. package/build/features/signIn/screens/OTP/OTPInput.js +53 -0
  84. package/build/features/signIn/screens/OTP/index.d.ts +3 -0
  85. package/build/features/signIn/screens/OTP/index.js +2 -0
  86. package/build/features/signIn/screens/OTP/validation.d.ts +8 -0
  87. package/build/features/signIn/screens/OTP/validation.js +4 -0
  88. package/build/features/signIn/screens/Password/Password.d.ts +5 -0
  89. package/build/features/signIn/screens/Password/Password.js +54 -0
  90. package/build/features/signIn/screens/Password/PasswordInput.d.ts +5 -0
  91. package/build/features/signIn/screens/Password/PasswordInput.js +28 -0
  92. package/build/features/signIn/screens/Password/index.d.ts +3 -0
  93. package/build/features/signIn/screens/Password/index.js +2 -0
  94. package/build/features/signIn/screens/Password/validation.d.ts +8 -0
  95. package/build/features/signIn/screens/Password/validation.js +4 -0
  96. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +1 -1
  97. package/build/hooks/useAppDispatch.d.ts +1 -0
  98. package/build/index.css +1 -0
  99. package/build/index.d.ts +3 -2
  100. package/build/index.js +5 -2
  101. package/build/utils/string.d.ts +3 -1
  102. package/build/utils/string.js +11 -2
  103. package/package.json +1 -1
@@ -34,6 +34,10 @@ import TaxDetailsPage from './tax/screens/TaxDetails';
34
34
  import TaxSuccessPage from './tax/screens/Success';
35
35
  import TaxSuccessWithFlowPage from './tax/screens/SuccessWithFlowButtons';
36
36
  import TaxResetPasswordSuccessPage from './tax/screens/ResetPasswordSuccess';
37
+ import SignInMobilePage from './signIn/screens/Mobile';
38
+ import SignInEmailPage from './signIn/screens/Email';
39
+ import SignInOTPPage from './signIn/screens/OTP';
40
+ import SignInPasswordPage from './signIn/screens/Password';
37
41
  export var connectFeatureScreens = [
38
42
  {
39
43
  name: 'CONNECT_NID_STEP',
@@ -169,3 +173,21 @@ export var taxFeatureScreens = [
169
173
  },
170
174
  { name: 'TAX_RESET_PASSWORD_SUCCESS', element: TaxResetPasswordSuccessPage }
171
175
  ];
176
+ export var signInFeatureScreens = [
177
+ {
178
+ name: 'SIGIN_MOBILE_STEP',
179
+ element: SignInMobilePage
180
+ },
181
+ {
182
+ name: 'SIGIN_EMAIL_STEP',
183
+ element: SignInEmailPage
184
+ },
185
+ {
186
+ name: 'SIGIN_OTP_STEP',
187
+ element: SignInOTPPage
188
+ },
189
+ {
190
+ name: 'SIGIN_PASSWORD_STEP',
191
+ element: SignInPasswordPage
192
+ }
193
+ ];
@@ -2,14 +2,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
5
- import { individualSelector, updateLeadSuccess } from '../../../app/individual/individualStore';
5
+ import { individualSelector, updateBoardSuccess } from '../../../app/individual/individualStore';
6
6
  import SuccessScreen from '../../../shared/SuccessScreen';
7
7
  var Success = function (_a) {
8
8
  var t = useTranslation().t;
9
9
  var dispatch = useAppDispatch();
10
10
  var _b = useAppSelector(individualSelector), loading = _b.loading, error = _b.error;
11
11
  var onSuccess = function () {
12
- dispatch(updateLeadSuccess());
12
+ dispatch(updateBoardSuccess());
13
13
  };
14
14
  return (_jsx(SuccessScreen, { title: t('individual_success_title'), onSuccess: onSuccess, successTitle: t('continue'), loading: loading, error: error || '' }));
15
15
  };
@@ -37,13 +37,13 @@ var Password = memo(function (props) {
37
37
  var token = getParameterByName('token');
38
38
  var lang = getParameterByName('lang');
39
39
  var operationType = getParameterByName('operation_type');
40
- var leadId = getParameterByName('lead_id') || '';
40
+ var boardId = getParameterByName('board_id') || '';
41
41
  if (lang)
42
42
  dispatch(handleLanguage(lang));
43
43
  if (!token)
44
44
  throw new Error('Auth token is not found!');
45
45
  if (operationType === PASSWORD_OPERATION_TYPE.RESET_PASSWORD) {
46
- dispatch(verifyOperationToken({ token: token, leadId: leadId }));
46
+ dispatch(verifyOperationToken({ token: token, boardId: boardId }));
47
47
  return;
48
48
  }
49
49
  dispatch(verifyLeadToken(token));
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
5
- import { updateLeadSuccess, passwordSelector, retrieveLeadPassword } from '../../../app/password/passwordStore';
5
+ import { updateBoardSuccess, passwordSelector, retrieveLeadPassword } from '../../../app/password/passwordStore';
6
6
  import SuccessScreen from '../../../shared/SuccessScreen';
7
7
  import { PASSWORD_OPERATION_TYPE } from '../../../../constants';
8
8
  var Success = function (_a) {
@@ -15,7 +15,7 @@ var Success = function (_a) {
15
15
  dispatch(retrieveLeadPassword());
16
16
  return;
17
17
  }
18
- dispatch(updateLeadSuccess());
18
+ dispatch(updateBoardSuccess());
19
19
  };
20
20
  return (_jsx(SuccessScreen, { title: t('password_success_title'), onSuccess: onSuccess, successTitle: t('continue'), loading: loading, error: error || '' }));
21
21
  };
@@ -19,8 +19,7 @@ import Mandatory from '../../shared/Mandatory';
19
19
  import { DragAndDrop, UploadInput } from '../../../components/FileInput';
20
20
  import Collapse from '../../../components/Collapse';
21
21
  import Warning from '../../../components/Warning';
22
- import Icon from '../../../components/Icon';
23
- import { ICONS_NAMES } from '../../../constants';
22
+ import ClearIcon from '@mui/icons-material/Clear';
24
23
  var FeatureStyled = styled(ScreenContainer)(function (_a) {
25
24
  var theme = _a.theme;
26
25
  return ({
@@ -43,12 +42,14 @@ var UploadBoxStyled = styled(Box)(function (_a) {
43
42
  var theme = _a.theme;
44
43
  return (__assign(__assign({}, theme.typography.caption), { background: theme.palette.primary.main, color: theme.palette.common.white, fontWeight: theme.typography.fontWeightRegular, padding: theme.spacing(0.75, 1.75, 0), cursor: 'pointer', width: '15%', display: 'flex', justifyContent: 'center' }));
45
44
  });
46
- var IconStyled = styled(Icon)(function (_a) {
45
+ var ClearIconStyled = styled(ClearIcon)(function (_a) {
47
46
  var theme = _a.theme;
48
47
  return ({
49
- marginBlockStart: theme.spacing(0),
50
- width: theme.spacing(3.5),
51
- height: theme.spacing(3.5)
48
+ marginBlockStart: theme.spacing(0.25),
49
+ width: theme.spacing(3),
50
+ height: theme.spacing(3),
51
+ cursor: 'pointer',
52
+ color: theme.palette.common.white
52
53
  });
53
54
  });
54
55
  export var InputContainerStyled = styled(Box)(function (_a) {
@@ -71,6 +72,6 @@ var UploadFile = function (_a) {
71
72
  onReset === null || onReset === void 0 ? void 0 : onReset();
72
73
  }
73
74
  };
74
- return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {})] }), _jsx(Collapse, __assign({ in: !fileName }, { children: _jsxs(InputContainerStyled, { children: [_jsx(DragAndDrop, { title: dragTitle, onSuccess: handleFileChange }), _jsx(UploadInput, { title: uploadTitle, onChange: handleFileChange })] }) })), _jsx(Collapse, __assign({ in: !!fileName }, { children: _jsxs(InputContainerStyled, { children: [_jsx(BoxStyled, { children: fileName }), _jsx(UploadBoxStyled, __assign({ onClick: handleReset }, { children: _jsx(IconStyled, { src: ICONS_NAMES.DELETE_ICON }) }))] }) })), _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: error })) }))] }));
75
+ return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {})] }), _jsx(Collapse, __assign({ in: !fileName }, { children: _jsxs(InputContainerStyled, { children: [_jsx(DragAndDrop, { title: dragTitle, onSuccess: handleFileChange }), _jsx(UploadInput, { title: uploadTitle, onChange: handleFileChange })] }) })), _jsx(Collapse, __assign({ in: !!fileName }, { children: _jsxs(InputContainerStyled, { children: [_jsx(BoxStyled, { children: fileName }), _jsx(UploadBoxStyled, __assign({ onClick: handleReset }, { children: _jsx(ClearIconStyled, {}) }))] }) })), _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: error })) }))] }));
75
76
  };
76
77
  export default UploadFile;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { LibConfig } from '../../@types';
3
+ export interface SignInLibProps extends LibConfig {
4
+ }
5
+ export declare function SignInLib(props: SignInLibProps): JSX.Element;
6
+ export declare function renderSignInLib(config: SignInLibProps, elementId: string): void;
7
+ export declare function unmountSignInLib(elementId: string): void;
@@ -0,0 +1,49 @@
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 { memo } from 'react';
14
+ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener } from '../../hooks';
15
+ import { settingsSelector } from '../../app/settings';
16
+ import AnimationFlow from '../../components/AnimationFlow';
17
+ import { store } from '../../app/store';
18
+ import { ReduxProvider, ThemeProvider } from '../../components/Providers';
19
+ import Collapse from '../../components/Collapse';
20
+ import { reactElement } from '../../utils';
21
+ import { FeatureContainer } from '../shared/Containers';
22
+ import { SigIn_SCREENS_NAVIGATION } from '../../constants';
23
+ import { signInFeatureScreens } from '../featuresScreens';
24
+ import CustomFooter from '../shared/Footer';
25
+ import { signInSelector } from '../app/signIn/signInStore';
26
+ import Background from '../shared/Background';
27
+ var SignIn = memo(function (props) {
28
+ var theme = useAppTheme().theme;
29
+ var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, loading = _a.loading;
30
+ var signInError = useAppSelector(signInSelector).error;
31
+ useAppConfig(__assign({ navigation: SigIn_SCREENS_NAVIGATION }, props));
32
+ useErrorListener(signInError || error);
33
+ useStepStartedListener();
34
+ var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
35
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: loading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, open: open, error: error, loading: loading, breakpoint: 'sm', footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: signInFeatureScreens.map(function (_a, index) {
36
+ var Element = _a.element, name = _a.name;
37
+ var isActive = activeScreen.name === name;
38
+ return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
39
+ }) }) })) })) })));
40
+ });
41
+ export function SignInLib(props) {
42
+ return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(SignIn, __assign({}, props)) })));
43
+ }
44
+ export function renderSignInLib(config, elementId) {
45
+ reactElement(elementId).render(_jsx(SignInLib, __assign({}, config)));
46
+ }
47
+ export function unmountSignInLib(elementId) {
48
+ reactElement(elementId).unmount();
49
+ }
@@ -0,0 +1 @@
1
+ export * from './SignIn';
@@ -0,0 +1 @@
1
+ export * from './SignIn';
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface EmailProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: EmailProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,95 @@
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 { useTranslation } from 'react-i18next';
15
+ import { alpha, styled } from '@mui/material/styles';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
19
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
20
+ import { clearError, signInSelector, createEmailAuth } from '../../../app/signIn/signInStore';
21
+ import Form from '../../../../components/Form';
22
+ import Button, { MobileButton } from '../../../shared/Button';
23
+ import { ScreenContainer } from '../../../shared/Containers';
24
+ import Collapse from '../../../../components/Collapse';
25
+ import Box from '@mui/material/Box';
26
+ import Divider from '@mui/material/Divider';
27
+ import Text from '../../../../components/Text';
28
+ import EmailField from './EmailField';
29
+ import { EmailValidationSchema } from './validation';
30
+ var FormStyled = styled(Form)(function () { return ({
31
+ display: 'flex',
32
+ flexDirection: 'column'
33
+ }); });
34
+ var TextStyled = styled(Text)(function (_a) {
35
+ var theme = _a.theme;
36
+ return ({
37
+ color: alpha(theme.palette.primary.dark, 0.4)
38
+ });
39
+ });
40
+ var DividerStyled = styled(Divider)(function (_a) {
41
+ var theme = _a.theme;
42
+ return ({
43
+ width: '45%',
44
+ borderColor: alpha(theme.palette.primary.dark, 0.4),
45
+ marginBlockEnd: theme.spacing(0.62)
46
+ });
47
+ });
48
+ var OrBoxStyled = styled(Box)(function (_a) {
49
+ var theme = _a.theme;
50
+ return ({
51
+ display: 'flex',
52
+ justifyContent: 'space-between',
53
+ marginBlockEnd: theme.spacing(1.62),
54
+ marginBlockStart: theme.spacing(-1.25),
55
+ marginInline: theme.spacing(2.5)
56
+ });
57
+ });
58
+ var InputsContainerStyled = styled(Box, {
59
+ shouldForwardProp: function (prop) { return prop !== 'showMobileButton'; }
60
+ })(function (_a) {
61
+ var theme = _a.theme, showMobileButton = _a.showMobileButton;
62
+ return ({
63
+ transition: 'padding-bottom 0.3s',
64
+ paddingBottom: showMobileButton ? theme.spacing(0) : theme.spacing(7.5)
65
+ });
66
+ });
67
+ var Email = function (_a) {
68
+ var isAr = useLanguage().isAr;
69
+ var dispatch = useAppDispatch();
70
+ var t = useTranslation().t;
71
+ var _b = useAppSelector(signInSelector), data = _b.data, loading = _b.loading, error = _b.error;
72
+ var settingsStore = useAppSelector(settingsSelector);
73
+ var methods = useForm({
74
+ resolver: yupResolver(EmailValidationSchema),
75
+ defaultValues: { email: data.auth.email || '' },
76
+ mode: 'onChange'
77
+ });
78
+ React.useEffect(function () {
79
+ handleClearError();
80
+ }, [methods.formState.isValid]);
81
+ var onSubmit = function (data) {
82
+ dispatch(createEmailAuth(data));
83
+ };
84
+ var handleClearError = function () {
85
+ if (error)
86
+ dispatch(clearError());
87
+ };
88
+ var onBack = function () {
89
+ dispatch(handlePrevScreenStep());
90
+ };
91
+ var disabled = !methods.formState.isValid || !!error;
92
+ var showMobileButton = !methods.formState.isValid;
93
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, __assign({ showMobileButton: showMobileButton }, { children: _jsx(EmailField, {}) })), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: showMobileButton }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading }, { children: t('mobile_button_label') }))] }))] })) })) }));
94
+ };
95
+ export default React.memo(Email);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ interface EmailFieldProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<EmailFieldProps & React.RefAttributes<unknown>>>;
5
+ export default _default;
@@ -0,0 +1,55 @@
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 Box from '@mui/material/Box';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useController, useFormContext } from 'react-hook-form';
17
+ import { styled, alpha } from '@mui/material/styles';
18
+ import Text from '../../../../components/Text';
19
+ import Input from '../../../shared/Input';
20
+ import ClearIcon from '../../../shared/ClearIcon';
21
+ import CheckIcon from '../../../shared/CheckIcon';
22
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
23
+ var LabelContainerStyled = styled(Box)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ justifyContent: 'space-between',
28
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
29
+ });
30
+ });
31
+ var InputLabelStyled = styled(Text)(function (_a) {
32
+ var theme = _a.theme;
33
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
34
+ });
35
+ var EmailField = React.forwardRef(function (_a, ref) {
36
+ var _b;
37
+ var t = useTranslation().t;
38
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
39
+ var emailControl = useController({ control: control, name: 'email' });
40
+ React.useEffect(function () {
41
+ if (emailControl.field.value)
42
+ setValue('email', emailControl.field.value, { shouldValidate: true });
43
+ }, []);
44
+ var handleEmailChange = function (_a) {
45
+ var target = _a.target;
46
+ emailControl.field.onChange(target === null || target === void 0 ? void 0 : target.value);
47
+ };
48
+ var clearEmail = function () {
49
+ emailControl.field.onChange('');
50
+ };
51
+ var emailValue = emailControl.field.value;
52
+ var error = (_b = emailControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
53
+ return (_jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signin_email_label') }) }), _jsx(Input, { type: 'text', onChange: handleEmailChange, value: emailValue, endAdornment: !error && emailValue ? _jsx(CheckIcon, {}) : emailValue && _jsx(ClearIcon, { onClick: clearEmail }), placeholder: t('signin_email_placeholder'), warningType: 'alert', warningMessage: error && t(error, { number: '1' }), required: true })] })));
54
+ });
55
+ export default React.memo(EmailField);
@@ -0,0 +1,3 @@
1
+ import Email, { EmailProps } from './Email';
2
+ export type { EmailProps };
3
+ export default Email;
@@ -0,0 +1,2 @@
1
+ import Email from './Email';
2
+ export default Email;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const EmailValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ email: 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
+ email: 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
+ email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,5 @@
1
+ import * as yup from 'yup';
2
+ import { EMAIL_MAX_LENGTH } from '../../../../constants';
3
+ export var EmailValidationSchema = yup.object().shape({
4
+ email: yup.string().max(EMAIL_MAX_LENGTH).email('email_not_valid').required('email_not_valid')
5
+ });
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface MobileProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: MobileProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,106 @@
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 Box from '@mui/material/Box';
15
+ import { useForm, FormProvider } from 'react-hook-form';
16
+ import { yupResolver } from '@hookform/resolvers/yup';
17
+ import { useTranslation } from 'react-i18next';
18
+ import { styled, alpha } from '@mui/material/styles';
19
+ import Collapse from '../../../../components/Collapse';
20
+ import Form from '../../../../components/Form';
21
+ import Button, { MobileButton } from '../../../shared/Button';
22
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
23
+ import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
24
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
25
+ import { clearError, createMobileAuth, signInSelector } from '../../../app/signIn/signInStore';
26
+ import { useLanguage } from '../../../../hooks';
27
+ import Divider from '@mui/material/Divider';
28
+ import Text from '../../../../components/Text';
29
+ import MobileNumber from './MobileNumber';
30
+ import { PhoneValidationSchema } from './validation';
31
+ var FormStyled = styled(Form)(function () { return ({
32
+ display: 'flex',
33
+ flexDirection: 'column'
34
+ }); });
35
+ var InputsContainerStyled = styled(Box)(function (_a) {
36
+ var _b;
37
+ var theme = _a.theme;
38
+ return (_b = {},
39
+ _b[theme.transitions.create(['padding-bottom'])] = {
40
+ duration: theme.transitions.duration.standard
41
+ },
42
+ _b);
43
+ });
44
+ var TextStyled = styled(Text)(function (_a) {
45
+ var theme = _a.theme;
46
+ return ({
47
+ color: alpha(theme.palette.primary.dark, 0.4)
48
+ });
49
+ });
50
+ var DividerStyled = styled(Divider)(function (_a) {
51
+ var theme = _a.theme;
52
+ return ({
53
+ width: '45%',
54
+ borderColor: alpha(theme.palette.primary.dark, 0.4),
55
+ marginBlockEnd: theme.spacing(0.62)
56
+ });
57
+ });
58
+ var OrBoxStyled = styled(Box)(function (_a) {
59
+ var theme = _a.theme;
60
+ return ({
61
+ display: 'flex',
62
+ justifyContent: 'space-between',
63
+ marginBlockEnd: theme.spacing(1.62),
64
+ marginBlockStart: theme.spacing(-1.25),
65
+ marginInline: theme.spacing(2.5)
66
+ });
67
+ });
68
+ var ListType;
69
+ (function (ListType) {
70
+ ListType["CountryCodeList"] = "CountryCodeList";
71
+ })(ListType || (ListType = {}));
72
+ var Mobile = function (_a) {
73
+ var settingsStore = useAppSelector(settingsSelector);
74
+ var _b = useAppSelector(signInSelector), data = _b.data, loading = _b.loading, error = _b.error;
75
+ var _c = React.useState(), listType = _c[0], setListType = _c[1];
76
+ var dispatch = useAppDispatch();
77
+ var methods = useForm({
78
+ resolver: yupResolver(PhoneValidationSchema),
79
+ defaultValues: { mobile: data.auth.mobile || '', countryCode: data.auth.countryCode },
80
+ mode: 'onChange'
81
+ });
82
+ var t = useTranslation().t;
83
+ var isAr = useLanguage().isAr;
84
+ var handleMenuListClick = function (flag) {
85
+ setListType(flag);
86
+ };
87
+ React.useEffect(function () {
88
+ if (data.auth.countryCode) {
89
+ methods.setValue('countryCode', data.auth.countryCode);
90
+ }
91
+ }, [data.auth]);
92
+ React.useEffect(function () {
93
+ if (error)
94
+ dispatch(clearError());
95
+ }, [methods.formState.isValid]);
96
+ var onSubmit = function (data) {
97
+ dispatch(createMobileAuth(data));
98
+ };
99
+ var onBack = function () {
100
+ dispatch(handlePrevScreenStep());
101
+ };
102
+ var listActive = listType === ListType.CountryCodeList;
103
+ var disabled = !methods.formState.isValid || !!error;
104
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { countries: settingsStore.data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } }) }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, loading: loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: !methods.formState.isValid }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ disabled: settingsStore.loading || loading, onClick: function () { return onBack(); } }, { children: t('email_button_label') }))] }))] }))] })) })) }));
105
+ };
106
+ export default React.memo(Mobile);
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { CountryCode } from '../../../../@types';
3
+ interface MobileNumberProps {
4
+ countries: Array<CountryCode>;
5
+ setMobileLength?: (length: number) => void;
6
+ onSwitchToIdNumber?: () => void;
7
+ onListOpen?: () => void;
8
+ onListClose?: () => void;
9
+ }
10
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<MobileNumberProps & React.RefAttributes<unknown>>>;
11
+ export default _default;