@tap-payments/auth-jsconnect 2.6.12-test → 2.6.13-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 +2 -1
- package/build/@types/app.js +1 -0
- package/build/app/settings.js +2 -5
- package/build/constants/app.js +11 -5
- package/build/constants/dummy.d.ts +45 -0
- package/build/constants/dummy.js +330 -0
- package/build/features/app/brand/brandStore.js +2 -2
- package/build/features/app/business/businessStore.d.ts +9 -2
- package/build/features/app/business/businessStore.js +38 -22
- package/build/features/app/connectExpress/connectExpressStore.js +27 -13
- package/build/features/app/individual/individualStore.js +5 -5
- package/build/features/business/screens/BusinessType/BusinessType.js +13 -5
- package/build/features/business/screens/BusinessType/EntityName.js +3 -3
- package/build/features/business/screens/BusinessType/LicenseList.js +3 -3
- package/build/features/business/screens/BusinessType/LicenseNumber.js +9 -8
- package/build/features/business/screens/BusinessType/validation.d.ts +10 -0
- package/build/features/business/screens/BusinessType/validation.js +16 -0
- package/build/features/connect/Connect.js +3 -3
- package/build/features/connect/screens/Mobile/Mobile.js +7 -6
- package/build/features/connect/screens/Mobile/MobileNumber.js +9 -6
- package/build/features/connectExpress/ConnectExpress.js +3 -3
- package/build/features/connectExpress/screens/CollectBusinessInfo/CollectBusinessInfo.js +12 -4
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseList.js +6 -6
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseNumber.js +8 -7
- package/build/features/connectExpress/screens/CollectBusinessInfo/validation.d.ts +13 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/validation.js +67 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.js +4 -0
- package/build/features/connectExpress/screens/IdentityOTP/OTP.js +1 -1
- package/build/features/connectExpress/screens/IdentityOTP/OTPInput.js +1 -1
- package/build/features/connectExpress/screens/Mobile/Mobile.js +2 -2
- package/build/features/connectExpress/screens/Mobile/MobileNumber.js +9 -6
- package/build/features/entity/screens/EntityName/EntityName.js +11 -4
- package/build/features/entity/screens/EntityName/LicenseNumber.js +5 -4
- package/build/features/entity/screens/EntityName/validation.d.ts +28 -0
- package/build/features/entity/screens/EntityName/validation.js +38 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +4 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +1 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +2 -2
- package/build/hooks/useCountry.d.ts +1 -0
- package/build/hooks/useCountry.js +4 -3
- package/build/utils/string.d.ts +1 -0
- package/build/utils/string.js +3 -0
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ import Box from '@mui/material/Box';
|
|
|
26
26
|
import { useTranslation } from 'react-i18next';
|
|
27
27
|
import { useController, useFormContext } from 'react-hook-form';
|
|
28
28
|
import { styled, alpha } from '@mui/material/styles';
|
|
29
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
29
30
|
import Text from '../../../../components/Text';
|
|
30
31
|
import Collapse from '../../../../components/Collapse';
|
|
31
32
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
@@ -35,7 +36,7 @@ import { connectSelector } from '../../../app/connect/connectStore';
|
|
|
35
36
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
36
37
|
import Input from '../../../shared/Input';
|
|
37
38
|
import SimpleList from '../../../../components/SimpleList';
|
|
38
|
-
import { removeAllCharsFromNumber, sendCustomEventToGTM } from '../../../../utils';
|
|
39
|
+
import { isOtherThanKWOrSA, removeAllCharsFromNumber, sendCustomEventToGTM } from '../../../../utils';
|
|
39
40
|
import { useLanguage, useAppSelector } from '../../../../hooks';
|
|
40
41
|
import Search from '../../../shared/Search';
|
|
41
42
|
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
@@ -80,14 +81,15 @@ var InputStyled = styled(Input)(function () { return ({
|
|
|
80
81
|
}
|
|
81
82
|
}); });
|
|
82
83
|
var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
83
|
-
var _b, _c, _d;
|
|
84
|
+
var _b, _c, _d, _e;
|
|
84
85
|
var countries = _a.countries, rest = __rest(_a, ["countries"]);
|
|
85
|
-
var
|
|
86
|
-
var
|
|
86
|
+
var _f = React.useState(countries || []), countriesCode = _f[0], setCountries = _f[1];
|
|
87
|
+
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
87
88
|
var t = useTranslation().t;
|
|
88
89
|
var isAr = useLanguage().isAr;
|
|
89
|
-
var
|
|
90
|
+
var _h = useFormContext(), control = _h.control, setValue = _h.setValue;
|
|
90
91
|
var loading = useAppSelector(connectSelector).loading;
|
|
92
|
+
var settingsStore = useAppSelector(settingsSelector);
|
|
91
93
|
var phoneControl = useController({ name: 'mobile', control: control });
|
|
92
94
|
var countryCodeControl = useController({ name: 'countryCode', control: control });
|
|
93
95
|
var countryCodeValue = countryCodeControl.field.value;
|
|
@@ -98,6 +100,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
98
100
|
var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
|
|
99
101
|
var isStartsWith5 = mobileValue.startsWith('5');
|
|
100
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]);
|
|
101
104
|
React.useEffect(function () {
|
|
102
105
|
if (mobileValue)
|
|
103
106
|
setValue('mobile', mobileValue, { shouldValidate: true });
|
|
@@ -151,7 +154,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
151
154
|
});
|
|
152
155
|
setCountries(filteredCountries);
|
|
153
156
|
};
|
|
154
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { minHeight: mobileValue ? '133px' : '0px' } }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(InputStyled, { inputProps: { maxLength: requiredLen }, type: 'tel', readOnly: !!anchorEl, required: true, onClick: onCloseCountryList, onChange: onPhoneNumberChange, onEnterPressed: function (e) { return loading && e.preventDefault(); }, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: !anchorEl ? error && t(error, { length: requiredLen, number: '05|5' }) : undefined }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
157
|
+
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, required: true, onClick: onCloseCountryList, onChange: onPhoneNumberChange, onEnterPressed: function (e) { return loading && e.preventDefault(); }, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: !anchorEl ? error && t(error, { length: requiredLen, number: '05|5' }) : undefined }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
155
158
|
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
159
|
} })] }))] })) })));
|
|
157
160
|
});
|
|
@@ -67,7 +67,7 @@ import { store } from '../../app/store';
|
|
|
67
67
|
import { connectExpressSelector, setIsLeadIdPassed, setLeadId, retrieveLeadIdentityByIdAsync, setShowBoard } from '../app/connectExpress/connectExpressStore';
|
|
68
68
|
import { ReduxProvider, ThemeProvider } from '../../components/Providers';
|
|
69
69
|
import Collapse from '../../components/Collapse';
|
|
70
|
-
import { isKW, findOrCreateElementAndInject, sendPageView } from '../../utils';
|
|
70
|
+
import { isKW, findOrCreateElementAndInject, sendPageView, isOtherThanKWOrSA } from '../../utils';
|
|
71
71
|
import { CONNECT_EXPRESS_SCREENS_NAVIGATION } from '../../constants';
|
|
72
72
|
import { connectExpressFeatureScreens } from '../featuresScreens';
|
|
73
73
|
import Background from '../shared/Background';
|
|
@@ -118,8 +118,8 @@ var ConnectExpress = memo(function (_a) {
|
|
|
118
118
|
}
|
|
119
119
|
}, [data.isValidOperator, settingLoading]);
|
|
120
120
|
React.useEffect(function () {
|
|
121
|
-
var _a;
|
|
122
|
-
if (!settingLoading && isKW((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2)) {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
if (!settingLoading && (isKW((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || isOtherThanKWOrSA((_b = data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2))) {
|
|
123
123
|
dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
124
124
|
}
|
|
125
125
|
}, [settingLoading]);
|
|
@@ -15,14 +15,14 @@ import { useForm, FormProvider } from 'react-hook-form';
|
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
17
17
|
import { useAppDispatch, useAppSelector, useSetFromDefaultValues, useLanguage, useFormReadOnly, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids } from '../../../../hooks';
|
|
18
|
-
import { deepCopy, isSA } from '../../../../utils';
|
|
18
|
+
import { deepCopy, isKW, isSA } from '../../../../utils';
|
|
19
19
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
20
20
|
import Form from '../../../../components/Form';
|
|
21
21
|
import Collapse from '../../../../components/Collapse';
|
|
22
22
|
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
23
23
|
import { connectExpressSelector, clearError, updateLeadBusinessDataAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
24
24
|
import Button from '../../../shared/Button';
|
|
25
|
-
import { KWBusinessDataSchema, BusinessDataSchema } from './validation';
|
|
25
|
+
import { KWBusinessDataSchema, BusinessDataSchema, OtherThanKWOrSABusinessDataSchema } from './validation';
|
|
26
26
|
import LicenseList from './LicenseList';
|
|
27
27
|
import BrandName from './BrandName';
|
|
28
28
|
import TAC from './TAC';
|
|
@@ -37,9 +37,17 @@ var CollectBusinessInfo = function (_a) {
|
|
|
37
37
|
var dispatch = useAppDispatch();
|
|
38
38
|
var _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
|
|
39
39
|
var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
|
|
40
|
+
var isKWCountry = React.useMemo(function () { return isKW(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
40
41
|
var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
42
|
+
var getSchema = React.useMemo(function () {
|
|
43
|
+
if (isKWCountry)
|
|
44
|
+
return KWBusinessDataSchema(isLeadIdPassed);
|
|
45
|
+
if (isSACountry)
|
|
46
|
+
return BusinessDataSchema(isLeadIdPassed);
|
|
47
|
+
return OtherThanKWOrSABusinessDataSchema(isLeadIdPassed);
|
|
48
|
+
}, [isLeadIdPassed]);
|
|
41
49
|
var methods = useForm({
|
|
42
|
-
resolver: yupResolver(
|
|
50
|
+
resolver: yupResolver(getSchema),
|
|
43
51
|
defaultValues: {
|
|
44
52
|
brandName: brandName,
|
|
45
53
|
selectedLicense: selectedLicense,
|
|
@@ -78,6 +86,6 @@ var CollectBusinessInfo = function (_a) {
|
|
|
78
86
|
setListActive(true);
|
|
79
87
|
}, onListClose: function () {
|
|
80
88
|
setListActive(false);
|
|
81
|
-
} }),
|
|
89
|
+
} }), _jsxs(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: [_jsx(TAC, { show: !isLeadIdPassed, readOnly: readOnly['termAndConditionChecked'] }), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') }))] }))] })) })) }));
|
|
82
90
|
};
|
|
83
91
|
export default React.memo(CollectBusinessInfo);
|
|
@@ -28,7 +28,7 @@ import Box from '@mui/material/Box';
|
|
|
28
28
|
import { styled } from '@mui/material/styles';
|
|
29
29
|
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
30
30
|
import { BusinessType } from '../../../../@types';
|
|
31
|
-
import { isOtherLicense, isSA } from '../../../../utils';
|
|
31
|
+
import { isKW, isOtherLicense, isSA } from '../../../../utils';
|
|
32
32
|
import { settingsSelector } from '../../../../app/settings';
|
|
33
33
|
import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
|
|
34
34
|
import SimpleList from '../../../../components/SimpleList';
|
|
@@ -81,6 +81,7 @@ var LicenseList = function (_a) {
|
|
|
81
81
|
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
82
82
|
};
|
|
83
83
|
var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
|
|
84
|
+
var isKWCountry = React.useMemo(function () { return isKW(country_code); }, [country_code]);
|
|
84
85
|
React.useEffect(function () {
|
|
85
86
|
if ((licenseList || []).length > 0)
|
|
86
87
|
setValue('licenseList', licenseList);
|
|
@@ -95,8 +96,7 @@ var LicenseList = function (_a) {
|
|
|
95
96
|
}, [licenseList, selectedLicense]);
|
|
96
97
|
React.useEffect(function () {
|
|
97
98
|
if (!!country_code) {
|
|
98
|
-
|
|
99
|
-
if (isNonSA) {
|
|
99
|
+
if (isKWCountry) {
|
|
100
100
|
var license = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR ? OTHER_CR_LICENSE : OTHER_FL_LICENSE;
|
|
101
101
|
setValue('selectedLicense', license, { shouldValidate: true });
|
|
102
102
|
}
|
|
@@ -132,8 +132,8 @@ var LicenseList = function (_a) {
|
|
|
132
132
|
var licenseReadonly = !isOtherLicense(selected);
|
|
133
133
|
var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
|
|
134
134
|
var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
|
|
135
|
-
return (_jsxs(ScreenContainer, { children: [
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
return (_jsxs(ScreenContainer, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: readOnly, onClick: !!anchorEl ? function () { return onCloseLicenseList(); } : onOpenLicenseList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_license_cr'), value: isCR ? t(getLicenseName(selected)) : flValue }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'legal_name?.en', list: licenseList || [], onSelectItem: onSelectItem, renderItem: function (item) {
|
|
136
|
+
return (_jsxs(_Fragment, { children: [_jsx(LicenseContainer, { children: _jsx(LicenseNameText, __assign({ isSelected: getLicenseNumber(item) === getLicenseNumber(selected) }, { children: isOtherLicense(item) ? t(getLicenseName(item)) : getLicenseFullName(item) })) }), getLicenseNumber(item) === getLicenseNumber(selected) && _jsx(CheckIcon, {})] }));
|
|
137
|
+
} }) })), _jsx(LicenseType, { show: show && isKWCountry, readOnly: readOnly }), _jsx(LicenseNumber, { show: isKWCountry ? isCR : show, readOnly: licenseReadonly })] }));
|
|
138
138
|
};
|
|
139
139
|
export default React.memo(LicenseList);
|
|
@@ -14,7 +14,7 @@ import * as React from 'react';
|
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
16
16
|
import { CR_MIN_LICENSE_LENGTH, CR_NUMBER_MAX_LENGTH, FL_MIN_LICENSE_LENGTH, FL_NUMBER_MAX_LENGTH, KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
|
|
17
|
-
import { removeAllOtherThanCharsAndNumber,
|
|
17
|
+
import { removeAllOtherThanCharsAndNumber, isKW, isOtherThanKWOrSA } from '../../../../utils';
|
|
18
18
|
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
19
19
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
20
20
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
@@ -30,8 +30,9 @@ var LicenseNumber = function (_a) {
|
|
|
30
30
|
var _c = useFormContext(), control = _c.control, watch = _c.watch, getValues = _c.getValues;
|
|
31
31
|
var licenseNumberControl = useController({ control: control, name: 'licenseNumber' });
|
|
32
32
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
33
|
-
var
|
|
34
|
-
var
|
|
33
|
+
var isKWCountry = React.useMemo(function () { return isKW(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
34
|
+
var isOtherThanKWOrSACountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
35
|
+
var selectedLicense = isKWCountry ? watch('selectedLicense') : getValues('selectedLicense');
|
|
35
36
|
var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
|
|
36
37
|
var handleFLNumberChange = function (_a) {
|
|
37
38
|
var target = _a.target;
|
|
@@ -43,10 +44,10 @@ var LicenseNumber = function (_a) {
|
|
|
43
44
|
};
|
|
44
45
|
var licenseNumberValue = licenseNumberControl.field.value;
|
|
45
46
|
var error = (_b = licenseNumberControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
46
|
-
var length =
|
|
47
|
-
var minLength =
|
|
47
|
+
var length = isKWCountry || isOtherThanKWOrSACountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_MAX_LENGTH : FL_NUMBER_MAX_LENGTH;
|
|
48
|
+
var minLength = isKWCountry || isOtherThanKWOrSACountry ? KW_MIN_LICENSE_LENGTH : isCR ? CR_MIN_LICENSE_LENGTH : FL_MIN_LICENSE_LENGTH;
|
|
48
49
|
var label = isCR ? 'cr_number' : 'fl_number';
|
|
49
|
-
var showCheckIcon =
|
|
50
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t(label), required:
|
|
50
|
+
var showCheckIcon = isKWCountry || isOtherThanKWOrSACountry ? (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) >= minLength : (licenseNumberValue === null || licenseNumberValue === void 0 ? void 0 : licenseNumberValue.length) === length;
|
|
51
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t(label), required: isKWCountry, onChange: handleFLNumberChange, inputProps: { maxLength: length }, value: licenseNumberValue, endAdornment: showCheckIcon || (readOnly && licenseNumberValue) ? _jsx(CheckIcon, {}) : licenseNumberValue && _jsx(ClearIcon, { onClick: clearLicenseNumber }), placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }) }) }) })));
|
|
51
52
|
};
|
|
52
53
|
export default React.memo(LicenseNumber);
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
+
export declare const OtherThanKWOrSABusinessDataSchema: (isLeadIdPassed: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
selectedLicense: any;
|
|
5
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
selectedLicense: any;
|
|
9
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
10
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
11
|
+
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
12
|
+
selectedLicense: any;
|
|
13
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
14
|
+
}>>>;
|
|
2
15
|
export declare const BusinessDataSchema: (isLeadIdPassed: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
16
|
brandName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
17
|
selectedLicense: any;
|
|
@@ -11,6 +11,73 @@ var objectElements = {
|
|
|
11
11
|
}),
|
|
12
12
|
type: yup.string()
|
|
13
13
|
};
|
|
14
|
+
export var OtherThanKWOrSABusinessDataSchema = function (isLeadIdPassed) {
|
|
15
|
+
if (!isLeadIdPassed) {
|
|
16
|
+
return yup.object().shape({
|
|
17
|
+
brandName: yup
|
|
18
|
+
.string()
|
|
19
|
+
.test({
|
|
20
|
+
test: function (value) {
|
|
21
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 0)
|
|
22
|
+
return true;
|
|
23
|
+
if (value && value.length >= 3)
|
|
24
|
+
return true;
|
|
25
|
+
return this.createError({ message: 'enter_brand_name_english_chars_numbers_space' });
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
.required('enter_brand_name_english_chars_numbers_space'),
|
|
29
|
+
selectedLicense: yup.object().shape(objectElements).required(''),
|
|
30
|
+
licenseNumber: yup
|
|
31
|
+
.string()
|
|
32
|
+
.test({
|
|
33
|
+
test: function (value) {
|
|
34
|
+
var selectedLicense = this.parent.selectedLicense;
|
|
35
|
+
var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
|
|
36
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
37
|
+
if (length === 0)
|
|
38
|
+
return true;
|
|
39
|
+
if (isCR) {
|
|
40
|
+
return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_max_length' });
|
|
41
|
+
}
|
|
42
|
+
return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.required(''),
|
|
46
|
+
termAndConditionChecked: yup.boolean().isTrue('check_terms_cond').required('check_terms_cond')
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return yup.object().shape({
|
|
50
|
+
brandName: yup
|
|
51
|
+
.string()
|
|
52
|
+
.test({
|
|
53
|
+
test: function (value) {
|
|
54
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 0)
|
|
55
|
+
return true;
|
|
56
|
+
if (value && value.length >= 3)
|
|
57
|
+
return true;
|
|
58
|
+
return this.createError({ message: 'enter_brand_name_english_chars_numbers_space' });
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.required('enter_brand_name_english_chars_numbers_space'),
|
|
62
|
+
selectedLicense: yup.object().shape(objectElements).required(''),
|
|
63
|
+
licenseNumber: yup
|
|
64
|
+
.string()
|
|
65
|
+
.test({
|
|
66
|
+
test: function (value) {
|
|
67
|
+
var selectedLicense = this.parent.selectedLicense;
|
|
68
|
+
var isCR = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR;
|
|
69
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
70
|
+
if (length === 0)
|
|
71
|
+
return true;
|
|
72
|
+
if (isCR) {
|
|
73
|
+
return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'cr_max_length' });
|
|
74
|
+
}
|
|
75
|
+
return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: 'fl_max_length' });
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.required('')
|
|
79
|
+
});
|
|
80
|
+
};
|
|
14
81
|
export var BusinessDataSchema = function (isLeadIdPassed) {
|
|
15
82
|
if (!isLeadIdPassed) {
|
|
16
83
|
return yup.object().shape({
|
package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.js
CHANGED
|
@@ -47,6 +47,7 @@ var CollectIndividualInfo = function (_a) {
|
|
|
47
47
|
var isAr = useLanguage().isAr;
|
|
48
48
|
var individualData = data.individualData, otpData = data.otpData, responseData = data.responseData;
|
|
49
49
|
var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
|
|
50
|
+
var startWithNIDMissed = otpData.authFor === AuthForType.NATIONAL_ID_MISSED;
|
|
50
51
|
var contact = ((responseData === null || responseData === void 0 ? void 0 : responseData.leadData) || {}).contact;
|
|
51
52
|
var countryCode = individualData.countryCode;
|
|
52
53
|
var isEmailAvailable = (responseData || {}).isEmailAvailable;
|
|
@@ -71,6 +72,9 @@ var CollectIndividualInfo = function (_a) {
|
|
|
71
72
|
dispatch(resetIndividualScreen());
|
|
72
73
|
var code = (_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2;
|
|
73
74
|
var screen = startWithNID ? (isKW(code) ? 'CONNECT_EXPRESS_CIVIL_ID_STEP' : 'CONNECT_EXPRESS_NID_STEP') : 'CONNECT_EXPRESS_MOBILE_STEP';
|
|
75
|
+
if (startWithNIDMissed) {
|
|
76
|
+
screen = isKW(code) ? 'CONNECT_EXPRESS_CIVIL_ID_MISSED_STEP' : 'CONNECT_EXPRESS_NID_MISSED_STEP';
|
|
77
|
+
}
|
|
74
78
|
dispatch(handlePrevScreenStep(screen));
|
|
75
79
|
};
|
|
76
80
|
React.useEffect(function () {
|
|
@@ -58,7 +58,7 @@ var OTP = function () {
|
|
|
58
58
|
defaultValues: data.otpData,
|
|
59
59
|
mode: 'onChange'
|
|
60
60
|
});
|
|
61
|
-
var isNidAuth = data.otpData.authFor === AuthForType.
|
|
61
|
+
var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID_MISSED;
|
|
62
62
|
React.useEffect(function () {
|
|
63
63
|
if (error)
|
|
64
64
|
dispatch(clearError());
|
|
@@ -35,7 +35,7 @@ var OTPInput = function (_a) {
|
|
|
35
35
|
var otpControl = useController({ name: 'otp', control: control });
|
|
36
36
|
var _c = useAppSelector(connectExpressSelector), data = _c.data, error = _c.error;
|
|
37
37
|
var nidData = data.nidData;
|
|
38
|
-
var isNidAuth = data.otpData.authFor === AuthForType.
|
|
38
|
+
var isNidAuth = data.otpData.authFor === AuthForType.NATIONAL_ID_MISSED;
|
|
39
39
|
var handleOnOTPChange = function (otp) {
|
|
40
40
|
if (error)
|
|
41
41
|
dispatch(clearError());
|
|
@@ -76,7 +76,7 @@ var Mobile = function (_a) {
|
|
|
76
76
|
var t = useTranslation().t;
|
|
77
77
|
var isAr = useLanguage().isAr;
|
|
78
78
|
var dispatch = useAppDispatch();
|
|
79
|
-
var
|
|
79
|
+
var _f = useCountry(settingData.businessCountry.iso2), isKuwait = _f.isKuwait, isOther = _f.isOther;
|
|
80
80
|
var responseData = data.responseData, isLeadIdPassed = data.isLeadIdPassed;
|
|
81
81
|
var isLeadIdentityIdAvailable = !((_c = (_b = responseData === null || responseData === void 0 ? void 0 : responseData.leadData) === null || _b === void 0 ? void 0 : _b.identification) === null || _c === void 0 ? void 0 : _c.id);
|
|
82
82
|
var methods = useForm({
|
|
@@ -107,6 +107,6 @@ var Mobile = function (_a) {
|
|
|
107
107
|
var originalReadOnly = useFormReadOnly(methods);
|
|
108
108
|
var readOnly = useFormErrorAndUpdateReadOnly(methods, originalReadOnly);
|
|
109
109
|
var disabled = !methods.formState.isValid || !!error;
|
|
110
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { readOnly: readOnly['mobile'], show: true, countries: settingData.countries, onListOpen: handleCountryOpen, onListClose: handleCountryClose }) }), _jsxs(Collapse, __assign({ in: !anchor }, { children: [_jsx(TAC, { show: isLeadIdPassed, readOnly: readOnly['termAndConditionChecked'] }), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: isLeadIdPassed ? !isLeadIdentityIdAvailable : !methods.formState.isValid }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), isKuwait ? (_jsx(MobileButton, __assign({ disabled: loading, onClick: function () { return onBack(); }, icon: ICONS_NAMES.PACI_ICON }, { children: t('paci_button_label') }))) : (_jsx(AbsherButton, __assign({ disabled: loading, onClick: function () { return onBack(); } }, { children: t('absher_button_label') })))] }))] }))] })) })) }));
|
|
110
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { readOnly: readOnly['mobile'], show: true, countries: settingData.countries, onListOpen: handleCountryOpen, onListClose: handleCountryClose }) }), _jsxs(Collapse, __assign({ in: !anchor }, { children: [_jsx(TAC, { show: isLeadIdPassed, readOnly: readOnly['termAndConditionChecked'] }), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })), _jsxs(Collapse, __assign({ in: (isLeadIdPassed ? !isLeadIdentityIdAvailable : !methods.formState.isValid) && !isOther }, { children: [_jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), isKuwait ? (_jsx(MobileButton, __assign({ disabled: loading, onClick: function () { return onBack(); }, icon: ICONS_NAMES.PACI_ICON }, { children: t('paci_button_label') }))) : (_jsx(AbsherButton, __assign({ disabled: loading, onClick: function () { return onBack(); } }, { children: t('absher_button_label') })))] }))] }))] })) })) }));
|
|
111
111
|
};
|
|
112
112
|
export default React.memo(Mobile);
|
|
@@ -27,6 +27,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
27
27
|
import { useController, useFormContext } from 'react-hook-form';
|
|
28
28
|
import { styled, alpha } from '@mui/material/styles';
|
|
29
29
|
import Text from '../../../../components/Text';
|
|
30
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
30
31
|
import Collapse from '../../../../components/Collapse';
|
|
31
32
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
32
33
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
@@ -35,7 +36,7 @@ import { connectSelector } from '../../../app/connect/connectStore';
|
|
|
35
36
|
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
36
37
|
import Input from '../../../shared/Input';
|
|
37
38
|
import SimpleList from '../../../../components/SimpleList';
|
|
38
|
-
import { removeAllCharsFromNumber } from '../../../../utils';
|
|
39
|
+
import { isOtherThanKWOrSA, removeAllCharsFromNumber } from '../../../../utils';
|
|
39
40
|
import { useLanguage, useAppSelector } from '../../../../hooks';
|
|
40
41
|
import Search from '../../../shared/Search';
|
|
41
42
|
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
@@ -80,14 +81,15 @@ var InputStyled = styled(Input)(function () { return ({
|
|
|
80
81
|
}
|
|
81
82
|
}); });
|
|
82
83
|
var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
83
|
-
var _b, _c, _d;
|
|
84
|
+
var _b, _c, _d, _e;
|
|
84
85
|
var countries = _a.countries, readOnly = _a.readOnly, rest = __rest(_a, ["countries", "readOnly"]);
|
|
85
|
-
var
|
|
86
|
-
var
|
|
86
|
+
var _f = React.useState(countries || []), countriesCode = _f[0], setCountries = _f[1];
|
|
87
|
+
var _g = React.useState(null), anchorEl = _g[0], setAnchorEl = _g[1];
|
|
87
88
|
var t = useTranslation().t;
|
|
88
89
|
var isAr = useLanguage().isAr;
|
|
89
|
-
var
|
|
90
|
+
var _h = useFormContext(), control = _h.control, setValue = _h.setValue;
|
|
90
91
|
var loading = useAppSelector(connectSelector).loading;
|
|
92
|
+
var settingsStore = useAppSelector(settingsSelector);
|
|
91
93
|
var phoneControl = useController({ name: 'mobile', control: control });
|
|
92
94
|
var countryCodeControl = useController({ name: 'countryCode', control: control });
|
|
93
95
|
var countryCodeValue = countryCodeControl.field.value;
|
|
@@ -98,6 +100,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
98
100
|
var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
|
|
99
101
|
var isStartsWith5 = mobileValue.startsWith('5');
|
|
100
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]);
|
|
101
104
|
React.useEffect(function () {
|
|
102
105
|
if (mobileValue)
|
|
103
106
|
setValue('mobile', mobileValue, { shouldValidate: true });
|
|
@@ -144,7 +147,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
144
147
|
});
|
|
145
148
|
setCountries(filteredCountries);
|
|
146
149
|
};
|
|
147
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { minHeight: mobileValue ? '133px' : '0px' } }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(InputStyled, { inputProps: { maxLength: requiredLen }, type: 'tel', readOnly: !!anchorEl || readOnly, required: true, onClick: onCloseCountryList, onChange: onPhoneNumberChange, onEnterPressed: function (e) { return loading && e.preventDefault(); }, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () {
|
|
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 () {
|
|
148
151
|
if (readOnly)
|
|
149
152
|
return;
|
|
150
153
|
toggleCountryList();
|
|
@@ -24,7 +24,7 @@ import Collapse from '../../../../components/Collapse';
|
|
|
24
24
|
import { clearError, entitySelector, retrieveBoardStatus, updateEntityName } from '../../../app/entity/entityStore';
|
|
25
25
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
26
26
|
import Button from '../../../shared/Button';
|
|
27
|
-
import { EntityNameValidationSchema, EntityNameKWValidationSchema } from './validation';
|
|
27
|
+
import { EntityNameValidationSchema, EntityNameKWValidationSchema, EntityNameOtherCountryValidationSchema } from './validation';
|
|
28
28
|
import LegalName from './LegalName';
|
|
29
29
|
import LicenseNumber from './LicenseNumber';
|
|
30
30
|
import IssuingDate from './IssuingDate';
|
|
@@ -54,8 +54,15 @@ var EntityName = function (_a) {
|
|
|
54
54
|
var isCR = licenseType === BusinessType.CR;
|
|
55
55
|
var _h = data.verify.responseBody || {}, entity = _h.entity, flows = _h.flows;
|
|
56
56
|
var _j = entity || {}, AOA_file = _j.AOA_file, id = _j.id, documents = _j.documents, data_status = _j.data_status, data_verification = _j.data_verification, legal_name = _j.legal_name, type = _j.type, license = _j.license;
|
|
57
|
+
var getSchema = function () {
|
|
58
|
+
if (isSACountry)
|
|
59
|
+
return EntityNameValidationSchema();
|
|
60
|
+
if (isKWCountry)
|
|
61
|
+
return EntityNameKWValidationSchema();
|
|
62
|
+
return EntityNameOtherCountryValidationSchema();
|
|
63
|
+
};
|
|
57
64
|
var methods = useForm({
|
|
58
|
-
resolver: yupResolver(
|
|
65
|
+
resolver: yupResolver(getSchema()),
|
|
59
66
|
defaultValues: {
|
|
60
67
|
legalName: legalName,
|
|
61
68
|
licenseNumber: licenseNumber,
|
|
@@ -130,8 +137,8 @@ var EntityName = function (_a) {
|
|
|
130
137
|
dispatch(clearError());
|
|
131
138
|
}, [methods.formState.isValid]);
|
|
132
139
|
var disabled = !methods.formState.isValid || !!error || uploading || uploadingArticle;
|
|
133
|
-
var showLicenseNumber =
|
|
140
|
+
var showLicenseNumber = isKWCountry ? isCR : true;
|
|
134
141
|
var showUnifiedNumber = isSACountry ? isCR : false;
|
|
135
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: _jsx(LegalName, { readOnly: readOnly['legalName'] || (noneEditable['legal_name.en'] && noneEditable['legal_name.ar']), isVerified: isLegalNameVerified }) })), _jsx(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl }, { children: _jsx(EntityTypeList, { readOnly: readOnly['entityType'] || noneEditable['type'], onListOpen: function () { return handleEntityOpenClose(true); }, onListClose: function () { return handleEntityOpenClose(false); }, isVerified: isEntityTypeVerified }) })), _jsxs(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: [_jsx(LicenseNumber, { show: showLicenseNumber, readOnly: readOnly['licenseNumber'] || noneEditable['license.number'], isVerified: isLicenseNumberVerified }), _jsx(UnifiedNumber, { show: showUnifiedNumber, readOnly: readOnly['unifiedNumber'] || noneEditable['license.additional_info'], isVerified: isUnifiedNumberVerified })] })), _jsx(Collapse, __assign({ in: !expiryAnchorEl && !entityTypeAnchorEl }, { children: _jsx(IssuingDate, { onDateClicked: handleIssueDateOpenClose, readOnly: readOnly['issuingDate'] || noneEditable['license.issuing_date'], isVerified: isIssuingDateVerified }) })), _jsx(Collapse, __assign({ in: !issueAnchorEl && !entityTypeAnchorEl }, { children: _jsx(ExpiryDate, { onDateClicked: handleExpiryDateOpenClose, readOnly: readOnly['expiryDate'] || noneEditable['license.expiry_date'], isVerified: isExpiryDateVerified }) })), _jsxs(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: [_jsx(LicenseCertificate, { defaultFiles: defaultCertificateFiles, show:
|
|
142
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: _jsx(LegalName, { readOnly: readOnly['legalName'] || (noneEditable['legal_name.en'] && noneEditable['legal_name.ar']), isVerified: isLegalNameVerified }) })), _jsx(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl }, { children: _jsx(EntityTypeList, { readOnly: readOnly['entityType'] || noneEditable['type'], onListOpen: function () { return handleEntityOpenClose(true); }, onListClose: function () { return handleEntityOpenClose(false); }, isVerified: isEntityTypeVerified }) })), _jsxs(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: [_jsx(LicenseNumber, { show: showLicenseNumber, readOnly: readOnly['licenseNumber'] || noneEditable['license.number'], isVerified: isLicenseNumberVerified }), _jsx(UnifiedNumber, { show: showUnifiedNumber, readOnly: readOnly['unifiedNumber'] || noneEditable['license.additional_info'], isVerified: isUnifiedNumberVerified })] })), _jsx(Collapse, __assign({ in: !expiryAnchorEl && !entityTypeAnchorEl }, { children: _jsx(IssuingDate, { onDateClicked: handleIssueDateOpenClose, readOnly: readOnly['issuingDate'] || noneEditable['license.issuing_date'], isVerified: isIssuingDateVerified }) })), _jsx(Collapse, __assign({ in: !issueAnchorEl && !entityTypeAnchorEl }, { children: _jsx(ExpiryDate, { onDateClicked: handleExpiryDateOpenClose, readOnly: readOnly['expiryDate'] || noneEditable['license.expiry_date'], isVerified: isExpiryDateVerified }) })), _jsxs(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: [_jsx(LicenseCertificate, { defaultFiles: defaultCertificateFiles, show: isSACountry && isCR, readOnly: readOnly['certificateId'] || noneEditable['documents'] }), _jsx(Article, { defaultFile: defaultArticleFile, show: true, readOnly: readOnly['articleId'] || noneEditable['AOA_file_id'], isVerified: isArticleIdVerified })] })), _jsx(Collapse, __assign({ in: !expiryAnchorEl && !issueAnchorEl && !entityTypeAnchorEl }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
136
143
|
};
|
|
137
144
|
export default EntityName;
|
|
@@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
15
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
16
16
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
17
17
|
import { BusinessType } from '../../../../@types';
|
|
18
|
-
import {
|
|
18
|
+
import { isKW, isOtherThanKWOrSA, removeAllOtherThanCharsAndNumber } from '../../../../utils';
|
|
19
19
|
import { settingsSelector } from '../../../../app/settings';
|
|
20
20
|
import { CR_MIN_LICENSE_LENGTH, CR_NUMBER_MAX_LENGTH, FL_MIN_LICENSE_LENGTH, FL_NUMBER_ENTITY_LENGTH, KW_MAX_LICENSE_LENGTH, KW_MIN_LICENSE_LENGTH } from '../../../../constants';
|
|
21
21
|
import Collapse from '../../../../components/Collapse';
|
|
@@ -34,7 +34,8 @@ var LicenseNumber = function (_a) {
|
|
|
34
34
|
var entity = (data.verify.responseBody || {}).entity;
|
|
35
35
|
var type = data.entityNameData.licenseType;
|
|
36
36
|
var number = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.number;
|
|
37
|
-
var
|
|
37
|
+
var isKWCountry = React.useMemo(function () { return isKW(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
38
|
+
var isOtherCountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
38
39
|
var handleChange = function (_a) {
|
|
39
40
|
var target = _a.target;
|
|
40
41
|
if (bckError)
|
|
@@ -46,8 +47,8 @@ var LicenseNumber = function (_a) {
|
|
|
46
47
|
var licenseNumberValue = licenseNumberControl.field.value;
|
|
47
48
|
var error = (_c = licenseNumberControl.fieldState.error) === null || _c === void 0 ? void 0 : _c.message;
|
|
48
49
|
var isCR = type === BusinessType.CR;
|
|
49
|
-
var length =
|
|
50
|
-
var minLength =
|
|
50
|
+
var length = isKWCountry || isOtherCountry ? KW_MAX_LICENSE_LENGTH : isCR ? CR_NUMBER_MAX_LENGTH : FL_NUMBER_ENTITY_LENGTH;
|
|
51
|
+
var minLength = isKWCountry || isOtherCountry ? KW_MIN_LICENSE_LENGTH : isCR ? CR_MIN_LICENSE_LENGTH : FL_MIN_LICENSE_LENGTH;
|
|
51
52
|
return (_jsx(Collapse, __assign({ in: show && !!number }, { children: _jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { readOnly: readOnly, label: t('license_number_label'), onChange: handleChange, inputProps: { maxLength: length }, value: licenseNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } }, placeholder: isCR ? t('cr_number_hint') : t('fl_number_hint'), warningType: 'alert', warningMessage: error && t(error, { length: minLength }), endAdornment: _jsx(EndAdornment, { value: licenseNumberValue, isVerified: isVerified }) }) })) })));
|
|
52
53
|
};
|
|
53
54
|
export default React.memo(LicenseNumber);
|
|
@@ -58,3 +58,31 @@ export declare const EntityNameKWValidationSchema: () => yup.ObjectSchema<import
|
|
|
58
58
|
certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
59
59
|
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
60
60
|
}>>>;
|
|
61
|
+
export declare const EntityNameOtherCountryValidationSchema: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
62
|
+
legalName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
63
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
64
|
+
entityType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
65
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
66
|
+
issuingDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
67
|
+
expiryDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
68
|
+
certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
69
|
+
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
70
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
71
|
+
legalName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
72
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
73
|
+
entityType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
74
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
75
|
+
issuingDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
76
|
+
expiryDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
77
|
+
certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
78
|
+
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
79
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
80
|
+
legalName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
81
|
+
licenseType: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
82
|
+
entityType: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
83
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
84
|
+
issuingDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
85
|
+
expiryDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
86
|
+
certificateId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
87
|
+
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
88
|
+
}>>>;
|
|
@@ -89,3 +89,41 @@ export var EntityNameKWValidationSchema = function () {
|
|
|
89
89
|
articleId: yup.string().optional()
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
|
+
export var EntityNameOtherCountryValidationSchema = function () {
|
|
93
|
+
return yup.object().shape({
|
|
94
|
+
legalName: yup
|
|
95
|
+
.string()
|
|
96
|
+
.required('')
|
|
97
|
+
.test({
|
|
98
|
+
test: function (value) {
|
|
99
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
100
|
+
if (length === 0)
|
|
101
|
+
return true;
|
|
102
|
+
return length >= 3 ? true : this.createError({ message: 'enter_legal_name_min_three_chars' });
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
licenseType: yup.string().optional(),
|
|
106
|
+
entityType: yup.string().required('entity_type_required'),
|
|
107
|
+
licenseNumber: yup
|
|
108
|
+
.string()
|
|
109
|
+
.when('licenseType', function (licenseType) {
|
|
110
|
+
var isCR = licenseType === BusinessType.CR;
|
|
111
|
+
return yup
|
|
112
|
+
.string()
|
|
113
|
+
.required('')
|
|
114
|
+
.test({
|
|
115
|
+
test: function (value) {
|
|
116
|
+
var length = (value === null || value === void 0 ? void 0 : value.length) || 0;
|
|
117
|
+
if (length === 0)
|
|
118
|
+
return true;
|
|
119
|
+
return length >= KW_MIN_LICENSE_LENGTH ? true : this.createError({ message: isCR ? 'cr_kw_max_length' : 'fl_max_length' });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
})
|
|
123
|
+
.required(''),
|
|
124
|
+
issuingDate: yup.string().required('choose_any_issuing_date'),
|
|
125
|
+
expiryDate: yup.string().required('choose_any_expiry_date'),
|
|
126
|
+
certificateId: yup.array().optional(),
|
|
127
|
+
articleId: yup.string().optional()
|
|
128
|
+
});
|
|
129
|
+
};
|