@tap-payments/auth-jsconnect 2.6.57-test → 2.6.60-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 (118) hide show
  1. package/build/@types/app.d.ts +3 -1
  2. package/build/@types/app.js +1 -1
  3. package/build/api/account.d.ts +1 -0
  4. package/build/api/account.js +8 -1
  5. package/build/api/auth.d.ts +2 -0
  6. package/build/api/index.d.ts +4 -3
  7. package/build/api/lead.d.ts +3 -0
  8. package/build/api/operator.d.ts +3 -2
  9. package/build/api/operator.js +2 -2
  10. package/build/app/rootReducer.d.ts +1 -0
  11. package/build/app/rootReducer.js +2 -0
  12. package/build/app/settings.js +3 -2
  13. package/build/app/store.d.ts +2 -0
  14. package/build/assets/locales/ar.json +2 -1
  15. package/build/assets/locales/en.json +2 -1
  16. package/build/constants/app.d.ts +11 -0
  17. package/build/constants/app.js +54 -0
  18. package/build/features/app/auth/authStore.d.ts +189 -0
  19. package/build/features/app/auth/authStore.js +726 -0
  20. package/build/features/app/bank/bankStore.js +5 -4
  21. package/build/features/app/brand/brandStore.js +5 -4
  22. package/build/features/app/business/businessStore.js +37 -28
  23. package/build/features/app/connectExpress/connectExpressStore.js +3 -2
  24. package/build/features/app/entity/entityStore.js +5 -4
  25. package/build/features/app/individual/individualStore.js +5 -4
  26. package/build/features/app/tax/taxStore.js +5 -4
  27. package/build/features/auth/Auth.d.ts +9 -0
  28. package/build/features/auth/Auth.js +93 -0
  29. package/build/features/auth/index.d.ts +1 -0
  30. package/build/features/auth/index.js +1 -0
  31. package/build/features/auth/screens/AuthenticationList/AuthenticationList.d.ts +5 -0
  32. package/build/features/auth/screens/AuthenticationList/AuthenticationList.js +91 -0
  33. package/build/features/auth/screens/AuthenticationList/BrandList.d.ts +10 -0
  34. package/build/features/auth/screens/AuthenticationList/BrandList.js +81 -0
  35. package/build/features/auth/screens/AuthenticationList/EntityList.d.ts +11 -0
  36. package/build/features/auth/screens/AuthenticationList/EntityList.js +96 -0
  37. package/build/features/auth/screens/AuthenticationList/MerchantList.d.ts +10 -0
  38. package/build/features/auth/screens/AuthenticationList/MerchantList.js +107 -0
  39. package/build/features/auth/screens/AuthenticationList/index.d.ts +3 -0
  40. package/build/features/auth/screens/AuthenticationList/index.js +2 -0
  41. package/build/features/auth/screens/AuthenticationList/validation.d.ts +14 -0
  42. package/build/features/auth/screens/AuthenticationList/validation.js +8 -0
  43. package/build/features/auth/screens/BusinessCountry/BusinessCountry.d.ts +5 -0
  44. package/build/features/auth/screens/BusinessCountry/BusinessCountry.js +105 -0
  45. package/build/features/auth/screens/BusinessCountry/index.d.ts +3 -0
  46. package/build/features/auth/screens/BusinessCountry/index.js +2 -0
  47. package/build/features/auth/screens/CivilID/CivilID.d.ts +5 -0
  48. package/build/features/auth/screens/CivilID/CivilID.js +88 -0
  49. package/build/features/auth/screens/CivilID/IDNumber.d.ts +8 -0
  50. package/build/features/auth/screens/CivilID/IDNumber.js +54 -0
  51. package/build/features/auth/screens/CivilID/index.d.ts +3 -0
  52. package/build/features/auth/screens/CivilID/index.js +2 -0
  53. package/build/features/auth/screens/CivilID/validation.d.ts +8 -0
  54. package/build/features/auth/screens/CivilID/validation.js +4 -0
  55. package/build/features/auth/screens/Mobile/Mobile.d.ts +5 -0
  56. package/build/features/auth/screens/Mobile/Mobile.js +108 -0
  57. package/build/features/auth/screens/Mobile/MobileNumber.d.ts +13 -0
  58. package/build/features/auth/screens/Mobile/MobileNumber.js +158 -0
  59. package/build/features/auth/screens/Mobile/index.d.ts +3 -0
  60. package/build/features/auth/screens/Mobile/index.js +2 -0
  61. package/build/features/auth/screens/Mobile/validation.d.ts +8 -0
  62. package/build/features/auth/screens/Mobile/validation.js +30 -0
  63. package/build/features/auth/screens/NID/DOB.d.ts +6 -0
  64. package/build/features/auth/screens/NID/DOB.js +47 -0
  65. package/build/features/auth/screens/NID/IDNumber.d.ts +7 -0
  66. package/build/features/auth/screens/NID/IDNumber.js +55 -0
  67. package/build/features/auth/screens/NID/NID.d.ts +5 -0
  68. package/build/features/auth/screens/NID/NID.js +92 -0
  69. package/build/features/auth/screens/NID/index.d.ts +3 -0
  70. package/build/features/auth/screens/NID/index.js +2 -0
  71. package/build/features/auth/screens/NID/validation.d.ts +11 -0
  72. package/build/features/auth/screens/NID/validation.js +11 -0
  73. package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
  74. package/build/features/auth/screens/OTP/OTP.js +88 -0
  75. package/build/features/auth/screens/OTP/OTPInput.d.ts +5 -0
  76. package/build/features/auth/screens/OTP/OTPInput.js +57 -0
  77. package/build/features/auth/screens/OTP/index.d.ts +3 -0
  78. package/build/features/auth/screens/OTP/index.js +2 -0
  79. package/build/features/auth/screens/OTP/validation.d.ts +8 -0
  80. package/build/features/auth/screens/OTP/validation.js +4 -0
  81. package/build/features/auth/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
  82. package/build/features/auth/screens/VerifyPACI/VerifyPACI.js +34 -0
  83. package/build/features/auth/screens/VerifyPACI/index.d.ts +3 -0
  84. package/build/features/auth/screens/VerifyPACI/index.js +2 -0
  85. package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +6 -33
  86. package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +4 -17
  87. package/build/features/brand/screens/BrandActivities/TAC.d.ts +2 -7
  88. package/build/features/business/screens/BusinessType/LicenseType.d.ts +4 -26
  89. package/build/features/business/screens/Customers/CustomerLocations.d.ts +6 -33
  90. package/build/features/business/screens/Customers/RefundPolicy.d.ts +4 -17
  91. package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +4 -26
  92. package/build/features/connectExpress/screens/CollectBusinessInfo/TAC.d.ts +2 -7
  93. package/build/features/connectExpress/screens/Mobile/MobileNumber.js +2 -2
  94. package/build/features/connectExpress/screens/NID/TAC.d.ts +2 -7
  95. package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +6 -33
  96. package/build/features/featuresScreens.d.ts +1 -0
  97. package/build/features/featuresScreens.js +40 -3
  98. package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +4 -26
  99. package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +4 -26
  100. package/build/features/shared/Address/CountryList.d.ts +5 -21
  101. package/build/features/shared/Address/InputSelect.d.ts +5 -21
  102. package/build/features/shared/Background/Background.d.ts +2 -1
  103. package/build/features/shared/Background/Background.js +5 -5
  104. package/build/features/shared/Input/Input.d.ts +1 -1
  105. package/build/features/shared/UploadFile/FileUpload.d.ts +2 -7
  106. package/build/features/shared/UploadFile/UploadFile.d.ts +2 -7
  107. package/build/features/shared/UploadFile/UploadWrapper.d.ts +2 -7
  108. package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +2 -7
  109. package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +2 -7
  110. package/build/hooks/useAppDispatch.d.ts +1 -0
  111. package/build/index.d.ts +3 -2
  112. package/build/index.js +3 -1
  113. package/build/utils/common.d.ts +1 -0
  114. package/build/utils/common.js +8 -1
  115. package/build/utils/string.d.ts +1 -0
  116. package/build/utils/string.js +3 -0
  117. package/build/utils/validation.js +2 -1
  118. package/package.json +1 -1
@@ -0,0 +1,158 @@
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 { settingsSelector } from '../../../../app/settings';
31
+ import Collapse from '../../../../components/Collapse';
32
+ import ClearIcon from '../../../shared/ClearIcon';
33
+ import CheckIcon from '../../../shared/CheckIcon';
34
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
35
+ import { authSelector } from '../../../app/auth/authStore';
36
+ import ExpandIcon from '../../../../components/ExpandIcon';
37
+ import Input from '../../../shared/Input';
38
+ import SimpleList from '../../../../components/SimpleList';
39
+ import { isOtherThanKWOrSA, removeAllCharsFromNumber } from '../../../../utils';
40
+ import { useLanguage, useAppSelector } from '../../../../hooks';
41
+ import Search from '../../../shared/Search';
42
+ var LabelContainerStyled = styled(Box)(function (_a) {
43
+ var theme = _a.theme;
44
+ return ({
45
+ display: 'flex',
46
+ justifyContent: 'space-between',
47
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
48
+ });
49
+ });
50
+ var CountryItemContainer = styled(Box)(function () { return ({
51
+ display: 'flex'
52
+ }); });
53
+ var CountryCodeText = styled(Text, {
54
+ shouldForwardProp: function (prop) { return prop !== 'isSelected'; }
55
+ })(function (_a) {
56
+ var theme = _a.theme, isSelected = _a.isSelected;
57
+ 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 }));
58
+ });
59
+ var CountryNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
60
+ var theme = _a.theme, isSelected = _a.isSelected;
61
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25) }));
62
+ });
63
+ var CountryCodeStyled = styled(Text)(function (_a) {
64
+ var theme = _a.theme;
65
+ return (__assign(__assign({ cursor: 'pointer' }, theme.typography.body2), { fontWeight: theme.typography.fontWeightRegular, display: 'flex', alignItems: 'center', minWidth: theme.spacing(8.75) }));
66
+ });
67
+ var InputLabelStyled = styled(Text)(function (_a) {
68
+ var theme = _a.theme;
69
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
70
+ });
71
+ var ExpandIconStyled = styled(ExpandIcon)(function (_a) {
72
+ var theme = _a.theme;
73
+ return ({
74
+ marginInlineStart: theme.spacing(1)
75
+ });
76
+ });
77
+ var InputStyled = styled(Input)(function () { return ({
78
+ direction: 'ltr',
79
+ '& .MuiInputBase-input': {
80
+ cursor: 'auto'
81
+ }
82
+ }); });
83
+ var MobileNumber = React.forwardRef(function (_a, ref) {
84
+ var _b, _c, _d, _e;
85
+ var countries = _a.countries, readOnly = _a.readOnly, rest = __rest(_a, ["countries", "readOnly"]);
86
+ var _f = React.useState(countries || []), countriesCode = _f[0], setCountries = _f[1];
87
+ var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
88
+ var t = useTranslation().t;
89
+ var isAr = useLanguage().isAr;
90
+ var _h = useFormContext(), control = _h.control, setValue = _h.setValue;
91
+ var loading = useAppSelector(authSelector).loading;
92
+ var settingsStore = useAppSelector(settingsSelector);
93
+ var phoneControl = useController({ name: 'mobile', control: control });
94
+ var countryCodeControl = useController({ name: 'countryCode', control: control });
95
+ var countryCodeValue = countryCodeControl.field.value;
96
+ var mobileValue = phoneControl.field.value || '';
97
+ 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) || '';
98
+ var error = !!mobileValue ? (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message : '';
99
+ var isSA = countryCodeValue.iso2 === 'SA';
100
+ var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
101
+ var isStartsWith5 = mobileValue.startsWith('5');
102
+ var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
103
+ var isOtherThanKWOrSACountry = React.useMemo(function () { var _a; return isOtherThanKWOrSA((_a = settingsStore.data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2); }, [(_e = settingsStore.data.businessCountry) === null || _e === void 0 ? void 0 : _e.iso2]);
104
+ React.useEffect(function () {
105
+ if (mobileValue)
106
+ setValue('mobile', mobileValue, { shouldValidate: true });
107
+ }, []);
108
+ var onPhoneNumberChange = function (_a) {
109
+ var target = _a.target;
110
+ var value = removeAllCharsFromNumber(target.value);
111
+ phoneControl.field.onChange(value);
112
+ };
113
+ var clearMobileNumber = function () {
114
+ phoneControl.field.onChange('');
115
+ };
116
+ var onCloseCountryList = function () {
117
+ var _a;
118
+ if (anchorEl) {
119
+ setAnchorEl(null);
120
+ (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
121
+ }
122
+ setCountries(countries);
123
+ };
124
+ var toggleCountryList = function () {
125
+ var _a, _b;
126
+ if (anchorEl) {
127
+ setAnchorEl(null);
128
+ (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
129
+ setCountries(countries);
130
+ }
131
+ else {
132
+ (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
133
+ setAnchorEl(true);
134
+ }
135
+ };
136
+ var onSelectItem = function (country) {
137
+ onCloseCountryList();
138
+ setValue('mobile', '');
139
+ countryCodeControl.field.onChange(country);
140
+ };
141
+ var handleSearch = function (value) {
142
+ var filteredCountries = countries.filter(function (country) {
143
+ return country.idd_prefix.toString().toLowerCase().startsWith(value.replace('+', '').toLowerCase()) ||
144
+ country.capital.toLowerCase().startsWith(value.toLowerCase()) ||
145
+ country.name.arabic.toLowerCase().startsWith(value.toLowerCase()) ||
146
+ country.name.english.toLowerCase().startsWith(value.toLowerCase());
147
+ });
148
+ setCountries(filteredCountries);
149
+ };
150
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { minHeight: mobileValue ? '133px' : isOtherThanKWOrSACountry ? '117px' : '0px' } }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(InputStyled, { inputProps: { maxLength: requiredLen }, type: 'tel', readOnly: !!anchorEl || readOnly, required: true, onClick: onCloseCountryList, onChange: onPhoneNumberChange, onEnterPressed: function (e) { return loading && e.preventDefault(); }, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () {
151
+ if (readOnly)
152
+ return;
153
+ toggleCountryList();
154
+ } }, { 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) {
155
+ 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, {})] }));
156
+ } })] }))] })) })));
157
+ });
158
+ 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,30 @@
1
+ import * as yup from 'yup';
2
+ export var PhoneValidationSchema = function () {
3
+ return yup.object().shape({
4
+ mobile: yup
5
+ .string()
6
+ .test({
7
+ test: function (value) {
8
+ var countryCode = this.parent.countryCode;
9
+ var isSA = countryCode.iso2 === 'SA';
10
+ var digits = countryCode.digits;
11
+ var mobileValue = value || '';
12
+ var valueLen = mobileValue.length;
13
+ var isNumber = mobileValue.match(/^[0-9]/g);
14
+ if (!isNumber)
15
+ return this.createError({ message: 'enter_valid_mobile_number' });
16
+ var isStartWithZero = mobileValue.startsWith('05');
17
+ var isStartWith5 = mobileValue.startsWith('5');
18
+ var isSaudiNumber = isStartWith5 || isStartWithZero;
19
+ if (isSA) {
20
+ if (!isSaudiNumber)
21
+ return this.createError({ message: 'start_with_number' });
22
+ var requiredLen = isStartWith5 ? digits - 1 : digits;
23
+ return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
24
+ }
25
+ return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
26
+ }
27
+ })
28
+ .required('mobile_number_error')
29
+ });
30
+ };
@@ -0,0 +1,6 @@
1
+ interface DOBProps {
2
+ onDateClicked?: (flag: boolean) => void;
3
+ readOnly?: boolean;
4
+ }
5
+ declare const DOB: ({ onDateClicked, readOnly }: DOBProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default DOB;
@@ -0,0 +1,47 @@
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 { useTranslation } from 'react-i18next';
14
+ import { useController, useFormContext } from 'react-hook-form';
15
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
16
+ import { ScreenContainer } from '../../../shared/Containers';
17
+ import { alpha, styled } from '@mui/material/styles';
18
+ import { clearError, authSelector } from '../../../app/auth/authStore';
19
+ import Text from '../../../../components/Text';
20
+ import Calender from '../../../shared/Calender';
21
+ var InputLabelStyled = styled(Text)(function (_a) {
22
+ var theme = _a.theme;
23
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
24
+ });
25
+ var DOB = function (_a) {
26
+ var _b;
27
+ var onDateClicked = _a.onDateClicked, readOnly = _a.readOnly;
28
+ var t = useTranslation().t;
29
+ var control = useFormContext().control;
30
+ var dispatch = useAppDispatch();
31
+ var dobControl = useController({ control: control, name: 'dob' });
32
+ var error = useAppSelector(authSelector).error;
33
+ var handleBirthDateChange = function (data) {
34
+ dobControl.field.onChange(data);
35
+ handleClearError();
36
+ };
37
+ var handleClearError = function () {
38
+ if (error)
39
+ dispatch(clearError());
40
+ };
41
+ var dateValue = (_b = dobControl === null || dobControl === void 0 ? void 0 : dobControl.field) === null || _b === void 0 ? void 0 : _b.value;
42
+ return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, __assign({ sx: { p: function (_a) {
43
+ var spacing = _a.spacing;
44
+ return spacing(2.5, 2.5, 1.5, 2.5);
45
+ } } }, { children: t('enter_birth_date') })), _jsx(Calender, { isDob: true, disabled: readOnly, defaultValue: dateValue ? new Date(dateValue) : undefined, onDateClicked: onDateClicked, onDateChange: handleBirthDateChange })] }));
46
+ };
47
+ export default DOB;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ interface IDNumberProps {
3
+ show: boolean;
4
+ readOnly?: boolean;
5
+ }
6
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IDNumberProps & React.RefAttributes<unknown>>>;
7
+ 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 Collapse from '../../../../components/Collapse';
21
+ import ScreenContainer from '../../../shared/Containers/ScreenContainer';
22
+ import { removeAllCharsFromNumber } from '../../../../utils';
23
+ import { ID_NUMBER_LENGTH } from '../../../../constants';
24
+ import { EndAdornment } from '../../../shared/EndAdornment';
25
+ var LabelContainerStyled = styled(Box)(function (_a) {
26
+ var theme = _a.theme;
27
+ return ({
28
+ display: 'flex',
29
+ justifyContent: 'space-between',
30
+ padding: theme.spacing(0, 2.5, 1.25, 2.5)
31
+ });
32
+ });
33
+ var InputLabelStyled = styled(Text)(function (_a) {
34
+ var theme = _a.theme;
35
+ return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
36
+ });
37
+ var IDNumber = React.forwardRef(function (_a, ref) {
38
+ var _b;
39
+ var show = _a.show, readOnly = _a.readOnly;
40
+ var t = useTranslation().t;
41
+ var control = useFormContext().control;
42
+ var nidControl = useController({ control: control, name: 'nid' });
43
+ var handleIdChange = function (_a) {
44
+ var target = _a.target;
45
+ var value = removeAllCharsFromNumber(target.value);
46
+ nidControl.field.onChange(value);
47
+ };
48
+ var clearIdNumber = function () {
49
+ nidControl.field.onChange('');
50
+ };
51
+ var nidValue = nidControl.field.value;
52
+ var error = (_b = nidControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
53
+ return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_national_id') }) }), _jsx(Input, { readOnly: readOnly, dir: 'ltr', type: 'tel', inputProps: { maxLength: ID_NUMBER_LENGTH }, onChange: handleIdChange, value: nidValue, endAdornment: _jsx(EndAdornment, { value: nidValue, error: error, onClear: clearIdNumber }), placeholder: t('national_id_placeholder'), warningType: 'alert', warningMessage: error && t(error, { number: '1' }), required: true })] })) })));
54
+ });
55
+ export default React.memo(IDNumber);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface NIDProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: NIDProps) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -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 * as React from 'react';
14
+ import { useTranslation } from 'react-i18next';
15
+ import { useForm, FormProvider } from 'react-hook-form';
16
+ import { alpha, styled } from '@mui/material/styles';
17
+ import Box from '@mui/material/Box';
18
+ import Divider from '@mui/material/Divider';
19
+ import { yupResolver } from '@hookform/resolvers/yup';
20
+ import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
21
+ import { handleCurrentActiveScreen, handlePrevScreenStep } from '../../../../app/settings';
22
+ import { clearError, authSelector, createNIDAuth } from '../../../app/auth/authStore';
23
+ import Form from '../../../../components/Form';
24
+ import Button, { MobileButton } from '../../../shared/Button';
25
+ import { ScreenContainer } from '../../../shared/Containers';
26
+ import Collapse from '../../../../components/Collapse';
27
+ import Text from '../../../../components/Text';
28
+ import { deepCopy } from '../../../../utils';
29
+ import IDNumber from './IDNumber';
30
+ import DOB from './DOB';
31
+ import { NIDValidationSchema } from './validation';
32
+ var FormStyled = styled(Form)(function () { return ({
33
+ display: 'flex',
34
+ flexDirection: 'column'
35
+ }); });
36
+ var TextStyled = styled(Text)(function (_a) {
37
+ var theme = _a.theme;
38
+ return ({
39
+ color: alpha(theme.palette.primary.dark, 0.4)
40
+ });
41
+ });
42
+ var DividerStyled = styled(Divider)(function (_a) {
43
+ var theme = _a.theme;
44
+ return ({
45
+ width: '45%',
46
+ borderColor: alpha(theme.palette.primary.dark, 0.4),
47
+ marginBlockEnd: theme.spacing(0.62)
48
+ });
49
+ });
50
+ var OrBoxStyled = styled(Box)(function (_a) {
51
+ var theme = _a.theme;
52
+ return ({
53
+ display: 'flex',
54
+ justifyContent: 'space-between',
55
+ marginBlockEnd: theme.spacing(1.62),
56
+ marginBlockStart: theme.spacing(-1.25),
57
+ marginInline: theme.spacing(2.5)
58
+ });
59
+ });
60
+ var NID = function (_a) {
61
+ var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
62
+ var isAr = useLanguage().isAr;
63
+ var dispatch = useAppDispatch();
64
+ var t = useTranslation().t;
65
+ var _c = useAppSelector(authSelector), data = _c.data, loading = _c.loading, error = _c.error;
66
+ var methods = useForm({
67
+ resolver: yupResolver(NIDValidationSchema()),
68
+ defaultValues: data.nidData,
69
+ mode: 'onChange'
70
+ });
71
+ React.useEffect(function () {
72
+ if (error)
73
+ dispatch(clearError());
74
+ }, [methods.formState.isValid]);
75
+ React.useEffect(function () {
76
+ }, []);
77
+ var onSubmit = function (data) {
78
+ dispatch(createNIDAuth(deepCopy(data)));
79
+ };
80
+ var handleCollapseOpenClose = function (flag) {
81
+ setCollapse(flag);
82
+ };
83
+ var onBack = function () {
84
+ dispatch(handlePrevScreenStep());
85
+ };
86
+ var onBackToCountryList = function () {
87
+ dispatch(handleCurrentActiveScreen('AUTH_BUSINESS_COUNTRY_STEP'));
88
+ };
89
+ var disabled = !methods.formState.isValid;
90
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, { show: !collapse }) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, onBackClicked: onBackToCountryList, disableBack: !data.isStartFromBusinessCountry, disabled: disabled, 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({ onClick: function () { return onBack(); }, disabled: loading }, { children: t('mobile_button_label') }))] }))] }))] })) })) }));
91
+ };
92
+ export default React.memo(NID);
@@ -0,0 +1,3 @@
1
+ import NID, { NIDProps } from './NID';
2
+ export type { NIDProps };
3
+ export default NID;
@@ -0,0 +1,2 @@
1
+ import NID from './NID';
2
+ export default NID;
@@ -0,0 +1,11 @@
1
+ import * as yup from 'yup';
2
+ export declare const NIDValidationSchema: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ dob: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
6
+ dob: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
9
+ dob: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
+ nid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
+ }>>>;
@@ -0,0 +1,11 @@
1
+ import * as yup from 'yup';
2
+ export var NIDValidationSchema = function () {
3
+ return yup.object().shape({
4
+ dob: yup.string().min(5).required('enter_valid_birth_date'),
5
+ nid: yup
6
+ .string()
7
+ .matches(/^(1|2)([0-9]{1,})$/g, 'signup_invalid_national_id_format')
8
+ .min(10, 'signup_invalid_national_id')
9
+ .required('signup_invalid_national_id')
10
+ });
11
+ };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,88 @@
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 { useForm, FormProvider } from 'react-hook-form';
16
+ import Box from '@mui/material/Box/Box';
17
+ import { styled } from '@mui/material/styles';
18
+ import Text from '../../../../components/Text';
19
+ import { clearError, authSelector, verifyMobileOtp, verifyNIDOtp, resetOTPValue } from '../../../app/auth/authStore';
20
+ import Button from '../../../shared/Button';
21
+ import { ScreenContainer } from '../../../shared/Containers';
22
+ import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
23
+ import { handlePrevScreenStep } from '../../../../app/settings';
24
+ import { AuthForType } from '../../../../@types';
25
+ import { yupResolver } from '@hookform/resolvers/yup';
26
+ import Form from '../../../../components/Form';
27
+ import { maskPhone, maskID, deepCopy } from '../../../../utils';
28
+ import { ACCOUNT_NOT_AVAILABLE } from '../../../../constants';
29
+ import { OTPValidation } from './validation';
30
+ import OTPInput from './OTPInput';
31
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ background: theme.palette.common.white,
35
+ border: '1px solid',
36
+ borderColor: theme.palette.divider,
37
+ direction: theme.direction,
38
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
39
+ marginBottom: theme.spacing(5.75)
40
+ });
41
+ });
42
+ var OTPTitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line' }));
45
+ });
46
+ var FormStyled = styled(Form)(function () { return ({
47
+ display: 'flex',
48
+ flexDirection: 'column'
49
+ }); });
50
+ var OTP = function () {
51
+ var _a;
52
+ var dispatch = useAppDispatch();
53
+ var _b = useAppSelector(authSelector), data = _b.data, loading = _b.loading, error = _b.error;
54
+ var t = useTranslation().t;
55
+ var isAr = useLanguage().isAr;
56
+ var methods = useForm({
57
+ resolver: yupResolver(OTPValidation),
58
+ defaultValues: data.otpData,
59
+ mode: 'onChange'
60
+ });
61
+ var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID;
62
+ React.useEffect(function () {
63
+ if (error && error !== ACCOUNT_NOT_AVAILABLE)
64
+ dispatch(clearError());
65
+ }, [methods.formState.isValid]);
66
+ React.useEffect(function () {
67
+ return function () {
68
+ dispatch(resetOTPValue());
69
+ };
70
+ }, []);
71
+ var onSubmit = function (formData) {
72
+ if (isNidAuth) {
73
+ dispatch(verifyNIDOtp(deepCopy(formData)));
74
+ return;
75
+ }
76
+ dispatch(verifyMobileOtp(deepCopy(formData)));
77
+ };
78
+ var onBack = function () {
79
+ var screen = isNidAuth ? 'AUTH_NID_STEP' : 'AUTH_MOBILE_STEP';
80
+ dispatch(handlePrevScreenStep(screen));
81
+ };
82
+ var disabled = !methods.formState.isValid || error === ACCOUNT_NOT_AVAILABLE;
83
+ var phone = ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + (data.mobileData.mobile || '');
84
+ var idNumber = data.nidData.nid;
85
+ var title = isNidAuth ? t('opt_nid_sent_title', { provider: 'ABSHER' }) : t('ide_opt_sent_title');
86
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : title, !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: isNidAuth ? maskID(idNumber) : maskPhone(phone) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
87
+ };
88
+ export default React.memo(OTP);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => import("react/jsx-runtime").JSX.Element>;
5
+ export default _default;
@@ -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 * as React from 'react';
14
+ import { useController, useFormContext } from 'react-hook-form';
15
+ import { useTranslation } from 'react-i18next';
16
+ import Box from '@mui/material/Box/Box';
17
+ import { styled } from '@mui/material/styles';
18
+ import OTPField from '../../../shared/OTP';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ import { AuthForType } from '../../../../@types';
21
+ import { resendMobileAuthOTP, resendNIDAuthOTP, authSelector, clearError } from '../../../app/auth/authStore';
22
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
23
+ var BoxStyled = styled(Box)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ flexDirection: 'column',
28
+ fontFamily: theme.typography.fontFamily
29
+ });
30
+ });
31
+ var OTPInput = function (_a) {
32
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
33
+ var t = useTranslation().t;
34
+ var dispatch = useAppDispatch();
35
+ var otpControl = useController({ name: 'otp', control: control });
36
+ var _c = useAppSelector(authSelector), data = _c.data, error = _c.error;
37
+ var mobileData = data.mobileData, nidData = data.nidData;
38
+ var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID;
39
+ var handleOnOTPChange = function (otp) {
40
+ if (error)
41
+ dispatch(clearError());
42
+ otpControl.field.onChange(otp);
43
+ };
44
+ var handleOnResendOTP = function () {
45
+ if (otpControl.field.value)
46
+ setValue('otp', '', { shouldValidate: true });
47
+ dispatch(resendMobileAuthOTP(mobileData));
48
+ };
49
+ var handleOnResendAbsherOTP = function () {
50
+ if (otpControl.field.value)
51
+ setValue('otp', '', { shouldValidate: true });
52
+ dispatch(resendNIDAuthOTP(nidData));
53
+ };
54
+ var otpValue = otpControl.field.value;
55
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: isNidAuth ? handleOnResendAbsherOTP : handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
56
+ };
57
+ export default React.memo(OTPInput);
@@ -0,0 +1,3 @@
1
+ import OTP, { OTPProps } from './OTP';
2
+ export type { OTPProps };
3
+ export default OTP;
@@ -0,0 +1,2 @@
1
+ import OTP from './OTP';
2
+ export default OTP;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;