@tap-payments/auth-jsconnect 2.0.7 → 2.0.9

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 (84) hide show
  1. package/build/@types/form.d.ts +4 -0
  2. package/build/@types/redux.d.ts +0 -1
  3. package/build/api/entity.d.ts +4 -3
  4. package/build/api/entity.js +8 -1
  5. package/build/api/index.d.ts +2 -0
  6. package/build/api/individual.d.ts +1 -0
  7. package/build/api/individual.js +9 -2
  8. package/build/app/rootReducer.d.ts +1 -0
  9. package/build/app/rootReducer.js +3 -1
  10. package/build/app/store.d.ts +2 -0
  11. package/build/assets/locales/ar.json +2 -1
  12. package/build/assets/locales/en.json +2 -1
  13. package/build/components/FileInput/DragAndDrop.js +1 -2
  14. package/build/constants/app.d.ts +9 -0
  15. package/build/constants/app.js +36 -0
  16. package/build/constants/validation.d.ts +2 -0
  17. package/build/constants/validation.js +2 -0
  18. package/build/features/app/bank/bankStore.d.ts +1 -1
  19. package/build/features/app/bank/bankStore.js +23 -42
  20. package/build/features/app/business/businessStore.d.ts +5 -3
  21. package/build/features/app/business/businessStore.js +55 -31
  22. package/build/features/app/connect/connectStore.d.ts +2 -1
  23. package/build/features/app/connect/connectStore.js +78 -47
  24. package/build/features/app/individual/individualStore.d.ts +9 -2
  25. package/build/features/app/individual/individualStore.js +80 -41
  26. package/build/features/app/password/passwordStore.d.ts +1 -0
  27. package/build/features/app/password/passwordStore.js +3 -7
  28. package/build/features/app/signIn/signInStore.d.ts +33 -0
  29. package/build/features/app/signIn/signInStore.js +389 -0
  30. package/build/features/app/tax/taxStore.d.ts +1 -0
  31. package/build/features/bank/screens/BankDetails/BankStatement.js +6 -17
  32. package/build/features/bank/screens/BankDetails/validation.d.ts +3 -0
  33. package/build/features/bank/screens/BankDetails/validation.js +11 -1
  34. package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
  35. package/build/features/business/screens/Customers/CustomerLocations.d.ts +2 -2
  36. package/build/features/connect/screens/Merchant/Merchant.js +3 -2
  37. package/build/features/connect/screens/Merchant/validation.js +1 -1
  38. package/build/features/featuresScreens.d.ts +1 -0
  39. package/build/features/featuresScreens.js +22 -0
  40. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +19 -5
  41. package/build/features/shared/UploadFile/UploadFile.d.ts +2 -2
  42. package/build/features/shared/UploadFile/UploadFile.js +13 -13
  43. package/build/features/signIn/SignIn.d.ts +7 -0
  44. package/build/features/signIn/SignIn.js +49 -0
  45. package/build/features/signIn/index.d.ts +1 -0
  46. package/build/features/signIn/index.js +1 -0
  47. package/build/features/signIn/screens/Email/Email.d.ts +5 -0
  48. package/build/features/signIn/screens/Email/Email.js +95 -0
  49. package/build/features/signIn/screens/Email/EmailField.d.ts +5 -0
  50. package/build/features/signIn/screens/Email/EmailField.js +55 -0
  51. package/build/features/signIn/screens/Email/index.d.ts +3 -0
  52. package/build/features/signIn/screens/Email/index.js +2 -0
  53. package/build/features/signIn/screens/Email/validation.d.ts +8 -0
  54. package/build/features/signIn/screens/Email/validation.js +5 -0
  55. package/build/features/signIn/screens/Mobile/Mobile.d.ts +5 -0
  56. package/build/features/signIn/screens/Mobile/Mobile.js +106 -0
  57. package/build/features/signIn/screens/Mobile/MobileNumber.d.ts +11 -0
  58. package/build/features/signIn/screens/Mobile/MobileNumber.js +151 -0
  59. package/build/features/signIn/screens/Mobile/index.d.ts +3 -0
  60. package/build/features/signIn/screens/Mobile/index.js +2 -0
  61. package/build/features/signIn/screens/Mobile/validation.d.ts +8 -0
  62. package/build/features/signIn/screens/Mobile/validation.js +28 -0
  63. package/build/features/signIn/screens/OTP/OTP.d.ts +5 -0
  64. package/build/features/signIn/screens/OTP/OTP.js +80 -0
  65. package/build/features/signIn/screens/OTP/OTPInput.d.ts +5 -0
  66. package/build/features/signIn/screens/OTP/OTPInput.js +53 -0
  67. package/build/features/signIn/screens/OTP/index.d.ts +3 -0
  68. package/build/features/signIn/screens/OTP/index.js +2 -0
  69. package/build/features/signIn/screens/OTP/validation.d.ts +8 -0
  70. package/build/features/signIn/screens/OTP/validation.js +4 -0
  71. package/build/features/signIn/screens/Password/Password.d.ts +5 -0
  72. package/build/features/signIn/screens/Password/Password.js +54 -0
  73. package/build/features/signIn/screens/Password/PasswordInput.d.ts +5 -0
  74. package/build/features/signIn/screens/Password/PasswordInput.js +28 -0
  75. package/build/features/signIn/screens/Password/index.d.ts +3 -0
  76. package/build/features/signIn/screens/Password/index.js +2 -0
  77. package/build/features/signIn/screens/Password/validation.d.ts +8 -0
  78. package/build/features/signIn/screens/Password/validation.js +4 -0
  79. package/build/hooks/useAppDispatch.d.ts +1 -0
  80. package/build/index.d.ts +3 -2
  81. package/build/index.js +5 -2
  82. package/build/utils/string.d.ts +1 -0
  83. package/build/utils/string.js +4 -0
  84. package/package.json +1 -1
@@ -19,10 +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';
24
- import { useTranslation } from 'react-i18next';
25
- import Loader from '../../../components/Loader';
22
+ import ClearIcon from '@mui/icons-material/Clear';
26
23
  var FeatureStyled = styled(ScreenContainer)(function (_a) {
27
24
  var theme = _a.theme;
28
25
  return ({
@@ -45,12 +42,14 @@ var UploadBoxStyled = styled(Box)(function (_a) {
45
42
  var theme = _a.theme;
46
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' }));
47
44
  });
48
- var IconStyled = styled(Icon)(function (_a) {
45
+ var ClearIconStyled = styled(ClearIcon)(function (_a) {
49
46
  var theme = _a.theme;
50
47
  return ({
51
- marginBlockStart: theme.spacing(0),
52
- width: theme.spacing(3.5),
53
- 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
54
53
  });
55
54
  });
56
55
  export var InputContainerStyled = styled(Box)(function (_a) {
@@ -61,17 +60,18 @@ export var InputContainerStyled = styled(Box)(function (_a) {
61
60
  });
62
61
  });
63
62
  var UploadFile = function (_a) {
64
- var label = _a.label, required = _a.required, dragTitle = _a.dragTitle, uploadTitle = _a.uploadTitle, loading = _a.loading, error = _a.error, onFileUploaded = _a.onFileUploaded, onReset = _a.onReset;
63
+ var label = _a.label, required = _a.required, dragTitle = _a.dragTitle, uploadTitle = _a.uploadTitle, isSubmitting = _a.isSubmitting, error = _a.error, onFileUploaded = _a.onFileUploaded, onReset = _a.onReset;
65
64
  var _b = React.useState(''), fileName = _b[0], setFileName = _b[1];
66
- var t = useTranslation().t;
67
65
  var handleFileChange = function (file) {
68
66
  setFileName(file === null || file === void 0 ? void 0 : file.name);
69
67
  onFileUploaded === null || onFileUploaded === void 0 ? void 0 : onFileUploaded(file);
70
68
  };
71
69
  var handleReset = function () {
72
- setFileName('');
73
- onReset === null || onReset === void 0 ? void 0 : onReset();
70
+ if (!isSubmitting) {
71
+ setFileName('');
72
+ onReset === null || onReset === void 0 ? void 0 : onReset();
73
+ }
74
74
  };
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: loading ? t('loading_bank_statement') : fileName }), _jsxs(UploadBoxStyled, __assign({ onClick: handleReset }, { children: [_jsx(Collapse, __assign({ in: !loading }, { children: _jsx(IconStyled, { src: ICONS_NAMES.DELETE_ICON }) })), _jsx(Collapse, __assign({ in: loading }, { children: _jsx(Loader, { innerColor: 'white', outerColor: 'white', toggleAnimation: true, style: { width: 30, height: 30 }, svgStyle: { width: 30, height: 30 } }) }))] }))] }) })), _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 })) }))] }));
76
76
  };
77
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;
@@ -0,0 +1,151 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
24
+ import * as React from 'react';
25
+ import Box from '@mui/material/Box';
26
+ import { useTranslation } from 'react-i18next';
27
+ import { useController, useFormContext } from 'react-hook-form';
28
+ import { styled, alpha } from '@mui/material/styles';
29
+ import Text from '../../../../components/Text';
30
+ import Collapse from '../../../../components/Collapse';
31
+ import ClearIcon from '../../../shared/ClearIcon';
32
+ import CheckIcon from '../../../shared/CheckIcon';
33
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
34
+ import { signInSelector } from '../../../app/signIn/signInStore';
35
+ import ExpandIcon from '../../../../components/ExpandIcon';
36
+ import Input from '../../../shared/Input';
37
+ import SimpleList from '../../../../components/SimpleList';
38
+ import { removeAllCharsFromNumber } from '../../../../utils';
39
+ import { useLanguage, useAppSelector } from '../../../../hooks';
40
+ import Search from '../../../shared/Search';
41
+ var LabelContainerStyled = styled(Box)(function (_a) {
42
+ var theme = _a.theme;
43
+ return ({
44
+ display: 'flex',
45
+ justifyContent: 'space-between',
46
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
47
+ });
48
+ });
49
+ var CountryItemContainer = styled(Box)(function () { return ({
50
+ display: 'flex'
51
+ }); });
52
+ var CountryCodeText = styled(Text, {
53
+ shouldForwardProp: function (prop) { return prop !== 'isSelected'; }
54
+ })(function (_a) {
55
+ var theme = _a.theme, isSelected = _a.isSelected;
56
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { width: theme.spacing(10), textAlign: 'start', fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
57
+ });
58
+ var CountryNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
59
+ var theme = _a.theme, isSelected = _a.isSelected;
60
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25) }));
61
+ });
62
+ var CountryCodeStyled = styled(Text)(function (_a) {
63
+ var theme = _a.theme;
64
+ return (__assign(__assign({ cursor: 'pointer' }, theme.typography.body2), { fontWeight: theme.typography.fontWeightRegular, display: 'flex', alignItems: 'center', minWidth: theme.spacing(8.75) }));
65
+ });
66
+ var InputLabelStyled = styled(Text)(function (_a) {
67
+ var theme = _a.theme;
68
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
69
+ });
70
+ var ExpandIconStyled = styled(ExpandIcon)(function (_a) {
71
+ var theme = _a.theme;
72
+ return ({
73
+ marginInlineStart: theme.spacing(1)
74
+ });
75
+ });
76
+ var InputStyled = styled(Input)(function () { return ({
77
+ direction: 'ltr',
78
+ '& .MuiInputBase-input': {
79
+ cursor: 'auto'
80
+ }
81
+ }); });
82
+ var MobileNumber = React.forwardRef(function (_a, ref) {
83
+ var _b, _c, _d;
84
+ var countries = _a.countries, rest = __rest(_a, ["countries"]);
85
+ var _e = React.useState(countries || []), countriesCode = _e[0], setCountries = _e[1];
86
+ var _f = React.useState(null), anchorEl = _f[0], setAnchorEl = _f[1];
87
+ var t = useTranslation().t;
88
+ var isAr = useLanguage().isAr;
89
+ var _g = useFormContext(), control = _g.control, setValue = _g.setValue;
90
+ var loading = useAppSelector(signInSelector).loading;
91
+ var phoneControl = useController({ name: 'mobile', control: control });
92
+ var countryCodeControl = useController({ name: 'countryCode', control: control });
93
+ var countryCodeValue = countryCodeControl.field.value;
94
+ var mobileValue = phoneControl.field.value || '';
95
+ var countryName = (isAr ? (_b = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _b === void 0 ? void 0 : _b.arabic : (_c = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _c === void 0 ? void 0 : _c.english) || '';
96
+ var error = !!mobileValue ? (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message : '';
97
+ var isSA = countryCodeValue.iso2 === 'SA';
98
+ var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
99
+ var isStartsWith5 = mobileValue.startsWith('5');
100
+ var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
101
+ React.useEffect(function () {
102
+ if (mobileValue)
103
+ setValue('mobile', mobileValue, { shouldValidate: true });
104
+ }, []);
105
+ var onPhoneNumberChange = function (_a) {
106
+ var target = _a.target;
107
+ var value = removeAllCharsFromNumber(target.value);
108
+ phoneControl.field.onChange(value);
109
+ };
110
+ var clearMobileNumber = function () {
111
+ phoneControl.field.onChange('');
112
+ };
113
+ var onCloseCountryList = function () {
114
+ var _a;
115
+ if (anchorEl) {
116
+ setAnchorEl(null);
117
+ (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
118
+ }
119
+ setCountries(countries);
120
+ };
121
+ var toggleCountryList = function () {
122
+ var _a, _b;
123
+ if (anchorEl) {
124
+ setAnchorEl(null);
125
+ (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
126
+ setCountries(countries);
127
+ }
128
+ else {
129
+ (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
130
+ setAnchorEl(true);
131
+ }
132
+ };
133
+ var onSelectItem = function (country) {
134
+ onCloseCountryList();
135
+ setValue('mobile', '');
136
+ countryCodeControl.field.onChange(country);
137
+ };
138
+ var handleSearch = function (value) {
139
+ var filteredCountries = countries.filter(function (country) {
140
+ return country.idd_prefix.toString().toLowerCase().startsWith(value.replace('+', '').toLowerCase()) ||
141
+ country.capital.toLowerCase().startsWith(value.toLowerCase()) ||
142
+ country.name.arabic.toLowerCase().startsWith(value.toLowerCase()) ||
143
+ country.name.english.toLowerCase().startsWith(value.toLowerCase());
144
+ });
145
+ setCountries(filteredCountries);
146
+ };
147
+ return (_jsxs(ScreenContainer, __assign({ ref: ref, sx: { minHeight: mobileValue ? '133px' : '0px' } }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(InputStyled, { inputProps: { maxLength: requiredLen }, type: 'tel', readOnly: !!anchorEl, required: true, onClick: onCloseCountryList, onChange: onPhoneNumberChange, onEnterPressed: function (e) { return loading && e.preventDefault(); }, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: !anchorEl ? error && t(error, { length: requiredLen, number: '05|5' }) : undefined }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
148
+ return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsxs(CountryCodeText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: ["+", item.idd_prefix] })), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) && _jsx(CheckIcon, {})] }));
149
+ } })] }))] })));
150
+ });
151
+ export default React.memo(MobileNumber);
@@ -0,0 +1,3 @@
1
+ import Mobile, { MobileProps } from './Mobile';
2
+ export type { MobileProps };
3
+ export default Mobile;
@@ -0,0 +1,2 @@
1
+ import Mobile from './Mobile';
2
+ export default Mobile;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const PhoneValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ mobile: 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
+ mobile: 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
+ mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,28 @@
1
+ import * as yup from 'yup';
2
+ export var PhoneValidationSchema = yup.object().shape({
3
+ mobile: yup
4
+ .string()
5
+ .test({
6
+ test: function (value) {
7
+ var countryCode = this.parent.countryCode;
8
+ var isSA = countryCode.iso2 === 'SA';
9
+ var digits = countryCode.digits;
10
+ var mobileValue = value || '';
11
+ var valueLen = mobileValue.length;
12
+ var isNumber = mobileValue.match(/^[0-9]/g);
13
+ if (!isNumber)
14
+ return this.createError({ message: 'enter_valid_mobile_number' });
15
+ var isStartWithZero = mobileValue.startsWith('05');
16
+ var isStartWith5 = mobileValue.startsWith('5');
17
+ var isSaudiNumber = isStartWith5 || isStartWithZero;
18
+ if (isSA) {
19
+ if (!isSaudiNumber)
20
+ return this.createError({ message: 'start_with_number' });
21
+ var requiredLen = isStartWith5 ? digits - 1 : digits;
22
+ return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
23
+ }
24
+ return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
25
+ }
26
+ })
27
+ .required('mobile_number_error')
28
+ });