@tap-payments/auth-jsconnect 2.6.57-test → 2.6.59-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.
- package/build/@types/app.d.ts +3 -1
- package/build/@types/app.js +1 -1
- package/build/api/account.d.ts +1 -0
- package/build/api/account.js +8 -1
- package/build/api/auth.d.ts +2 -0
- package/build/api/index.d.ts +4 -3
- package/build/api/lead.d.ts +3 -0
- package/build/api/operator.d.ts +3 -2
- package/build/api/operator.js +2 -2
- package/build/app/rootReducer.d.ts +1 -0
- package/build/app/rootReducer.js +2 -0
- package/build/app/settings.js +3 -2
- package/build/app/store.d.ts +2 -0
- package/build/constants/app.d.ts +10 -0
- package/build/constants/app.js +53 -0
- package/build/features/app/auth/authStore.d.ts +189 -0
- package/build/features/app/auth/authStore.js +729 -0
- package/build/features/app/bank/bankStore.js +5 -4
- package/build/features/app/brand/brandStore.js +5 -4
- package/build/features/app/business/businessStore.js +37 -28
- package/build/features/app/connectExpress/connectExpressStore.js +3 -2
- package/build/features/app/entity/entityStore.js +5 -4
- package/build/features/app/individual/individualStore.js +5 -4
- package/build/features/app/tax/taxStore.js +5 -4
- package/build/features/auth/Auth.d.ts +8 -0
- package/build/features/auth/Auth.js +93 -0
- package/build/features/auth/index.d.ts +1 -0
- package/build/features/auth/index.js +1 -0
- package/build/features/auth/screens/AuthenticationList/AuthenticationList.d.ts +5 -0
- package/build/features/auth/screens/AuthenticationList/AuthenticationList.js +91 -0
- package/build/features/auth/screens/AuthenticationList/BrandList.d.ts +10 -0
- package/build/features/auth/screens/AuthenticationList/BrandList.js +81 -0
- package/build/features/auth/screens/AuthenticationList/EntityList.d.ts +11 -0
- package/build/features/auth/screens/AuthenticationList/EntityList.js +96 -0
- package/build/features/auth/screens/AuthenticationList/MerchantList.d.ts +10 -0
- package/build/features/auth/screens/AuthenticationList/MerchantList.js +107 -0
- package/build/features/auth/screens/AuthenticationList/index.d.ts +3 -0
- package/build/features/auth/screens/AuthenticationList/index.js +2 -0
- package/build/features/auth/screens/AuthenticationList/validation.d.ts +14 -0
- package/build/features/auth/screens/AuthenticationList/validation.js +8 -0
- package/build/features/auth/screens/BusinessCountry/BusinessCountry.d.ts +5 -0
- package/build/features/auth/screens/BusinessCountry/BusinessCountry.js +105 -0
- package/build/features/auth/screens/BusinessCountry/index.d.ts +3 -0
- package/build/features/auth/screens/BusinessCountry/index.js +2 -0
- package/build/features/auth/screens/CivilID/CivilID.d.ts +5 -0
- package/build/features/auth/screens/CivilID/CivilID.js +88 -0
- package/build/features/auth/screens/CivilID/IDNumber.d.ts +8 -0
- package/build/features/auth/screens/CivilID/IDNumber.js +54 -0
- package/build/features/auth/screens/CivilID/index.d.ts +3 -0
- package/build/features/auth/screens/CivilID/index.js +2 -0
- package/build/features/auth/screens/CivilID/validation.d.ts +8 -0
- package/build/features/auth/screens/CivilID/validation.js +4 -0
- package/build/features/auth/screens/Mobile/Mobile.d.ts +5 -0
- package/build/features/auth/screens/Mobile/Mobile.js +108 -0
- package/build/features/auth/screens/Mobile/MobileNumber.d.ts +13 -0
- package/build/features/auth/screens/Mobile/MobileNumber.js +158 -0
- package/build/features/auth/screens/Mobile/index.d.ts +3 -0
- package/build/features/auth/screens/Mobile/index.js +2 -0
- package/build/features/auth/screens/Mobile/validation.d.ts +8 -0
- package/build/features/auth/screens/Mobile/validation.js +30 -0
- package/build/features/auth/screens/NID/DOB.d.ts +6 -0
- package/build/features/auth/screens/NID/DOB.js +47 -0
- package/build/features/auth/screens/NID/IDNumber.d.ts +7 -0
- package/build/features/auth/screens/NID/IDNumber.js +55 -0
- package/build/features/auth/screens/NID/NID.d.ts +5 -0
- package/build/features/auth/screens/NID/NID.js +92 -0
- package/build/features/auth/screens/NID/index.d.ts +3 -0
- package/build/features/auth/screens/NID/index.js +2 -0
- package/build/features/auth/screens/NID/validation.d.ts +11 -0
- package/build/features/auth/screens/NID/validation.js +11 -0
- package/build/features/auth/screens/OTP/OTP.d.ts +5 -0
- package/build/features/auth/screens/OTP/OTP.js +87 -0
- package/build/features/auth/screens/OTP/OTPInput.d.ts +5 -0
- package/build/features/auth/screens/OTP/OTPInput.js +57 -0
- package/build/features/auth/screens/OTP/index.d.ts +3 -0
- package/build/features/auth/screens/OTP/index.js +2 -0
- package/build/features/auth/screens/OTP/validation.d.ts +8 -0
- package/build/features/auth/screens/OTP/validation.js +4 -0
- package/build/features/auth/screens/VerifyPACI/VerifyPACI.d.ts +5 -0
- package/build/features/auth/screens/VerifyPACI/VerifyPACI.js +34 -0
- package/build/features/auth/screens/VerifyPACI/index.d.ts +3 -0
- package/build/features/auth/screens/VerifyPACI/index.js +2 -0
- package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +6 -33
- package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +4 -17
- package/build/features/brand/screens/BrandActivities/TAC.d.ts +2 -7
- package/build/features/business/screens/BusinessType/LicenseType.d.ts +4 -26
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +6 -33
- package/build/features/business/screens/Customers/RefundPolicy.d.ts +4 -17
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +4 -26
- package/build/features/connectExpress/screens/CollectBusinessInfo/TAC.d.ts +2 -7
- package/build/features/connectExpress/screens/Mobile/MobileNumber.js +2 -2
- package/build/features/connectExpress/screens/NID/TAC.d.ts +2 -7
- package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +6 -33
- package/build/features/featuresScreens.d.ts +1 -0
- package/build/features/featuresScreens.js +40 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +4 -26
- package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +4 -26
- package/build/features/shared/Address/CountryList.d.ts +5 -21
- package/build/features/shared/Address/InputSelect.d.ts +5 -21
- package/build/features/shared/Input/Input.d.ts +1 -1
- package/build/features/shared/UploadFile/FileUpload.d.ts +2 -7
- package/build/features/shared/UploadFile/UploadFile.d.ts +2 -7
- package/build/features/shared/UploadFile/UploadWrapper.d.ts +2 -7
- package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +2 -7
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +2 -7
- package/build/hooks/useAppDispatch.d.ts +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.js +3 -1
- package/build/utils/common.d.ts +1 -0
- package/build/utils/common.js +8 -1
- package/build/utils/string.d.ts +1 -0
- package/build/utils/string.js +3 -0
- 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,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,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,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,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,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,87 @@
|
|
|
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 { OTPValidation } from './validation';
|
|
29
|
+
import OTPInput from './OTPInput';
|
|
30
|
+
var OTPTitleContainerStyled = styled(Box)(function (_a) {
|
|
31
|
+
var theme = _a.theme;
|
|
32
|
+
return ({
|
|
33
|
+
background: theme.palette.common.white,
|
|
34
|
+
border: '1px solid',
|
|
35
|
+
borderColor: theme.palette.divider,
|
|
36
|
+
direction: theme.direction,
|
|
37
|
+
borderRadius: theme.spacing(0, 0, 1.25, 1.25),
|
|
38
|
+
marginBottom: theme.spacing(5.75)
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var OTPTitleStyled = styled(Text)(function (_a) {
|
|
42
|
+
var theme = _a.theme;
|
|
43
|
+
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' }));
|
|
44
|
+
});
|
|
45
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
46
|
+
display: 'flex',
|
|
47
|
+
flexDirection: 'column'
|
|
48
|
+
}); });
|
|
49
|
+
var OTP = function () {
|
|
50
|
+
var _a;
|
|
51
|
+
var dispatch = useAppDispatch();
|
|
52
|
+
var _b = useAppSelector(authSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
53
|
+
var t = useTranslation().t;
|
|
54
|
+
var isAr = useLanguage().isAr;
|
|
55
|
+
var methods = useForm({
|
|
56
|
+
resolver: yupResolver(OTPValidation),
|
|
57
|
+
defaultValues: data.otpData,
|
|
58
|
+
mode: 'onChange'
|
|
59
|
+
});
|
|
60
|
+
var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID;
|
|
61
|
+
React.useEffect(function () {
|
|
62
|
+
if (error)
|
|
63
|
+
dispatch(clearError());
|
|
64
|
+
}, [methods.formState.isValid]);
|
|
65
|
+
React.useEffect(function () {
|
|
66
|
+
return function () {
|
|
67
|
+
dispatch(resetOTPValue());
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
var onSubmit = function (formData) {
|
|
71
|
+
if (isNidAuth) {
|
|
72
|
+
dispatch(verifyNIDOtp(deepCopy(formData)));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
dispatch(verifyMobileOtp(deepCopy(formData)));
|
|
76
|
+
};
|
|
77
|
+
var onBack = function () {
|
|
78
|
+
var screen = isNidAuth ? 'AUTH_NID_STEP' : 'AUTH_MOBILE_STEP';
|
|
79
|
+
dispatch(handlePrevScreenStep(screen));
|
|
80
|
+
};
|
|
81
|
+
var disabled = !methods.formState.isValid;
|
|
82
|
+
var phone = ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + (data.mobileData.mobile || '');
|
|
83
|
+
var idNumber = data.nidData.nid;
|
|
84
|
+
var title = isNidAuth ? t('opt_nid_sent_title', { provider: 'ABSHER' }) : t('ide_opt_sent_title');
|
|
85
|
+
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') }))] })) })) }));
|
|
86
|
+
};
|
|
87
|
+
export default React.memo(OTP);
|
|
@@ -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,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
|
+
}>>>;
|