@tap-payments/auth-jsconnect 1.0.57 → 1.0.61

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 (65) hide show
  1. package/build/@types/form.d.ts +2 -2
  2. package/build/api/entity.d.ts +20 -0
  3. package/build/api/entity.js +5 -1
  4. package/build/api/index.d.ts +3 -2
  5. package/build/assets/locales/ar.json +13 -1
  6. package/build/assets/locales/en.json +13 -1
  7. package/build/constants/api.d.ts +1 -0
  8. package/build/constants/api.js +3 -1
  9. package/build/constants/app.js +18 -18
  10. package/build/constants/assets.d.ts +7 -0
  11. package/build/constants/assets.js +8 -1
  12. package/build/features/Landing/Landing.js +5 -8
  13. package/build/features/Landing/screens/VerifyAndRedirect/VerifyAndRedirect.js +6 -20
  14. package/build/features/app/bank/bankStore.d.ts +5 -3
  15. package/build/features/app/bank/bankStore.js +81 -16
  16. package/build/features/app/business/businessStore.js +15 -17
  17. package/build/features/app/connect/connectStore.js +27 -19
  18. package/build/features/app/individual/individualStore.d.ts +4 -0
  19. package/build/features/app/individual/individualStore.js +80 -18
  20. package/build/features/bank/screens/BankDetails/BankDetails.js +7 -9
  21. package/build/features/bank/screens/BankDetails/Beneficiary.js +9 -1
  22. package/build/features/bank/screens/Success/Success.js +6 -0
  23. package/build/features/business/screens/BusinessType/LicenseNumber.js +1 -1
  24. package/build/features/business/screens/Success/Success.js +3 -2
  25. package/build/features/business/screens/{Confirm/Confirm.d.ts → SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts} +1 -3
  26. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +79 -0
  27. package/build/features/business/screens/SuccessWithFlowButtons/index.d.ts +2 -0
  28. package/build/features/business/screens/SuccessWithFlowButtons/index.js +2 -0
  29. package/build/features/connect/screens/ThankYou/ThankYou.js +1 -4
  30. package/build/features/featuresScreens.js +3 -6
  31. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +18 -15
  32. package/build/features/individual/screens/AdditionalIndividualInfo/EmployerName.js +10 -1
  33. package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +1 -1
  34. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +2 -2
  35. package/build/features/individual/screens/Success/Success.js +6 -0
  36. package/build/features/shared/Button/EmailProvidersButtons.d.ts +13 -0
  37. package/build/features/shared/Button/EmailProvidersButtons.js +92 -0
  38. package/build/features/shared/Button/FlowsButtons.d.ts +12 -0
  39. package/build/features/shared/Button/FlowsButtons.js +57 -0
  40. package/build/features/shared/Button/index.d.ts +3 -1
  41. package/build/features/shared/Button/index.js +3 -1
  42. package/build/features/shared/SuccessScreen/SuccessScreen.d.ts +4 -2
  43. package/build/features/shared/SuccessScreen/SuccessScreen.js +4 -4
  44. package/package.json +1 -1
  45. package/build/features/business/screens/BusinessType/CRNumber.d.ts +0 -7
  46. package/build/features/business/screens/BusinessType/CRNumber.js +0 -41
  47. package/build/features/business/screens/BusinessType/CompanyLicense.d.ts +0 -11
  48. package/build/features/business/screens/BusinessType/CompanyLicense.js +0 -127
  49. package/build/features/business/screens/BusinessType/FLNumber.d.ts +0 -7
  50. package/build/features/business/screens/BusinessType/FLNumber.js +0 -41
  51. package/build/features/business/screens/BusinessType/FreelanceLicense.d.ts +0 -11
  52. package/build/features/business/screens/BusinessType/FreelanceLicense.js +0 -127
  53. package/build/features/business/screens/Confirm/Confirm.js +0 -56
  54. package/build/features/business/screens/Confirm/index.d.ts +0 -3
  55. package/build/features/business/screens/Confirm/index.js +0 -2
  56. package/build/features/connect/screens/Mobile/BusinessCountry.d.ts +0 -8
  57. package/build/features/connect/screens/Mobile/BusinessCountry.js +0 -40
  58. package/build/features/connect/screens/Password/Password.d.ts +0 -5
  59. package/build/features/connect/screens/Password/Password.js +0 -60
  60. package/build/features/connect/screens/Password/PasswordInput.d.ts +0 -5
  61. package/build/features/connect/screens/Password/PasswordInput.js +0 -39
  62. package/build/features/connect/screens/Password/index.d.ts +0 -3
  63. package/build/features/connect/screens/Password/index.js +0 -2
  64. package/build/features/connect/screens/Password/validation.d.ts +0 -8
  65. package/build/features/connect/screens/Password/validation.js +0 -4
@@ -5,7 +5,7 @@ export var IndividualInfoValidationSchema = yup.object().shape({
5
5
  monthlyIncome: yup.string().optional(),
6
6
  employerName: yup.string().when('sourceIncome', function (sourceIncomeValue) {
7
7
  var _a;
8
- if (((_a = sourceIncomeValue === null || sourceIncomeValue === void 0 ? void 0 : sourceIncomeValue.nameEn) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'salary') {
8
+ if (((_a = sourceIncomeValue === null || sourceIncomeValue === void 0 ? void 0 : sourceIncomeValue.title) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'salary') {
9
9
  return yup.string().matches(REGEX_FULL_NAME, 'employer_name_invalid').required('please_enter_employer_name');
10
10
  }
11
11
  else {
@@ -14,7 +14,7 @@ export var IndividualInfoValidationSchema = yup.object().shape({
14
14
  }),
15
15
  employerLocation: yup.object().when('sourceIncome', function (sourceIncome) {
16
16
  var _a;
17
- if (((_a = sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome.nameEn) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'salary') {
17
+ if (((_a = sourceIncome === null || sourceIncome === void 0 ? void 0 : sourceIncome.title) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'salary') {
18
18
  return yup
19
19
  .object({
20
20
  name: yup.object().shape({
@@ -1,9 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
+ import { useAppDispatch } from '../../../../hooks';
5
+ import { updateLeadSuccess } from '../../../app/individual/individualStore';
4
6
  import SuccessScreen from '../../../shared/SuccessScreen';
5
7
  var Success = function (_a) {
6
8
  var t = useTranslation().t;
9
+ var dispatch = useAppDispatch();
10
+ React.useEffect(function () {
11
+ dispatch(updateLeadSuccess());
12
+ }, []);
7
13
  var onSuccess = function () {
8
14
  window.open('mailto:');
9
15
  };
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '../../../components/Button';
3
+ declare type buttonProps = {
4
+ title: string;
5
+ href: string;
6
+ };
7
+ export interface EmailProvidersButtonsProps extends ButtonProps {
8
+ gmail: buttonProps;
9
+ outlook: buttonProps;
10
+ apple: buttonProps;
11
+ }
12
+ export default function EmailProvidersButtons({ gmail, outlook, apple }: EmailProvidersButtonsProps): JSX.Element;
13
+ export {};
@@ -0,0 +1,92 @@
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 Button from '../../../components/Button';
14
+ import { alpha, styled } from '@mui/material/styles';
15
+ import Box from '@mui/material/Box';
16
+ import Link from '@mui/material/Link';
17
+ import { ICONS_NAMES } from '../../../constants';
18
+ var Image = styled('img')(function (_a) {
19
+ var theme = _a.theme;
20
+ return ({
21
+ width: theme.spacing(3),
22
+ height: theme.spacing(3),
23
+ fontSize: theme.spacing(3),
24
+ marginInlineStart: theme.spacing(1)
25
+ });
26
+ });
27
+ var ButtonBoxStyled = styled(Box)(function (_a) {
28
+ var theme = _a.theme;
29
+ return ({
30
+ margin: theme.spacing(0, 2.5, 2.5, 2.5)
31
+ });
32
+ });
33
+ var GMailButtonStyled = styled(Button)(function (_a) {
34
+ var theme = _a.theme;
35
+ return ({
36
+ width: '100%',
37
+ paddingInlineStart: theme.spacing(0.75),
38
+ marginBottom: theme.spacing(1.875),
39
+ backgroundColor: theme.palette.common.white,
40
+ border: "1px solid ".concat(theme.palette.primary.main),
41
+ color: theme.palette.primary.main,
42
+ '&:hover': {
43
+ backgroundColor: theme.palette.primary.main,
44
+ color: theme.palette.common.white
45
+ },
46
+ '&:disabled': {
47
+ backgroundColor: theme.palette.common.white,
48
+ color: alpha(theme.palette.primary.main, 0.3)
49
+ }
50
+ });
51
+ });
52
+ var OutlookButtonStyled = styled(Button)(function (_a) {
53
+ var theme = _a.theme;
54
+ return ({
55
+ width: '100%',
56
+ paddingInlineStart: theme.spacing(0.75),
57
+ marginBottom: theme.spacing(1.875),
58
+ backgroundColor: theme.palette.common.white,
59
+ border: "1px solid ".concat(theme.palette.primary.main),
60
+ color: theme.palette.primary.main,
61
+ '&:hover': {
62
+ backgroundColor: theme.palette.primary.main,
63
+ color: theme.palette.common.white
64
+ },
65
+ '&:disabled': {
66
+ backgroundColor: theme.palette.common.white,
67
+ color: alpha(theme.palette.primary.main, 0.3)
68
+ }
69
+ });
70
+ });
71
+ var AppleButtonStyled = styled(Button)(function (_a) {
72
+ var theme = _a.theme;
73
+ return ({
74
+ width: '100%',
75
+ paddingInlineStart: theme.spacing(0.75),
76
+ backgroundColor: theme.palette.common.white,
77
+ border: "1px solid ".concat(theme.palette.primary.main),
78
+ color: theme.palette.primary.main,
79
+ '&:hover': {
80
+ backgroundColor: theme.palette.primary.main,
81
+ color: theme.palette.common.white
82
+ },
83
+ '&:disabled': {
84
+ backgroundColor: theme.palette.common.white,
85
+ color: alpha(theme.palette.primary.main, 0.3)
86
+ }
87
+ });
88
+ });
89
+ export default function EmailProvidersButtons(_a) {
90
+ var gmail = _a.gmail, outlook = _a.outlook, apple = _a.apple;
91
+ return (_jsxs(ButtonBoxStyled, { children: [_jsx(Link, __assign({ href: gmail.href, underline: 'none', target: '_blank' }, { children: _jsx(GMailButtonStyled, __assign({ startIcon: _jsx(Image, { src: ICONS_NAMES.GMAIL_ICON, alt: gmail.title }), type: 'button' }, { children: gmail.title })) })), _jsx(Link, __assign({ href: outlook.href, underline: 'none', target: '_blank' }, { children: _jsx(OutlookButtonStyled, __assign({ startIcon: _jsx(Image, { src: ICONS_NAMES.OUTLOOK_ICON, alt: outlook.title }), type: 'button' }, { children: outlook.title })) })), _jsx(Link, __assign({ href: apple.href, underline: 'none', target: '_blank' }, { children: _jsx(AppleButtonStyled, __assign({ startIcon: _jsx(Image, { src: ICONS_NAMES.APPLE_MAIL_ICON, alt: apple.title }), type: 'button' }, { children: apple.title })) }))] }));
92
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from '../../../components/Button';
3
+ declare type buttonProps = {
4
+ title: string;
5
+ href: string;
6
+ src: string;
7
+ };
8
+ export interface EmailProvidersButtonsProps extends ButtonProps {
9
+ buttons: buttonProps[];
10
+ }
11
+ export default function FlowsButtons({ buttons }: EmailProvidersButtonsProps): JSX.Element;
12
+ export {};
@@ -0,0 +1,57 @@
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 Button from '../../../components/Button';
14
+ import { alpha, styled } from '@mui/material/styles';
15
+ import Box from '@mui/material/Box';
16
+ import Link from '@mui/material/Link';
17
+ var Image = styled('img')(function (_a) {
18
+ var theme = _a.theme;
19
+ return ({
20
+ width: theme.spacing(3),
21
+ height: theme.spacing(3),
22
+ fontSize: theme.spacing(3),
23
+ marginInlineStart: theme.spacing(1)
24
+ });
25
+ });
26
+ var ButtonBoxStyled = styled(Box)(function (_a) {
27
+ var theme = _a.theme;
28
+ return ({
29
+ margin: theme.spacing(0, 2.5, 2.5, 2.5)
30
+ });
31
+ });
32
+ var ButtonStyled = styled(Button)(function (_a) {
33
+ var theme = _a.theme;
34
+ return ({
35
+ width: '100%',
36
+ paddingInlineStart: theme.spacing(0.75),
37
+ backgroundColor: theme.palette.common.white,
38
+ border: "1px solid ".concat(theme.palette.primary.main),
39
+ color: theme.palette.primary.main,
40
+ '&:hover': {
41
+ backgroundColor: theme.palette.primary.main,
42
+ color: theme.palette.common.white
43
+ },
44
+ '&:disabled': {
45
+ backgroundColor: theme.palette.common.white,
46
+ color: alpha(theme.palette.primary.main, 0.3)
47
+ }
48
+ });
49
+ });
50
+ export default function FlowsButtons(_a) {
51
+ var buttons = _a.buttons;
52
+ return (_jsx(ButtonBoxStyled, { children: buttons.map(function (_a, index) {
53
+ var title = _a.title, href = _a.href, src = _a.src;
54
+ var isLast = index === buttons.length - 1;
55
+ return (_jsx(Link, __assign({ href: href, underline: 'none', target: '_blank' }, { children: _jsx(ButtonStyled, __assign({ sx: { mb: isLast ? 0 : 1.8 }, startIcon: _jsx(Image, { src: src, alt: title }), type: 'button' }, { children: title })) }), index));
56
+ }) }));
57
+ }
@@ -1,5 +1,7 @@
1
1
  import Button from './Button';
2
2
  import AbsherButton from './AbsherButton';
3
3
  import MobileButton from './MobileButton';
4
- export { AbsherButton, MobileButton };
4
+ import EmailProvidersButton from './EmailProvidersButtons';
5
+ import FlowsButtons from './FlowsButtons';
6
+ export { AbsherButton, MobileButton, EmailProvidersButton, FlowsButtons };
5
7
  export default Button;
@@ -1,5 +1,7 @@
1
1
  import Button from './Button';
2
2
  import AbsherButton from './AbsherButton';
3
3
  import MobileButton from './MobileButton';
4
- export { AbsherButton, MobileButton };
4
+ import EmailProvidersButton from './EmailProvidersButtons';
5
+ import FlowsButtons from './FlowsButtons';
6
+ export { AbsherButton, MobileButton, EmailProvidersButton, FlowsButtons };
5
7
  export default Button;
@@ -1,7 +1,9 @@
1
1
  import * as React from 'react';
2
2
  export interface ThankYouProps {
3
- onSuccess?: () => void;
4
3
  title?: string;
4
+ onSuccess?: () => void;
5
+ showEmailProviders?: boolean;
6
+ successTitle?: string;
5
7
  }
6
- declare const _default: React.MemoExoticComponent<({ onSuccess, title }: ThankYouProps) => JSX.Element>;
8
+ declare const _default: React.MemoExoticComponent<({ title, showEmailProviders, onSuccess, successTitle }: ThankYouProps) => JSX.Element>;
7
9
  export default _default;
@@ -14,12 +14,12 @@ import Box from '@mui/material/Box/Box';
14
14
  import { styled } from '@mui/material/styles';
15
15
  import * as React from 'react';
16
16
  import { useTranslation } from 'react-i18next';
17
- import { useLanguage } from '../../../hooks';
18
17
  import Text from '../../../components/Text';
19
18
  import Container from '../Containers/ScreenContainer';
20
- import { AbsherButton } from '../../shared/Button';
19
+ import { AbsherButton, EmailProvidersButton } from '../../shared/Button';
21
20
  import Icon from '../../../components/Icon';
22
21
  import { ICONS_NAMES } from '../../../constants';
22
+ import { useLanguage } from '../../../hooks';
23
23
  var MailBoxStyled = styled(Box)(function () { return ({
24
24
  width: '100%'
25
25
  }); });
@@ -64,9 +64,9 @@ var IconStyled = styled(Icon)(function (_a) {
64
64
  _b);
65
65
  });
66
66
  var ThankYou = function (_a) {
67
- var onSuccess = _a.onSuccess, title = _a.title;
67
+ var title = _a.title, showEmailProviders = _a.showEmailProviders, onSuccess = _a.onSuccess, successTitle = _a.successTitle;
68
68
  var t = useTranslation().t;
69
69
  var isAr = useLanguage().isAr;
70
- return (_jsxs(ContainerStyled, { children: [title && (_jsx(TextContainerStyled, { children: _jsxs(TitleStyled, { children: [title, " "] }) })), _jsx(IconStyled, { src: ICONS_NAMES.EMAIL_ICON, alt: 'loading...' }), _jsx(MailBoxStyled, { children: _jsx(AbsherButton, __assign({ hideIcon: true, isAr: isAr, onClick: onSuccess }, { children: t('open_mail_box') })) })] }));
70
+ return (_jsxs(ContainerStyled, { children: [title && (_jsx(TextContainerStyled, { children: _jsxs(TitleStyled, { children: [title, " "] }) })), _jsx(IconStyled, { src: ICONS_NAMES.EMAIL_ICON, alt: 'loading...' }), showEmailProviders && (_jsx(MailBoxStyled, { children: _jsx(EmailProvidersButton, { gmail: { title: t('open_gmail'), href: 'https://mail.google.com/mail/u/0/#inbox' }, outlook: { title: t('open_outlook'), href: 'https://outlook.live.com/mail/0/' }, apple: { title: t('open_apple'), href: 'https://www.icloud.com/mail/' } }) })), onSuccess && !showEmailProviders && (_jsx(MailBoxStyled, { children: _jsx(AbsherButton, __assign({ hideIcon: true, isAr: isAr, onClick: onSuccess }, { children: t(successTitle || 'open_mail_box') })) }))] }));
71
71
  };
72
72
  export default React.memo(ThankYou);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.57",
3
+ "version": "1.0.61",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- interface CRNumberProps {
3
- show: boolean;
4
- readOnly: boolean;
5
- }
6
- declare const _default: React.MemoExoticComponent<({ show, readOnly }: CRNumberProps) => JSX.Element>;
7
- export default _default;
@@ -1,41 +0,0 @@
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 { useTranslation } from 'react-i18next';
15
- import { useController, useFormContext } from 'react-hook-form';
16
- import { CR_NUMBER_LENGTH } from '../../../../constants';
17
- import { removeAllCharsFromNumber } from '../../../../utils';
18
- import ScreenContainer from '../../../shared/Containers/ScreenContainer';
19
- import ClearIcon from '../../../shared/ClearIcon';
20
- import CheckIcon from '../../../shared/CheckIcon';
21
- import Input from '../../../shared/Input';
22
- import Collapse from '../../../../components/Collapse';
23
- var CRNumber = function (_a) {
24
- var _b;
25
- var show = _a.show, readOnly = _a.readOnly;
26
- var t = useTranslation().t;
27
- var control = useFormContext().control;
28
- var crNumberControl = useController({ control: control, name: 'crNumber' });
29
- var handleFLNumberChange = function (_a) {
30
- var target = _a.target;
31
- var value = removeAllCharsFromNumber(target.value);
32
- crNumberControl.field.onChange(value);
33
- };
34
- var clearCRNumber = function () {
35
- crNumberControl.field.onChange('');
36
- };
37
- var crNumberValue = crNumberControl.field.value;
38
- var error = (_b = crNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
39
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t('enter_commercial_register_no'), onChange: handleFLNumberChange, inputProps: { maxLength: CR_NUMBER_LENGTH }, value: crNumberValue, endAdornment: (crNumberValue === null || crNumberValue === void 0 ? void 0 : crNumberValue.length) === CR_NUMBER_LENGTH ? (_jsx(CheckIcon, {})) : (crNumberValue && _jsx(ClearIcon, { onClick: clearCRNumber })), placeholder: '0123456789', warningType: 'alert', warningMessage: error && t(error, { length: CR_NUMBER_LENGTH }) }) }) })));
40
- };
41
- export default React.memo(CRNumber);
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- import { License } from '../../../../@types';
3
- interface CompanyLicenseProps {
4
- show: boolean;
5
- list: Array<License>;
6
- onSelectLicense?: (number: string) => void;
7
- onListOpen?: () => void;
8
- onListClose?: () => void;
9
- }
10
- declare const _default: React.MemoExoticComponent<({ show, list, ...rest }: CompanyLicenseProps) => JSX.Element>;
11
- export default _default;
@@ -1,127 +0,0 @@
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
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
- if (ar || !(i in from)) {
26
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
- ar[i] = from[i];
28
- }
29
- }
30
- return to.concat(ar || Array.prototype.slice.call(from));
31
- };
32
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
33
- import * as React from 'react';
34
- import { useTranslation } from 'react-i18next';
35
- import { useFormContext } from 'react-hook-form';
36
- import Box from '@mui/material/Box';
37
- import { styled } from '@mui/material/styles';
38
- import { useLanguage } from '../../../../hooks';
39
- import ScreenContainer from '../../../shared/Containers/ScreenContainer';
40
- import Input from '../../../shared/Input';
41
- import CheckIcon from '../../../shared/CheckIcon';
42
- import SimpleList from '../../../../components/SimpleList';
43
- import Text from '../../../../components/Text';
44
- import ExpandIcon from '../../../../components/ExpandIcon';
45
- import Collapse from '../../../../components/Collapse';
46
- import { OTHER_LICENSE } from '../../../../constants';
47
- import CRNumber from './CRNumber';
48
- var InputStyled = styled(Input)(function (_a) {
49
- var theme = _a.theme;
50
- return ({
51
- marginBottom: theme.spacing(2.5),
52
- '& .MuiInputBase-input': {
53
- cursor: 'pointer'
54
- }
55
- });
56
- });
57
- var LicenseContainer = styled(Box)(function () { return ({
58
- display: 'flex'
59
- }); });
60
- var LicenseNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
61
- var theme = _a.theme, isSelected = _a.isSelected;
62
- return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
63
- });
64
- var CompanyLicense = function (_a) {
65
- var show = _a.show, list = _a.list, rest = __rest(_a, ["show", "list"]);
66
- var _b = React.useState(list), licenseList = _b[0], setLicenseList = _b[1];
67
- var _c = React.useState(), selectedLicense = _c[0], setSelectedLicense = _c[1];
68
- var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
69
- var t = useTranslation().t;
70
- var isAr = useLanguage().isAr;
71
- var setValue = useFormContext().setValue;
72
- var onOpenLicenseList = function (event) {
73
- var _a;
74
- setAnchorEl(event.currentTarget);
75
- (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
76
- };
77
- var onCloseLicenseList = function () {
78
- var _a;
79
- setAnchorEl(null);
80
- (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
81
- };
82
- React.useEffect(function () {
83
- var array = list;
84
- if ((array === null || array === void 0 ? void 0 : array.length) > 0) {
85
- var hasOther = array === null || array === void 0 ? void 0 : array.find(function (item) { return isOtherLicense(item); });
86
- var first = array[0];
87
- if (first) {
88
- setSelectedLicense(first);
89
- setValue('crNumber', getLicenseNumber(first), { shouldValidate: true });
90
- if (!hasOther)
91
- array = __spreadArray(__spreadArray([], array, true), [OTHER_LICENSE], false);
92
- setLicenseList(array);
93
- }
94
- }
95
- }, [show, list]);
96
- var getLicenseNumber = function (item) {
97
- var _a;
98
- return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
99
- };
100
- var getLicenseName = function (item) {
101
- var _a, _b;
102
- return (isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '';
103
- };
104
- var isOtherLicense = function (item) {
105
- var _a;
106
- return ((_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.en) === 'other';
107
- };
108
- var onSelectItem = function (license) {
109
- setSelectedLicense(license);
110
- onCloseLicenseList();
111
- if (isOtherLicense(license))
112
- setValue('crNumber', '');
113
- else
114
- setValue('crNumber', getLicenseNumber(license), { shouldValidate: true });
115
- };
116
- var hasList = (licenseList === null || licenseList === void 0 ? void 0 : licenseList.length) > 0;
117
- var showCRNumber = !anchorEl;
118
- var crReadonly = !isOtherLicense(selectedLicense);
119
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: hasList }, { children: [_jsx(InputStyled, { label: t('enter_commercial_register_no'), readOnly: true, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: t(getLicenseName(selectedLicense)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList, onSelectItem: onSelectItem, renderItem: function (item) {
120
- return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selectedLicense) }, { children: isOtherLicense(item)
121
- ? t(getLicenseNumber(item))
122
- : isAr
123
- ? getLicenseName(item)
124
- : getLicenseNumber(item) + '-' + getLicenseName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selectedLicense) && _jsx(CheckIcon, {})] }));
125
- } }) }))] })), _jsx(CRNumber, { show: showCRNumber, readOnly: crReadonly })] }) })));
126
- };
127
- export default React.memo(CompanyLicense);
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- interface FLNumberProps {
3
- show: boolean;
4
- readOnly: boolean;
5
- }
6
- declare const _default: React.MemoExoticComponent<({ show, readOnly }: FLNumberProps) => JSX.Element>;
7
- export default _default;
@@ -1,41 +0,0 @@
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 { useTranslation } from 'react-i18next';
15
- import { useController, useFormContext } from 'react-hook-form';
16
- import { FL_NUMBER_LENGTH } from '../../../../constants';
17
- import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
18
- import CheckIcon from '../../../shared/CheckIcon';
19
- import ScreenContainer from '../../../shared/Containers/ScreenContainer';
20
- import ClearIcon from '../../../shared/ClearIcon';
21
- import Input from '../../../shared/Input';
22
- import Collapse from '../../../../components/Collapse';
23
- var FLNumber = function (_a) {
24
- var _b;
25
- var show = _a.show, readOnly = _a.readOnly;
26
- var t = useTranslation().t;
27
- var control = useFormContext().control;
28
- var flNumberControl = useController({ control: control, name: 'flNumber' });
29
- var handleFLNumberChange = function (_a) {
30
- var target = _a.target;
31
- var value = removeAllOtherThanCharsAndNumber(target.value);
32
- flNumberControl.field.onChange(value);
33
- };
34
- var clearFLNumber = function () {
35
- flNumberControl.field.onChange('');
36
- };
37
- var flNumberValue = flNumberControl.field.value;
38
- var error = (_b = flNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
39
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t('enter_license_no'), onChange: handleFLNumberChange, inputProps: { maxLength: FL_NUMBER_LENGTH }, value: flNumberValue, endAdornment: (flNumberValue === null || flNumberValue === void 0 ? void 0 : flNumberValue.length) === FL_NUMBER_LENGTH ? (_jsx(CheckIcon, {})) : (flNumberValue && _jsx(ClearIcon, { onClick: clearFLNumber })), placeholder: '12345678', warningType: 'alert', warningMessage: error && t(error, { length: FL_NUMBER_LENGTH }) }) }) })));
40
- };
41
- export default React.memo(FLNumber);
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- import { License } from '../../../../@types';
3
- interface FreelanceLicenseProps {
4
- show: boolean;
5
- list: Array<License>;
6
- onSelectLicense?: (number: string) => void;
7
- onListOpen?: () => void;
8
- onListClose?: () => void;
9
- }
10
- declare const _default: React.MemoExoticComponent<({ show, list, ...rest }: FreelanceLicenseProps) => JSX.Element>;
11
- export default _default;