@tap-payments/auth-jsconnect 2.1.44-test → 2.1.45-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/form.d.ts +8 -5
- package/build/api/account.d.ts +5 -0
- package/build/api/account.js +9 -1
- package/build/api/auth.d.ts +8 -4
- package/build/api/auth.js +18 -2
- package/build/api/index.d.ts +6 -2
- package/build/api/lead.d.ts +1 -0
- package/build/api/lead.js +10 -1
- package/build/assets/locales/ar.json +2 -0
- package/build/assets/locales/en.json +2 -0
- package/build/components/Lottie/Lottie.d.ts +320 -0
- package/build/components/Lottie/Lottie.js +3 -1
- package/build/components/Lottie/files/account_creating.json +732 -0
- package/build/constants/api.d.ts +3 -0
- package/build/constants/api.js +8 -2
- package/build/constants/app.d.ts +5 -2
- package/build/constants/app.js +60 -4
- package/build/features/app/auth/authStore.d.ts +3 -3
- package/build/features/app/business/businessStore.d.ts +1 -0
- package/build/features/app/connect/connectStore.d.ts +1 -0
- package/build/features/app/connect/connectStore.js +3 -2
- package/build/features/app/connectExpress/connectExpressStore.d.ts +61 -6
- package/build/features/app/connectExpress/connectExpressStore.js +614 -66
- package/build/features/connect/screens/Merchant/Merchant.js +12 -10
- package/build/features/connectExpress/ConnectExpress.js +1 -1
- package/build/features/connectExpress/screens/CivilID/CivilID.js +3 -3
- package/build/features/connectExpress/screens/CivilIDMissed/CivilID.d.ts +5 -0
- package/build/features/connectExpress/screens/CivilIDMissed/CivilID.js +53 -0
- package/build/features/connectExpress/screens/CivilIDMissed/IDNumber.d.ts +7 -0
- package/build/features/connectExpress/screens/CivilIDMissed/IDNumber.js +55 -0
- package/build/features/connectExpress/screens/CivilIDMissed/index.d.ts +3 -0
- package/build/features/connectExpress/screens/CivilIDMissed/index.js +2 -0
- package/build/features/connectExpress/screens/CivilIDMissed/validation.d.ts +8 -0
- package/build/features/connectExpress/screens/CivilIDMissed/validation.js +4 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.d.ts +8 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.js +142 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/CollectBusinessInfo.d.ts +5 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/CollectBusinessInfo.js +77 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseList.d.ts +8 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseList.js +144 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseNumber.d.ts +7 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseNumber.js +52 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +34 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.js +94 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/index.d.ts +3 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/index.js +2 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/validation.d.ts +27 -0
- package/build/features/connectExpress/screens/CollectBusinessInfo/validation.js +79 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.d.ts +5 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.js +89 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/Email.d.ts +8 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/Email.js +113 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/MobileNumber.d.ts +10 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/MobileNumber.js +149 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/Name.d.ts +6 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/Name.js +45 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/index.d.ts +3 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/index.js +2 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/validation.d.ts +14 -0
- package/build/features/connectExpress/screens/CollectIndividualInfo/validation.js +31 -0
- package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.d.ts +5 -0
- package/build/features/connectExpress/screens/CreateAccountLoader/CreateAccountLoader.js +61 -0
- package/build/features/connectExpress/screens/CreateAccountLoader/index.d.ts +2 -0
- package/build/features/connectExpress/screens/CreateAccountLoader/index.js +2 -0
- package/build/features/connectExpress/screens/IdentityOTP/OTP.d.ts +5 -0
- package/build/features/connectExpress/screens/IdentityOTP/OTP.js +87 -0
- package/build/features/connectExpress/screens/IdentityOTP/OTPInput.d.ts +5 -0
- package/build/features/connectExpress/screens/IdentityOTP/OTPInput.js +52 -0
- package/build/features/connectExpress/screens/IdentityOTP/index.d.ts +3 -0
- package/build/features/connectExpress/screens/IdentityOTP/index.js +2 -0
- package/build/features/connectExpress/screens/IdentityOTP/validation.d.ts +8 -0
- package/build/features/connectExpress/screens/IdentityOTP/validation.js +4 -0
- package/build/features/connectExpress/screens/IdentityVerifyPACI/VerifyPACI.d.ts +5 -0
- package/build/features/connectExpress/screens/IdentityVerifyPACI/VerifyPACI.js +34 -0
- package/build/features/connectExpress/screens/IdentityVerifyPACI/index.d.ts +3 -0
- package/build/features/connectExpress/screens/IdentityVerifyPACI/index.js +2 -0
- package/build/features/connectExpress/screens/Mobile/Mobile.js +0 -3
- package/build/features/connectExpress/screens/NID/NID.js +7 -6
- package/build/features/connectExpress/screens/NIDMissed/DOB.d.ts +6 -0
- package/build/features/connectExpress/screens/NIDMissed/DOB.js +47 -0
- package/build/features/connectExpress/screens/NIDMissed/IDNumber.d.ts +6 -0
- package/build/features/connectExpress/screens/NIDMissed/IDNumber.js +60 -0
- package/build/features/connectExpress/screens/NIDMissed/NID.d.ts +5 -0
- package/build/features/connectExpress/screens/NIDMissed/NID.js +59 -0
- package/build/features/connectExpress/screens/NIDMissed/index.d.ts +3 -0
- package/build/features/connectExpress/screens/NIDMissed/index.js +2 -0
- package/build/features/connectExpress/screens/NIDMissed/validation.d.ts +11 -0
- package/build/features/connectExpress/screens/NIDMissed/validation.js +9 -0
- package/build/features/connectExpress/screens/OTP/OTP.js +10 -6
- package/build/features/connectExpress/screens/OTP/OTPInput.js +7 -6
- package/build/features/connectExpress/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.d.ts +3 -0
- package/build/features/connectExpress/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +119 -0
- package/build/features/connectExpress/screens/SuccessWithFlowButtons/index.d.ts +2 -0
- package/build/features/connectExpress/screens/SuccessWithFlowButtons/index.js +2 -0
- package/build/features/connectExpress/screens/VerifyPACI/VerifyPACI.js +7 -68
- package/build/features/featuresScreens.js +40 -0
- package/build/features/shared/FlowButtons/FlowButtons.d.ts +4 -0
- package/build/features/shared/FlowButtons/FlowButtons.js +6 -0
- package/build/features/shared/FlowButtons/index.d.ts +2 -0
- package/build/features/shared/FlowButtons/index.js +2 -0
- package/package.json +1 -1
|
@@ -36,17 +36,17 @@ var ListType;
|
|
|
36
36
|
ListType["BrandList"] = "BrandList";
|
|
37
37
|
})(ListType || (ListType = {}));
|
|
38
38
|
var Merchant = function (_a) {
|
|
39
|
-
var _b;
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
39
|
+
var _b, _c;
|
|
40
|
+
var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
|
|
41
|
+
var _e = React.useState(false), isRequiredNewBrand = _e[0], setIsRequiredNewBrand = _e[1];
|
|
42
|
+
var _f = useAppSelector(connectSelector), data = _f.data, loading = _f.loading, error = _f.error;
|
|
43
|
+
var _g = data.brandData, brandName = _g.brandName, selectedBrandItem = _g.selectedBrandItem, termAndConditionChecked = _g.termAndConditionChecked, responseBody = _g.responseBody, salesChannels = _g.salesChannels, segment = _g.segment, teamSize = _g.teamSize;
|
|
44
44
|
var brandList = (responseBody || {}).brand_list;
|
|
45
|
-
var
|
|
45
|
+
var _h = React.useState(), listActive = _h[0], setListActive = _h[1];
|
|
46
46
|
var methods = useForm({
|
|
47
47
|
resolver: yupResolver(MerchantValidationSchema(isRequiredNewBrand)),
|
|
48
48
|
defaultValues: {
|
|
49
|
-
brandName: brandName,
|
|
49
|
+
brandName: brandName || ((_b = selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.name) === null || _b === void 0 ? void 0 : _b.en),
|
|
50
50
|
selectedBrandItem: selectedBrandItem,
|
|
51
51
|
termAndConditionChecked: termAndConditionChecked,
|
|
52
52
|
salesChannels: salesChannels,
|
|
@@ -68,7 +68,9 @@ var Merchant = function (_a) {
|
|
|
68
68
|
React.useEffect(function () {
|
|
69
69
|
methods.setValue('segment', segment);
|
|
70
70
|
methods.setValue('teamSize', teamSize);
|
|
71
|
-
|
|
71
|
+
if (brandName)
|
|
72
|
+
methods.trigger('brandName');
|
|
73
|
+
}, [segment, teamSize, brandName]);
|
|
72
74
|
React.useEffect(function () {
|
|
73
75
|
if (error)
|
|
74
76
|
dispatch(clearError());
|
|
@@ -81,8 +83,8 @@ var Merchant = function (_a) {
|
|
|
81
83
|
if (termAndConditionChecked === true)
|
|
82
84
|
methods.setValue('termAndConditionChecked', termAndConditionChecked);
|
|
83
85
|
}, [termAndConditionChecked]);
|
|
84
|
-
var brandErrChecks = !!
|
|
85
|
-
var disabled = brandErrChecks || brandNameChecking || ((
|
|
86
|
+
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
87
|
+
var disabled = brandErrChecks || brandNameChecking || ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.response_code) === '5';
|
|
86
88
|
var hasBrandList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
|
|
87
89
|
var isOtherBrand = (brandListItem === null || brandListItem === void 0 ? void 0 : brandListItem.id) === 'other' && hasBrandList;
|
|
88
90
|
var isNewBrand = (brandList === null || brandList === void 0 ? void 0 : brandList.length) === 0 || BrandList === undefined;
|
|
@@ -90,7 +90,7 @@ var ConnectExpress = memo(function (_a) {
|
|
|
90
90
|
return [2];
|
|
91
91
|
dispatch(setIsLeadIdPassed(true));
|
|
92
92
|
dispatch(setLeadId(leadId));
|
|
93
|
-
return [4, API.leadService.
|
|
93
|
+
return [4, API.leadService.retrieveLeadIdentity(leadId)];
|
|
94
94
|
case 1:
|
|
95
95
|
leadData = _a.sent();
|
|
96
96
|
dispatch(setResponseData({ leadData: leadData }));
|
|
@@ -18,7 +18,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
|
|
|
18
18
|
import { civilIDValidationSchema } from './validation';
|
|
19
19
|
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
20
20
|
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
21
|
-
import { clearError, connectExpressSelector,
|
|
21
|
+
import { clearError, connectExpressSelector, createCivilIdAuthAsync, resetStore } from '../../../app/connectExpress/connectExpressStore';
|
|
22
22
|
import Form from '../../../../components/Form';
|
|
23
23
|
import Button, { MobileButton } from '../../../shared/Button';
|
|
24
24
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
@@ -73,10 +73,10 @@ var CivilID = function (_a) {
|
|
|
73
73
|
dispatch(resetStore());
|
|
74
74
|
}, []);
|
|
75
75
|
var onSubmit = function (data) {
|
|
76
|
-
dispatch(
|
|
76
|
+
dispatch(createCivilIdAuthAsync(data));
|
|
77
77
|
};
|
|
78
78
|
var onBack = function () {
|
|
79
|
-
dispatch(handlePrevScreenStep(
|
|
79
|
+
dispatch(handlePrevScreenStep());
|
|
80
80
|
};
|
|
81
81
|
var disabled = !methods.formState.isValid || !!error;
|
|
82
82
|
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: methods.formState.isValid ? 7.5 : 0, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, 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') }))] }))] })) })) }));
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { styled } from '@mui/material/styles';
|
|
16
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
17
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
|
+
import { civilIDValidationSchema } from './validation';
|
|
19
|
+
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
20
|
+
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
21
|
+
import { clearError, connectExpressSelector, createCivilIDAuthIdentityAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
22
|
+
import Form from '../../../../components/Form';
|
|
23
|
+
import Button from '../../../shared/Button';
|
|
24
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
25
|
+
import IDNumber from './IDNumber';
|
|
26
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flexDirection: 'column'
|
|
29
|
+
}); });
|
|
30
|
+
var CivilID = function (_a) {
|
|
31
|
+
var isAr = useLanguage().isAr;
|
|
32
|
+
var dispatch = useAppDispatch();
|
|
33
|
+
var t = useTranslation().t;
|
|
34
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
35
|
+
var methods = useForm({
|
|
36
|
+
resolver: yupResolver(civilIDValidationSchema),
|
|
37
|
+
defaultValues: data.civilIdData,
|
|
38
|
+
mode: 'onChange'
|
|
39
|
+
});
|
|
40
|
+
React.useEffect(function () {
|
|
41
|
+
if (error)
|
|
42
|
+
dispatch(clearError());
|
|
43
|
+
}, [methods.formState.isValid]);
|
|
44
|
+
var onSubmit = function (data) {
|
|
45
|
+
dispatch(createCivilIDAuthIdentityAsync(data));
|
|
46
|
+
};
|
|
47
|
+
var onBack = function () {
|
|
48
|
+
dispatch(handlePrevScreenStep());
|
|
49
|
+
};
|
|
50
|
+
var disabled = !methods.formState.isValid || !!error;
|
|
51
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(IDNumber, { sx: { mb: methods.formState.isValid ? 7.5 : 0, transition: 'mb 0.3s' } }), _jsx(Button, __assign({ loading: loading, isAr: isAr, onBackClicked: onBack, disabled: disabled, error: t(error || '') }, { children: t('next') }))] })) })) }));
|
|
52
|
+
};
|
|
53
|
+
export default React.memo(CivilID);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
interface IDNumberProps {
|
|
4
|
+
sx: SxProps<Theme> | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<IDNumberProps & React.RefAttributes<unknown>>>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import Box from '@mui/material/Box';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
17
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
18
|
+
import Text from '../../../../components/Text';
|
|
19
|
+
import Input from '../../../shared/Input';
|
|
20
|
+
import ClearIcon from '../../../shared/ClearIcon';
|
|
21
|
+
import CheckIcon from '../../../shared/CheckIcon';
|
|
22
|
+
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
23
|
+
import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
|
|
24
|
+
import { CIVIL_ID_NUMBER_LENGTH } from '../../../../constants';
|
|
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 sx = _a.sx;
|
|
40
|
+
var t = useTranslation().t;
|
|
41
|
+
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
42
|
+
var civilIdControl = useController({ control: control, name: 'civilId' });
|
|
43
|
+
var handleIdChange = function (_a) {
|
|
44
|
+
var target = _a.target;
|
|
45
|
+
var value = removeAllOtherThanCharsAndNumber(target.value);
|
|
46
|
+
civilIdControl.field.onChange(value);
|
|
47
|
+
};
|
|
48
|
+
var clearIdNumber = function () {
|
|
49
|
+
civilIdControl.field.onChange('');
|
|
50
|
+
};
|
|
51
|
+
var idValue = civilIdControl.field.value;
|
|
52
|
+
var error = (_b = civilIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
53
|
+
return (_jsxs(ScreenContainer, __assign({ ref: ref, sx: sx }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('enter_civil_id') }) }), _jsx(Input, { dir: 'ltr', type: 'text', inputProps: { maxLength: CIVIL_ID_NUMBER_LENGTH }, onChange: handleIdChange, value: idValue, endAdornment: !error && idValue ? _jsx(CheckIcon, {}) : idValue && _jsx(ClearIcon, { onClick: clearIdNumber }), placeholder: t('civil_id_placeholder'), warningType: 'alert', warningMessage: error && t(error), required: true })] })));
|
|
54
|
+
});
|
|
55
|
+
export default React.memo(IDNumber);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const civilIDValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
civilId: 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
|
+
civilId: 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
|
+
civilId: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
}>>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface BrandNameProps {
|
|
3
|
+
show: boolean;
|
|
4
|
+
fetchingBrandName: (flag: boolean) => void;
|
|
5
|
+
brandNameChecking: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.MemoExoticComponent<({ show, brandNameChecking, fetchingBrandName }: BrandNameProps) => JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,142 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import * as React from 'react';
|
|
50
|
+
import { useTranslation } from 'react-i18next';
|
|
51
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
52
|
+
import { debounce } from 'lodash-es';
|
|
53
|
+
import axios from 'axios';
|
|
54
|
+
import Box from '@mui/material/Box';
|
|
55
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
56
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
57
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
58
|
+
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
59
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
60
|
+
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
61
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
62
|
+
import Text from '../../../../components/Text';
|
|
63
|
+
import Tooltip from '../../../../components/Tooltip';
|
|
64
|
+
import Collapse from '../../../../components/Collapse';
|
|
65
|
+
import Input from '../../../shared/Input';
|
|
66
|
+
import ClearIcon from '../../../shared/ClearIcon';
|
|
67
|
+
import CheckIcon from '../../../shared/CheckIcon';
|
|
68
|
+
import { checkBrandNameAvailabilityAsync, connectExpressSelector } from '../../../app/connectExpress/connectExpressStore';
|
|
69
|
+
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
70
|
+
var theme = _a.theme;
|
|
71
|
+
return ({
|
|
72
|
+
display: 'flex',
|
|
73
|
+
justifyContent: 'space-between',
|
|
74
|
+
padding: theme.spacing(0, 2.5, 1, 2.5)
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
var InputLabelStyled = styled(Text)(function (_a) {
|
|
78
|
+
var theme = _a.theme;
|
|
79
|
+
return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
|
|
80
|
+
});
|
|
81
|
+
var InfoOutlinedIconStyled = styled(InfoOutlinedIcon)(function (_a) {
|
|
82
|
+
var theme = _a.theme;
|
|
83
|
+
return ({
|
|
84
|
+
width: theme.spacing(2.75),
|
|
85
|
+
height: theme.spacing(2.125),
|
|
86
|
+
cursor: 'pointer',
|
|
87
|
+
color: alpha(theme.palette.text.primary, 0.4)
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
var InfoIconStyled = styled(InfoIcon)(function (_a) {
|
|
91
|
+
var theme = _a.theme;
|
|
92
|
+
return ({
|
|
93
|
+
width: theme.spacing(2.75),
|
|
94
|
+
height: theme.spacing(2.125),
|
|
95
|
+
cursor: 'pointer',
|
|
96
|
+
color: alpha(theme.palette.text.primary, 0.4)
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
var cancelToken = null;
|
|
100
|
+
var BrandName = function (_a) {
|
|
101
|
+
var _b;
|
|
102
|
+
var show = _a.show, brandNameChecking = _a.brandNameChecking, fetchingBrandName = _a.fetchingBrandName;
|
|
103
|
+
var dispatch = useAppDispatch();
|
|
104
|
+
var _c = React.useState(false), isHovered = _c[0], setIsHovered = _c[1];
|
|
105
|
+
var t = useTranslation().t;
|
|
106
|
+
var data = useAppSelector(connectExpressSelector).data;
|
|
107
|
+
var control = useFormContext().control;
|
|
108
|
+
var brandControl = useController({ control: control, name: 'brandName' });
|
|
109
|
+
var brandNameValue = brandControl.field.value;
|
|
110
|
+
var error = (_b = brandControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
111
|
+
var checkBrand = debounce(function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var onSuccess;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
if (cancelToken) {
|
|
115
|
+
cancelToken.cancel('Aborted');
|
|
116
|
+
}
|
|
117
|
+
cancelToken = axios.CancelToken.source();
|
|
118
|
+
onSuccess = function () { return fetchingBrandName(false); };
|
|
119
|
+
dispatch(checkBrandNameAvailabilityAsync({ name: value, cancelToken: cancelToken.token, onSuccess: onSuccess }));
|
|
120
|
+
return [2];
|
|
121
|
+
});
|
|
122
|
+
}); }, 500);
|
|
123
|
+
var handleBrandNameChange = function (_a) {
|
|
124
|
+
var target = _a.target;
|
|
125
|
+
var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
|
|
126
|
+
brandControl.field.onChange(value);
|
|
127
|
+
};
|
|
128
|
+
React.useEffect(function () {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
var isValid = brandNameValue && !error && brandNameValue.length > 2;
|
|
131
|
+
var brand = (_d = (_c = (_b = (_a = data.responseData) === null || _a === void 0 ? void 0 : _a.leadData) === null || _b === void 0 ? void 0 : _b.brand) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.en;
|
|
132
|
+
if (isValid && (brandNameValue === null || brandNameValue === void 0 ? void 0 : brandNameValue.toLowerCase()) != brand) {
|
|
133
|
+
fetchingBrandName(true);
|
|
134
|
+
checkBrand(brandNameValue);
|
|
135
|
+
}
|
|
136
|
+
}, [brandNameValue, error]);
|
|
137
|
+
var clearBrandName = function () {
|
|
138
|
+
brandControl.field.onChange('');
|
|
139
|
+
};
|
|
140
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 2.5 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue || '', placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
|
|
141
|
+
};
|
|
142
|
+
export default React.memo(BrandName);
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { useForm, FormProvider } from 'react-hook-form';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
17
|
+
import { useAppDispatch, useAppSelector, useSetFromDefaultValues, useLanguage } from '../../../../hooks';
|
|
18
|
+
import { isSA } from '../../../../utils';
|
|
19
|
+
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
20
|
+
import Form from '../../../../components/Form';
|
|
21
|
+
import Collapse from '../../../../components/Collapse';
|
|
22
|
+
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
23
|
+
import { connectExpressSelector, clearError, updateLeadBusinessDataAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
24
|
+
import Button from '../../../shared/Button';
|
|
25
|
+
import { KWBusinessDataSchema, BusinessDataSchema } from './validation';
|
|
26
|
+
import LicenseList from './LicenseList';
|
|
27
|
+
import BrandName from './BrandName';
|
|
28
|
+
var CollectBusinessInfo = function (_a) {
|
|
29
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
30
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
31
|
+
var responseData = data.responseData, businessData = data.businessData;
|
|
32
|
+
var isBrandNameAvailable = (responseData || {}).isBrandNameAvailable;
|
|
33
|
+
var selectedLicense = businessData.selectedLicense, licenseNumber = businessData.licenseNumber, brandName = businessData.brandName;
|
|
34
|
+
var t = useTranslation().t;
|
|
35
|
+
var isAr = useLanguage().isAr;
|
|
36
|
+
var dispatch = useAppDispatch();
|
|
37
|
+
var _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
|
|
38
|
+
var _d = React.useState(false), brandNameChecking = _d[0], setBrandNameChecking = _d[1];
|
|
39
|
+
var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
40
|
+
var methods = useForm({
|
|
41
|
+
resolver: yupResolver(!isSACountry ? KWBusinessDataSchema : BusinessDataSchema),
|
|
42
|
+
defaultValues: {
|
|
43
|
+
brandName: brandName,
|
|
44
|
+
selectedLicense: selectedLicense,
|
|
45
|
+
licenseNumber: licenseNumber
|
|
46
|
+
},
|
|
47
|
+
mode: 'onChange'
|
|
48
|
+
});
|
|
49
|
+
useSetFromDefaultValues(methods, data.businessData);
|
|
50
|
+
React.useEffect(function () {
|
|
51
|
+
if (error)
|
|
52
|
+
dispatch(clearError());
|
|
53
|
+
}, [methods.formState.isValid]);
|
|
54
|
+
React.useEffect(function () {
|
|
55
|
+
if (isBrandNameAvailable == false)
|
|
56
|
+
methods.setError('brandName', { message: 'brand_name_already_exist' });
|
|
57
|
+
}, [responseData]);
|
|
58
|
+
var onSubmit = function (data) {
|
|
59
|
+
var dataValues = {
|
|
60
|
+
brandName: data.brandName,
|
|
61
|
+
selectedLicense: data.selectedLicense,
|
|
62
|
+
licenseNumber: data.licenseNumber
|
|
63
|
+
};
|
|
64
|
+
dispatch(updateLeadBusinessDataAsync(dataValues));
|
|
65
|
+
};
|
|
66
|
+
var onBack = function () {
|
|
67
|
+
dispatch(handlePrevScreenStep());
|
|
68
|
+
};
|
|
69
|
+
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
70
|
+
var disabled = brandErrChecks || brandNameChecking || isBrandNameAvailable == false;
|
|
71
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandName, { show: true, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(LicenseList, { onListOpen: function () {
|
|
72
|
+
setListActive(true);
|
|
73
|
+
}, onListClose: function () {
|
|
74
|
+
setListActive(false);
|
|
75
|
+
} }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
76
|
+
};
|
|
77
|
+
export default React.memo(CollectBusinessInfo);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface LicenseListProps {
|
|
3
|
+
onSelectLicense?: (number: string) => void;
|
|
4
|
+
onListOpen?: () => void;
|
|
5
|
+
onListClose?: () => void;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: React.MemoExoticComponent<({ ...rest }: LicenseListProps) => JSX.Element>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,144 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import { useTranslation } from 'react-i18next';
|
|
26
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
27
|
+
import Box from '@mui/material/Box';
|
|
28
|
+
import { styled } from '@mui/material/styles';
|
|
29
|
+
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
30
|
+
import { BusinessType } from '../../../../@types';
|
|
31
|
+
import { isSA } from '../../../../utils';
|
|
32
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
33
|
+
import { OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../../constants';
|
|
34
|
+
import SimpleList from '../../../../components/SimpleList';
|
|
35
|
+
import Text from '../../../../components/Text';
|
|
36
|
+
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
37
|
+
import Collapse from '../../../../components/Collapse';
|
|
38
|
+
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
39
|
+
import Input from '../../../shared/Input';
|
|
40
|
+
import CheckIcon from '../../../shared/CheckIcon';
|
|
41
|
+
import { connectExpressSelector, clearError } from '../../../app/connectExpress/connectExpressStore';
|
|
42
|
+
import LicenseNumber from './LicenseNumber';
|
|
43
|
+
import LicenseType from './LicenseType';
|
|
44
|
+
var InputStyled = styled(Input)(function (_a) {
|
|
45
|
+
var theme = _a.theme;
|
|
46
|
+
return ({
|
|
47
|
+
marginBottom: theme.spacing(2.5),
|
|
48
|
+
'& .MuiInputBase-input': {
|
|
49
|
+
cursor: 'pointer'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
var LicenseContainer = styled(Box)(function () { return ({
|
|
54
|
+
display: 'flex'
|
|
55
|
+
}); });
|
|
56
|
+
var LicenseNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
|
|
57
|
+
var theme = _a.theme, isSelected = _a.isSelected;
|
|
58
|
+
return (__assign(__assign({ display: 'flex', color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
|
|
59
|
+
});
|
|
60
|
+
var LicenseList = function (_a) {
|
|
61
|
+
var rest = __rest(_a, []);
|
|
62
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, error = _b.error;
|
|
63
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
64
|
+
var businessData = data.businessData, responseData = data.responseData;
|
|
65
|
+
var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
|
|
66
|
+
var t = useTranslation().t;
|
|
67
|
+
var isAr = useLanguage().isAr;
|
|
68
|
+
var dispatch = useAppDispatch();
|
|
69
|
+
var _d = useFormContext(), setValue = _d.setValue, control = _d.control;
|
|
70
|
+
var selectedLicenseControl = useController({ control: control, name: 'selectedLicense' });
|
|
71
|
+
var selectedLicense = businessData.selectedLicense, licenseNumber = businessData.licenseNumber;
|
|
72
|
+
var licenseList = (responseData || { licenseList: [] }).licenseList;
|
|
73
|
+
var country_code = settingsData.businessCountry.iso2;
|
|
74
|
+
var onOpenLicenseList = function (event) {
|
|
75
|
+
var _a;
|
|
76
|
+
setAnchorEl(event.currentTarget);
|
|
77
|
+
(_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
78
|
+
};
|
|
79
|
+
var onCloseLicenseList = function () {
|
|
80
|
+
var _a;
|
|
81
|
+
setAnchorEl(null);
|
|
82
|
+
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
83
|
+
};
|
|
84
|
+
var isSACountry = React.useMemo(function () { return isSA(country_code); }, [country_code]);
|
|
85
|
+
React.useEffect(function () {
|
|
86
|
+
if ((licenseList || []).length > 0)
|
|
87
|
+
setValue('licenseList', licenseList);
|
|
88
|
+
}, [licenseList]);
|
|
89
|
+
React.useEffect(function () {
|
|
90
|
+
if ((licenseList || []).length > 0) {
|
|
91
|
+
if (!!selectedLicense) {
|
|
92
|
+
setValue('selectedLicense', selectedLicense, { shouldValidate: true });
|
|
93
|
+
setValue('licenseNumber', licenseNumber, { shouldValidate: true });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, [licenseList, selectedLicense]);
|
|
97
|
+
React.useEffect(function () {
|
|
98
|
+
if (!!country_code) {
|
|
99
|
+
var isNonSA = !isSA(country_code);
|
|
100
|
+
if (isNonSA) {
|
|
101
|
+
var license = (selectedLicense === null || selectedLicense === void 0 ? void 0 : selectedLicense.type) === BusinessType.CR ? OTHER_CR_LICENSE : OTHER_FL_LICENSE;
|
|
102
|
+
setValue('selectedLicense', license, { shouldValidate: true });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, [country_code]);
|
|
106
|
+
var getLicenseNumber = function (item) {
|
|
107
|
+
var _a;
|
|
108
|
+
return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) || '';
|
|
109
|
+
};
|
|
110
|
+
var getLicenseName = function (item) {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === BusinessType.FL && !isOtherLicense(item))
|
|
113
|
+
return t('future_work');
|
|
114
|
+
return t((isAr ? (_a = item === null || item === void 0 ? void 0 : item.legal_name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.legal_name) === null || _b === void 0 ? void 0 : _b.en) || '');
|
|
115
|
+
};
|
|
116
|
+
var isOtherLicense = function (item) {
|
|
117
|
+
var _a, _b;
|
|
118
|
+
return ((_a = item === null || item === void 0 ? void 0 : item.license) === null || _a === void 0 ? void 0 : _a.number) === 'other_fl' || ((_b = item === null || item === void 0 ? void 0 : item.license) === null || _b === void 0 ? void 0 : _b.number) === 'other_cr';
|
|
119
|
+
};
|
|
120
|
+
var onSelectItem = function (license) {
|
|
121
|
+
if (error)
|
|
122
|
+
dispatch(clearError());
|
|
123
|
+
selectedLicenseControl.field.onChange(license);
|
|
124
|
+
if (isOtherLicense(license))
|
|
125
|
+
setValue('licenseNumber', '', { shouldValidate: true });
|
|
126
|
+
else
|
|
127
|
+
setValue('licenseNumber', getLicenseNumber(license), { shouldValidate: true });
|
|
128
|
+
onCloseLicenseList();
|
|
129
|
+
};
|
|
130
|
+
var getLicenseFullName = function (item) {
|
|
131
|
+
if (isAr)
|
|
132
|
+
return _jsx("span", { children: "".concat(getLicenseName(item), " - ").concat(getLicenseNumber(item)) });
|
|
133
|
+
return _jsx("span", { children: "".concat(getLicenseNumber(item), " - ").concat(getLicenseName(item)) });
|
|
134
|
+
};
|
|
135
|
+
var show = !anchorEl;
|
|
136
|
+
var selected = selectedLicenseControl.field.value;
|
|
137
|
+
var licenseReadonly = !isOtherLicense(selected);
|
|
138
|
+
var isCR = (selected === null || selected === void 0 ? void 0 : selected.type) === BusinessType.CR;
|
|
139
|
+
var flValue = isOtherLicense(selected) ? t(getLicenseName(selected)) : getLicenseNumber(selected);
|
|
140
|
+
return (_jsxs(ScreenContainer, { children: [_jsxs(Collapse, __assign({ in: isSACountry }, { children: [_jsx(InputStyled, { label: t('choose_any_license'), readOnly: true, 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) {
|
|
141
|
+
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, {})] }));
|
|
142
|
+
} }) }))] })), _jsx(LicenseType, { show: show && !isSACountry }), _jsx(LicenseNumber, { show: !isSACountry ? isCR : show, readOnly: licenseReadonly })] }));
|
|
143
|
+
};
|
|
144
|
+
export default React.memo(LicenseList);
|