@tap-payments/auth-jsconnect 2.1.37-test → 2.1.39-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 +4 -7
- package/build/api/auth.d.ts +4 -3
- package/build/api/auth.js +8 -4
- package/build/api/entity.d.ts +0 -8
- package/build/api/entity.js +0 -15
- package/build/api/file.d.ts +13 -0
- package/build/api/file.js +24 -0
- package/build/api/index.d.ts +11 -6
- package/build/api/index.js +3 -1
- package/build/assets/locales/ar.json +5 -1
- package/build/assets/locales/en.json +5 -1
- package/build/components/FileInput/DragAndDrop.js +1 -1
- package/build/components/ProgressBar/CircularProgressBar.d.ts +3 -1
- package/build/components/ProgressBar/CircularProgressBar.js +2 -2
- package/build/components/SimpleList/SimpleList.d.ts +1 -1
- package/build/components/SimpleList/SimpleList.js +3 -3
- package/build/constants/api.d.ts +2 -0
- package/build/constants/api.js +4 -0
- package/build/constants/assets.d.ts +1 -0
- package/build/constants/assets.js +1 -0
- package/build/constants/validation.d.ts +1 -0
- package/build/constants/validation.js +1 -0
- package/build/features/app/auth/authStore.js +1 -1
- package/build/features/app/bank/bankStore.js +1 -1
- package/build/features/app/business/businessStore.d.ts +7 -9
- package/build/features/app/business/businessStore.js +29 -67
- package/build/features/app/connect/connectStore.js +21 -33
- package/build/features/app/connectExpress/connectExpressStore.d.ts +18 -5
- package/build/features/app/connectExpress/connectExpressStore.js +197 -6
- package/build/features/app/individual/individualStore.d.ts +4 -16
- package/build/features/app/individual/individualStore.js +11 -89
- package/build/features/app/signIn/signInStore.js +13 -41
- package/build/features/brand/screens/BrandActivities/ActivitiesList.js +1 -1
- package/build/features/brand/screens/BrandInfo/SalesChannels.js +6 -6
- package/build/features/brand/screens/BrandInfo/Segments.js +1 -1
- package/build/features/brand/screens/BrandInfo/TeamSize.js +1 -1
- package/build/features/business/screens/Activities/ActivitiesList.js +1 -1
- package/build/features/business/screens/BusinessType/Article.js +10 -13
- package/build/features/business/screens/BusinessType/BusinessType.js +2 -4
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +12 -50
- package/build/features/business/screens/BusinessType/validation.d.ts +3 -6
- package/build/features/business/screens/BusinessType/validation.js +1 -11
- package/build/features/connect/screens/Merchant/SalesChannels.js +4 -3
- package/build/features/connectExpress/ConnectExpress.d.ts +3 -2
- package/build/features/connectExpress/ConnectExpress.js +7 -14
- package/build/features/connectExpress/screens/CivilID/CivilID.js +13 -31
- package/build/features/connectExpress/screens/CivilID/IDNumber.js +0 -4
- package/build/features/connectExpress/screens/Mobile/Mobile.js +25 -49
- package/build/features/connectExpress/screens/NID/DOB.js +2 -2
- package/build/features/connectExpress/screens/NID/IDNumber.js +1 -5
- package/build/features/connectExpress/screens/NID/NID.js +11 -16
- package/build/features/connectExpress/screens/OTP/OTP.js +13 -23
- package/build/features/entity/screens/EntityCapital/ActivityList.js +1 -1
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +18 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +11 -62
- package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +11 -59
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +6 -12
- package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +2 -23
- package/build/features/shared/Address/CountryList.js +1 -1
- package/build/features/shared/Address/InputSelect.js +1 -1
- package/build/features/shared/SalesChannels/SalesChannel.d.ts +3 -2
- package/build/features/shared/SalesChannels/SalesChannel.js +25 -11
- package/build/features/shared/UploadFile/UploadFile.js +1 -1
- package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +38 -0
- package/build/features/shared/UploadMultipleFile/UploadFile.js +184 -1
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +27 -0
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +147 -1
- package/build/features/shared/UploadMultipleFile/index.d.ts +2 -0
- package/build/features/shared/UploadMultipleFile/index.js +2 -1
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.js +1 -0
- package/build/hooks/useCountry.d.ts +4 -0
- package/build/hooks/useCountry.js +7 -0
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -3
- package/build/theme/typography.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useController, useFormContext } from 'react-hook-form';
|
|
4
4
|
import { useAppSelector, useAppDispatch } from '../../../../hooks';
|
|
@@ -7,12 +7,13 @@ import { mapSalesChannel } from '../../../../utils';
|
|
|
7
7
|
import SalesChannel from '../../../shared/SalesChannels';
|
|
8
8
|
var SalesChannels = function (_a) {
|
|
9
9
|
var _b;
|
|
10
|
-
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
10
|
+
var _c = useFormContext(), control = _c.control, setValue = _c.setValue, getValues = _c.getValues;
|
|
11
11
|
var dispatch = useAppDispatch();
|
|
12
12
|
var _d = useController({ control: control, name: 'salesChannels' }), fieldState = _d.fieldState, field = _d.field;
|
|
13
13
|
var _e = useAppSelector(connectSelector), data = _e.data, error = _e.error;
|
|
14
14
|
var _f = data.brandData, selectedBrandItem = _f.selectedBrandItem, responseBody = _f.responseBody, defaultSalesChannels = _f.salesChannels;
|
|
15
15
|
var channelList = (responseBody || {}).channel_list;
|
|
16
|
+
var selectedBrandControl = getValues('selectedBrandItem');
|
|
16
17
|
React.useEffect(function () {
|
|
17
18
|
if (selectedBrandItem.id) {
|
|
18
19
|
setValue('selectedBrandItem', selectedBrandItem);
|
|
@@ -32,6 +33,6 @@ var SalesChannels = function (_a) {
|
|
|
32
33
|
dispatch(clearError());
|
|
33
34
|
field.onChange(channels);
|
|
34
35
|
};
|
|
35
|
-
return (_jsx(
|
|
36
|
+
return (_jsx(SalesChannel, { error: (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message, list: channelList, selectFirstIconListener: selectedBrandControl === null || selectedBrandControl === void 0 ? void 0 : selectedBrandControl.id, onChange: onChange, defaultValue: selectedSalesChannels }));
|
|
36
37
|
};
|
|
37
38
|
export default SalesChannels;
|
|
@@ -6,5 +6,6 @@ export interface ConnectExpressLibProps extends LibConfig {
|
|
|
6
6
|
postURL: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function ConnectExpressLib(props: ConnectExpressLibProps): JSX.Element;
|
|
9
|
-
export declare function renderConnectExpressLib(config: ConnectExpressLibProps, elementId: string):
|
|
10
|
-
|
|
9
|
+
export declare function renderConnectExpressLib(config: ConnectExpressLibProps, elementId: string): {
|
|
10
|
+
unmount: () => void;
|
|
11
|
+
};
|
|
@@ -63,12 +63,12 @@ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepSta
|
|
|
63
63
|
import { handleCurrentActiveScreen, settingsSelector, handleOpen } from '../../app/settings';
|
|
64
64
|
import AnimationFlow from '../../components/AnimationFlow';
|
|
65
65
|
import { store } from '../../app/store';
|
|
66
|
-
import { connectExpressSelector, setIsLeadIdPassed, setResponseData, setPostUrl } from '../app/connectExpress/connectExpressStore';
|
|
66
|
+
import { connectExpressSelector, setIsLeadIdPassed, setResponseData, setPostUrl, setLeadId } from '../app/connectExpress/connectExpressStore';
|
|
67
67
|
import API from '../../api';
|
|
68
68
|
import { ReduxProvider, ThemeProvider } from '../../components/Providers';
|
|
69
69
|
import Collapse from '../../components/Collapse';
|
|
70
|
-
import { reactElement,
|
|
71
|
-
import { CONNECT_EXPRESS_SCREENS_NAVIGATION
|
|
70
|
+
import { reactElement, isKW } from '../../utils';
|
|
71
|
+
import { CONNECT_EXPRESS_SCREENS_NAVIGATION } from '../../constants';
|
|
72
72
|
import { connectExpressFeatureScreens } from '../featuresScreens';
|
|
73
73
|
import CustomFooter from '../shared/Footer';
|
|
74
74
|
import Background from '../shared/Background';
|
|
@@ -89,6 +89,7 @@ var ConnectExpress = memo(function (_a) {
|
|
|
89
89
|
if (!leadId)
|
|
90
90
|
return [2];
|
|
91
91
|
dispatch(setIsLeadIdPassed(true));
|
|
92
|
+
dispatch(setLeadId(leadId));
|
|
92
93
|
return [4, API.leadService.getLeadById(leadId)];
|
|
93
94
|
case 1:
|
|
94
95
|
leadData = _a.sent();
|
|
@@ -120,15 +121,7 @@ export function ConnectExpressLib(props) {
|
|
|
120
121
|
return (_jsx(ReduxProvider, __assign({ store: store }, { children: _jsx(ConnectExpress, __assign({}, props)) })));
|
|
121
122
|
}
|
|
122
123
|
export function renderConnectExpressLib(config, elementId) {
|
|
123
|
-
reactElement(elementId).render
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (unmountTimeout === void 0) { unmountTimeout = 1000; }
|
|
127
|
-
var element = document.getElementById(elementId);
|
|
128
|
-
setTimeout(function () {
|
|
129
|
-
var _a;
|
|
130
|
-
((_a = element === null || element === void 0 ? void 0 : element.children) === null || _a === void 0 ? void 0 : _a.length) && element.removeChild(element.children[0]);
|
|
131
|
-
removeElement(DIALOG_ID);
|
|
132
|
-
elementId && reactElement(elementId).unmount();
|
|
133
|
-
}, unmountTimeout);
|
|
124
|
+
var _a = reactElement(elementId), render = _a.render, unmount = _a.unmount;
|
|
125
|
+
render(_jsx(ConnectExpress, __assign({}, config)));
|
|
126
|
+
return { unmount: unmount };
|
|
134
127
|
}
|
|
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
13
|
import * as React from 'react';
|
|
25
14
|
import { useTranslation } from 'react-i18next';
|
|
@@ -27,9 +16,9 @@ import { alpha, styled } from '@mui/material/styles';
|
|
|
27
16
|
import { useForm, FormProvider } from 'react-hook-form';
|
|
28
17
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
29
18
|
import { civilIDValidationSchema } from './validation';
|
|
30
|
-
import { useAppDispatch, useLanguage, useAppSelector
|
|
31
|
-
import { handlePrevScreenStep
|
|
32
|
-
import { clearError,
|
|
19
|
+
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
20
|
+
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
21
|
+
import { clearError, connectExpressSelector, createCivilAuthAsync, resetStore } from '../../../app/connectExpress/connectExpressStore';
|
|
33
22
|
import Form from '../../../../components/Form';
|
|
34
23
|
import Button, { MobileButton } from '../../../shared/Button';
|
|
35
24
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
@@ -70,33 +59,26 @@ var CivilID = function (_a) {
|
|
|
70
59
|
var isAr = useLanguage().isAr;
|
|
71
60
|
var dispatch = useAppDispatch();
|
|
72
61
|
var t = useTranslation().t;
|
|
73
|
-
var _b = useAppSelector(
|
|
74
|
-
var settingsStore = useAppSelector(settingsSelector);
|
|
75
|
-
var _c = data.civilIdData, responseBody = _c.responseBody, defaultValues = __rest(_c, ["responseBody"]);
|
|
62
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
76
63
|
var methods = useForm({
|
|
77
64
|
resolver: yupResolver(civilIDValidationSchema),
|
|
78
|
-
defaultValues:
|
|
65
|
+
defaultValues: data.civilIdData,
|
|
79
66
|
mode: 'onChange'
|
|
80
67
|
});
|
|
81
|
-
useSetFromDefaultValues(methods, data.civilIdData);
|
|
82
68
|
React.useEffect(function () {
|
|
83
|
-
handleClearError();
|
|
84
|
-
}, [methods.formState.isValid]);
|
|
85
|
-
var onSubmit = function (data) {
|
|
86
|
-
dispatch(createCivilIdAuth(data));
|
|
87
|
-
dispatch(resetMobileScreen(settingsStore.data.businessCountry));
|
|
88
|
-
};
|
|
89
|
-
var handleClearError = function () {
|
|
90
69
|
if (error)
|
|
91
70
|
dispatch(clearError());
|
|
92
|
-
};
|
|
93
|
-
var onBack = function () {
|
|
94
|
-
dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
|
|
95
|
-
};
|
|
71
|
+
}, [methods.formState.isValid]);
|
|
96
72
|
React.useEffect(function () {
|
|
97
73
|
dispatch(resetStore());
|
|
98
74
|
}, []);
|
|
75
|
+
var onSubmit = function (data) {
|
|
76
|
+
dispatch(createCivilAuthAsync(data));
|
|
77
|
+
};
|
|
78
|
+
var onBack = function () {
|
|
79
|
+
dispatch(handlePrevScreenStep('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
80
|
+
};
|
|
99
81
|
var disabled = !methods.formState.isValid || !!error;
|
|
100
|
-
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
|
|
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') }))] }))] })) })) }));
|
|
101
83
|
};
|
|
102
84
|
export default React.memo(CivilID);
|
|
@@ -40,10 +40,6 @@ var IDNumber = React.forwardRef(function (_a, ref) {
|
|
|
40
40
|
var t = useTranslation().t;
|
|
41
41
|
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
42
42
|
var civilIdControl = useController({ control: control, name: 'civilId' });
|
|
43
|
-
React.useEffect(function () {
|
|
44
|
-
if (civilIdControl.field.value)
|
|
45
|
-
setValue('civilId', civilIdControl.field.value, { shouldValidate: true });
|
|
46
|
-
}, []);
|
|
47
43
|
var handleIdChange = function (_a) {
|
|
48
44
|
var target = _a.target;
|
|
49
45
|
var value = removeAllOtherThanCharsAndNumber(target.value);
|
|
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
13
|
import * as React from 'react';
|
|
25
14
|
import Box from '@mui/material/Box';
|
|
@@ -30,13 +19,12 @@ import { styled, alpha } from '@mui/material/styles';
|
|
|
30
19
|
import Collapse from '../../../../components/Collapse';
|
|
31
20
|
import Form from '../../../../components/Form';
|
|
32
21
|
import Button, { AbsherButton, MobileButton } from '../../../shared/Button';
|
|
33
|
-
import { useAppDispatch, useAppSelector,
|
|
22
|
+
import { useAppDispatch, useAppSelector, useCountry } from '../../../../hooks';
|
|
34
23
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
35
24
|
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
36
|
-
import { clearError,
|
|
25
|
+
import { clearError, resetStore, connectExpressSelector, createMobileAuthAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
37
26
|
import { useLanguage } from '../../../../hooks';
|
|
38
27
|
import Divider from '@mui/material/Divider';
|
|
39
|
-
import { isKW } from '../../../../utils';
|
|
40
28
|
import Text from '../../../../components/Text';
|
|
41
29
|
import MIDTitle from './Title';
|
|
42
30
|
import MobileNumber from './MobileNumber';
|
|
@@ -79,55 +67,43 @@ var OrBoxStyled = styled(Box)(function (_a) {
|
|
|
79
67
|
marginInline: theme.spacing(2.5)
|
|
80
68
|
});
|
|
81
69
|
});
|
|
82
|
-
var ListType;
|
|
83
|
-
(function (ListType) {
|
|
84
|
-
ListType["BusinessList"] = "BusinessList";
|
|
85
|
-
ListType["CountryCodeList"] = "CountryCodeList";
|
|
86
|
-
})(ListType || (ListType = {}));
|
|
87
70
|
var Mobile = function (_a) {
|
|
88
|
-
var
|
|
89
|
-
var
|
|
90
|
-
var _c =
|
|
91
|
-
var
|
|
92
|
-
var
|
|
71
|
+
var settingData = useAppSelector(settingsSelector).data;
|
|
72
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
73
|
+
var _c = React.useState(false), anchor = _c[0], setAnchor = _c[1];
|
|
74
|
+
var t = useTranslation().t;
|
|
75
|
+
var isAr = useLanguage().isAr;
|
|
93
76
|
var dispatch = useAppDispatch();
|
|
94
|
-
var
|
|
77
|
+
var isKuwait = useCountry(settingData.businessCountry.iso2).isKuwait;
|
|
95
78
|
var methods = useForm({
|
|
96
79
|
resolver: yupResolver(PhoneValidationSchema),
|
|
97
|
-
defaultValues:
|
|
80
|
+
defaultValues: data.mobileData,
|
|
98
81
|
mode: 'onChange'
|
|
99
82
|
});
|
|
100
|
-
useSetFromDefaultValues(methods, defaultValues);
|
|
101
|
-
var t = useTranslation().t;
|
|
102
|
-
var isAr = useLanguage().isAr;
|
|
103
|
-
var handleMenuListClick = function (flag) {
|
|
104
|
-
setListType(flag);
|
|
105
|
-
};
|
|
106
|
-
React.useEffect(function () {
|
|
107
|
-
dispatch(resetOTPScreen());
|
|
108
|
-
}, []);
|
|
109
83
|
React.useEffect(function () {
|
|
110
84
|
if (error)
|
|
111
85
|
dispatch(clearError());
|
|
112
86
|
}, [methods.formState.isValid]);
|
|
87
|
+
React.useEffect(function () {
|
|
88
|
+
dispatch(resetStore());
|
|
89
|
+
}, []);
|
|
90
|
+
React.useEffect(function () {
|
|
91
|
+
dispatch(resetStore());
|
|
92
|
+
}, []);
|
|
113
93
|
var onSubmit = function (formData) {
|
|
114
|
-
dispatch(
|
|
115
|
-
dispatch(resetNIDScreen());
|
|
116
|
-
dispatch(resetCivilScreen());
|
|
94
|
+
dispatch(createMobileAuthAsync(formData));
|
|
117
95
|
};
|
|
118
|
-
var isKWCountry = React.useMemo(function () { var _a; return isKW((_a = settingsStore.data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2); }, [(_b = settingsStore.data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2]);
|
|
119
96
|
var onBack = function () {
|
|
120
|
-
|
|
97
|
+
var screen = isKuwait ? 'CONNECT_EXPRESS_CIVIL_ID_STEP' : 'CONNECT_EXPRESS_NID_STEP';
|
|
98
|
+
dispatch(handlePrevScreenStep(screen));
|
|
99
|
+
};
|
|
100
|
+
var handleCountryOpen = function () {
|
|
101
|
+
setAnchor(true);
|
|
102
|
+
};
|
|
103
|
+
var handleCountryClose = function () {
|
|
104
|
+
setAnchor(false);
|
|
121
105
|
};
|
|
122
|
-
React.useEffect(function () {
|
|
123
|
-
dispatch(resetStore());
|
|
124
|
-
}, []);
|
|
125
|
-
var isBusinessListActive = listType === ListType.BusinessList;
|
|
126
|
-
var isCountryListActive = listType === ListType.CountryCodeList;
|
|
127
|
-
var listActive = isBusinessListActive || isCountryListActive;
|
|
128
106
|
var disabled = !methods.formState.isValid || !!error;
|
|
129
|
-
|
|
130
|
-
var subTitle = t('ide_terms_and_conditions_description');
|
|
131
|
-
return (_jsxs(ScreenContainer, { children: [(title || subTitle) && _jsx(MIDTitle, { show: !listActive, title: title, description: subTitle }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { show: !isBusinessListActive, countries: settingsStore.data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } }) }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, loading: loading, 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, {})] }), isKWCountry ? (_jsx(MobileButton, __assign({ disabled: settingsStore.loading || loading, onClick: function () { return onBack(); }, icon: ICONS_NAMES.PACI_ICON }, { children: t('paci_button_label') }))) : (_jsx(AbsherButton, __assign({ disabled: settingsStore.loading || loading, onClick: function () { return onBack(); } }, { children: t('absher_button_label') })))] }))] }))] })) }))] }));
|
|
107
|
+
return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !anchor, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { show: !anchor, countries: settingData.countries, onListOpen: handleCountryOpen, onListClose: handleCountryClose }) }), _jsxs(Collapse, __assign({ in: !anchor }, { children: [_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: !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') })))] }))] }))] })) }))] }));
|
|
132
108
|
};
|
|
133
109
|
export default React.memo(Mobile);
|
|
@@ -16,7 +16,7 @@ import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
|
16
16
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
17
17
|
import DatePicker from '../../../../components/DatePicker';
|
|
18
18
|
import { alpha, styled } from '@mui/material/styles';
|
|
19
|
-
import { clearError,
|
|
19
|
+
import { clearError, connectExpressSelector } from '../../../app/connectExpress/connectExpressStore';
|
|
20
20
|
import Text from '../../../../components/Text';
|
|
21
21
|
var InputLabelStyled = styled(Text)(function (_a) {
|
|
22
22
|
var theme = _a.theme;
|
|
@@ -29,7 +29,7 @@ var DOB = function (_a) {
|
|
|
29
29
|
var control = useFormContext().control;
|
|
30
30
|
var dispatch = useAppDispatch();
|
|
31
31
|
var dobControl = useController({ control: control, name: 'dob' });
|
|
32
|
-
var error = useAppSelector(
|
|
32
|
+
var error = useAppSelector(connectExpressSelector).error;
|
|
33
33
|
var handleBirthDateChange = function (data) {
|
|
34
34
|
dobControl.field.onChange(data);
|
|
35
35
|
handleClearError();
|
|
@@ -39,12 +39,8 @@ var IDNumber = React.forwardRef(function (_a, ref) {
|
|
|
39
39
|
var _b;
|
|
40
40
|
var show = _a.show;
|
|
41
41
|
var t = useTranslation().t;
|
|
42
|
-
var
|
|
42
|
+
var control = useFormContext().control;
|
|
43
43
|
var nidControl = useController({ control: control, name: 'nid' });
|
|
44
|
-
React.useEffect(function () {
|
|
45
|
-
if (nidControl.field.value)
|
|
46
|
-
setValue('nid', nidControl.field.value, { shouldValidate: true });
|
|
47
|
-
}, [show]);
|
|
48
44
|
var handleIdChange = function (_a) {
|
|
49
45
|
var target = _a.target;
|
|
50
46
|
var value = removeAllCharsFromNumber(target.value);
|
|
@@ -17,8 +17,8 @@ import { useForm, FormProvider } from 'react-hook-form';
|
|
|
17
17
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
18
|
import { NIDValidationSchema } from './validation';
|
|
19
19
|
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
20
|
-
import { handlePrevScreenStep
|
|
21
|
-
import { clearError,
|
|
20
|
+
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
21
|
+
import { clearError, connectExpressSelector, createNIDAuthAsync, 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';
|
|
@@ -61,34 +61,29 @@ var NID = function (_a) {
|
|
|
61
61
|
var isAr = useLanguage().isAr;
|
|
62
62
|
var dispatch = useAppDispatch();
|
|
63
63
|
var t = useTranslation().t;
|
|
64
|
-
var _c = useAppSelector(
|
|
65
|
-
var settingsStore = useAppSelector(settingsSelector);
|
|
64
|
+
var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error;
|
|
66
65
|
var methods = useForm({
|
|
67
66
|
resolver: yupResolver(NIDValidationSchema),
|
|
68
67
|
defaultValues: data.nidData,
|
|
69
68
|
mode: 'onChange'
|
|
70
69
|
});
|
|
71
70
|
React.useEffect(function () {
|
|
72
|
-
|
|
71
|
+
if (error)
|
|
72
|
+
dispatch(clearError());
|
|
73
73
|
}, [methods.formState.isValid]);
|
|
74
|
+
React.useEffect(function () {
|
|
75
|
+
dispatch(resetStore());
|
|
76
|
+
}, []);
|
|
74
77
|
var onSubmit = function (data) {
|
|
75
|
-
dispatch(
|
|
76
|
-
dispatch(resetMobileScreen(settingsStore.data.businessCountry));
|
|
78
|
+
dispatch(createNIDAuthAsync(data));
|
|
77
79
|
};
|
|
78
80
|
var handleCollapseOpenClose = function (flag) {
|
|
79
81
|
setCollapse(flag);
|
|
80
82
|
};
|
|
81
|
-
var handleClearError = function () {
|
|
82
|
-
if (error)
|
|
83
|
-
dispatch(clearError());
|
|
84
|
-
};
|
|
85
83
|
var onBack = function () {
|
|
86
|
-
dispatch(handlePrevScreenStep('
|
|
84
|
+
dispatch(handlePrevScreenStep('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
87
85
|
};
|
|
88
|
-
React.useEffect(function () {
|
|
89
|
-
dispatch(resetStore());
|
|
90
|
-
}, []);
|
|
91
86
|
var disabled = !methods.formState.isValid || !!error;
|
|
92
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, { show: !collapse }) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled
|
|
87
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, { show: !collapse }) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, 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') }))] }))] }))] })) })) }));
|
|
93
88
|
};
|
|
94
89
|
export default React.memo(NID);
|
|
@@ -9,27 +9,16 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
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
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
13
|
import Box from '@mui/material/Box/Box';
|
|
25
14
|
import { styled } from '@mui/material/styles';
|
|
26
15
|
import * as React from 'react';
|
|
27
16
|
import { useTranslation } from 'react-i18next';
|
|
28
17
|
import Text from '../../../../components/Text';
|
|
29
|
-
import { clearError,
|
|
18
|
+
import { clearError, connectExpressSelector, verifyOtpAsync, resetOTPValue } from '../../../app/connectExpress/connectExpressStore';
|
|
30
19
|
import Button from '../../../shared/Button';
|
|
31
20
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
32
|
-
import { useAppDispatch, useAppSelector
|
|
21
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
33
22
|
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
34
23
|
import { useLanguage } from '../../../../hooks';
|
|
35
24
|
import { AuthForType } from '../../../../@types';
|
|
@@ -61,29 +50,30 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
61
50
|
var OTP = function () {
|
|
62
51
|
var _a;
|
|
63
52
|
var dispatch = useAppDispatch();
|
|
64
|
-
var _b = useAppSelector(
|
|
65
|
-
var
|
|
53
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
54
|
+
var t = useTranslation().t;
|
|
55
|
+
var isAr = useLanguage().isAr;
|
|
66
56
|
var methods = useForm({
|
|
67
57
|
resolver: yupResolver(OTPValidation),
|
|
68
|
-
defaultValues:
|
|
58
|
+
defaultValues: data.otpData,
|
|
69
59
|
mode: 'onChange'
|
|
70
60
|
});
|
|
71
|
-
useSetFromDefaultValues(methods, defaultValues);
|
|
72
|
-
var t = useTranslation().t;
|
|
73
|
-
var isAr = useLanguage().isAr;
|
|
74
61
|
var startWithNID = data.otpData.authFor === AuthForType.NATIONAL_ID;
|
|
75
62
|
React.useEffect(function () {
|
|
76
63
|
if (error)
|
|
77
64
|
dispatch(clearError());
|
|
65
|
+
}, [methods.formState.isValid]);
|
|
66
|
+
React.useEffect(function () {
|
|
78
67
|
return function () {
|
|
79
|
-
dispatch(
|
|
68
|
+
dispatch(resetOTPValue());
|
|
80
69
|
};
|
|
81
|
-
}, [
|
|
70
|
+
}, []);
|
|
82
71
|
var onSubmit = function (formData) {
|
|
83
|
-
dispatch(
|
|
72
|
+
dispatch(verifyOtpAsync(formData));
|
|
84
73
|
};
|
|
85
74
|
var onBack = function () {
|
|
86
|
-
|
|
75
|
+
var screen = startWithNID ? 'CONNECT_EXPRESS_NID_STEP' : 'CONNECT_EXPRESS_MOBILE_STEP';
|
|
76
|
+
dispatch(handlePrevScreenStep(screen));
|
|
87
77
|
};
|
|
88
78
|
var disabled = !methods.formState.isValid || !!error;
|
|
89
79
|
var phone = ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + (data.mobileData.mobile || '');
|
|
@@ -167,7 +167,7 @@ var ActivitiesList = function (_a) {
|
|
|
167
167
|
var getSelectedActivityFlag = function (item) {
|
|
168
168
|
return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
|
|
169
169
|
};
|
|
170
|
-
return (_jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t(isCR ? 'activities' : 'category') }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, disabled: disabled, value: getSelectedActivities() || '', placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath:
|
|
170
|
+
return (_jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t(isCR ? 'activities' : 'category') }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, disabled: disabled, value: getSelectedActivities() || '', placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
171
171
|
var _a, _b, _c;
|
|
172
172
|
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: item.id === ((_a = getSelectedActivityFlag(item)) === null || _a === void 0 ? void 0 : _a.id) }, { children: isAr ? (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
|
|
173
173
|
} }) }))] })] }));
|
package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js
CHANGED
|
@@ -48,14 +48,27 @@ var AdditionalIndividualInfo = function (_a) {
|
|
|
48
48
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
49
49
|
var countries = settingsData.countries;
|
|
50
50
|
var user = (data.verify.responseBody || {}).user;
|
|
51
|
+
var _c = data.individualData, occupation = _c.occupation, sourceIncome = _c.sourceIncome, monthlyIncome = _c.monthlyIncome, employerName = _c.employerName, employerLocation = _c.employerLocation, isPEP = _c.isPEP, isInfluencer = _c.isInfluencer, civilID = _c.civilID, signatureFileId = _c.signatureFileId, civilIDUploading = _c.civilIDUploading, signatureFileUploading = _c.signatureFileUploading;
|
|
51
52
|
var methods = useForm({
|
|
52
53
|
resolver: yupResolver(IndividualInfoValidationSchema),
|
|
53
|
-
defaultValues:
|
|
54
|
+
defaultValues: {
|
|
55
|
+
occupation: occupation,
|
|
56
|
+
sourceIncome: sourceIncome,
|
|
57
|
+
monthlyIncome: monthlyIncome,
|
|
58
|
+
employerName: employerName,
|
|
59
|
+
employerLocation: employerLocation,
|
|
60
|
+
isPEP: isPEP,
|
|
61
|
+
isInfluencer: isInfluencer,
|
|
62
|
+
civilID: civilID,
|
|
63
|
+
signatureFileId: signatureFileId,
|
|
64
|
+
civilIDUploading: civilIDUploading,
|
|
65
|
+
signatureFileUploading: signatureFileUploading
|
|
66
|
+
},
|
|
54
67
|
mode: 'onChange'
|
|
55
68
|
});
|
|
56
69
|
useSetFromDefaultValues(methods, data.individualData, true);
|
|
57
|
-
var
|
|
58
|
-
var
|
|
70
|
+
var _d = React.useState(), listActive = _d[0], setListActive = _d[1];
|
|
71
|
+
var _e = React.useState(false), employerFieldsActive = _e[0], setEmployerFieldsActive = _e[1];
|
|
59
72
|
React.useEffect(function () {
|
|
60
73
|
var _a, _b;
|
|
61
74
|
if (((_b = (_a = methods.getValues('sourceIncome')) === null || _a === void 0 ? void 0 : _a.name.en) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'salary')
|
|
@@ -76,7 +89,8 @@ var AdditionalIndividualInfo = function (_a) {
|
|
|
76
89
|
var isEmployerLocationListActive = listActive === ListType.EmployerLocationList;
|
|
77
90
|
var isMonthlyIncomeListActive = listActive === ListType.MonthlyIncomeList;
|
|
78
91
|
var isOccupationListActive = listActive === ListType.OccupationList;
|
|
79
|
-
|
|
92
|
+
var disabled = !methods.formState.isValid || civilIDUploading || signatureFileUploading;
|
|
93
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Box, { children: [_jsx(Occupation, { onListOpen: function () { return handleMenuClick(ListType.OccupationList); }, onListClose: function () { return handleMenuClick(); }, show: !isEmployerLocationListActive && !isMonthlyIncomeListActive && !isSourceOfIncomeListActive }), _jsx(SourceOfIncome, { onListOpen: function () { return handleMenuClick(ListType.SourceOfIncomeList); }, onListClose: function () { return handleMenuClick(); }, show: !isEmployerLocationListActive && !isMonthlyIncomeListActive && !isOccupationListActive }), _jsx(MonthlyIncome, { show: !isEmployerLocationListActive && !isSourceOfIncomeListActive && !isOccupationListActive, onListOpen: function () { return handleMenuClick(ListType.MonthlyIncomeList); }, onListClose: function () { return handleMenuClick(); } }), _jsx(EmployerName, { show: false }), _jsx(EmployerLocation, { show: !isSourceOfIncomeListActive && employerFieldsActive && !isMonthlyIncomeListActive && !isOccupationListActive, countries: countries, onListOpen: function () { return handleMenuClick(ListType.EmployerLocationList); }, onListClose: function () { return handleMenuClick(); } }), _jsxs(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: [_jsx(CivilIDFile, {}), _jsx(SignatureFile, { show: user === null || user === void 0 ? void 0 : user.is_authorized })] })), _jsx(PEPSwitch, { show: !listActive }), _jsx(InfluencerSwitch, { show: !listActive })] }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
80
94
|
};
|
|
81
95
|
export default React.memo(AdditionalIndividualInfo);
|
|
82
96
|
AdditionalIndividualInfo.defaultProps = {};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
4
3
|
import { styled } from '@mui/material/styles';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
5
|
import { useController, useFormContext } from 'react-hook-form';
|
|
7
6
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import UploadFile from '../../../../features/shared/UploadFile';
|
|
11
|
-
import { maskFileName } from '../../../../utils';
|
|
7
|
+
import { civilIDUploadingStatus, individualSelector } from '../../../app/individual/individualStore';
|
|
8
|
+
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
12
9
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
13
10
|
var theme = _a.theme;
|
|
14
11
|
return ({
|
|
@@ -16,66 +13,18 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
16
13
|
});
|
|
17
14
|
});
|
|
18
15
|
var CivilIDFile = function () {
|
|
19
|
-
var _a
|
|
20
|
-
var _c = React.useState(0), progress = _c[0], setProgress = _c[1];
|
|
16
|
+
var _a;
|
|
21
17
|
var t = useTranslation().t;
|
|
22
|
-
var _d = useFormContext(), control = _d.control, setError = _d.setError, clearErrors = _d.clearErrors, setValue = _d.setValue;
|
|
23
|
-
var civilIDFileControl = useController({ name: 'civilIDFile', control: control });
|
|
24
|
-
var civilIDFileIdControl = useController({ name: 'civilID', control: control });
|
|
25
|
-
var _e = useAppSelector(individualSelector), data = _e.data, loading = _e.loading, sysError = _e.error;
|
|
26
|
-
var _f = data.attachmentsData, civilIDUploading = _f.civilIDUploading, civilIDFile = _f.civilIDFile, civilID = _f.civilID;
|
|
27
18
|
var dispatch = useAppDispatch();
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
34
|
-
setError('civilIDFile', { message: 'file_not_supported_alert' });
|
|
35
|
-
}
|
|
36
|
-
else if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
|
|
37
|
-
setError('civilIDFile', { message: 'file_size_alert' });
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
civilIDFileControl.field.onChange(file);
|
|
41
|
-
dispatch(uploadCivilIdFile({
|
|
42
|
-
file: file,
|
|
43
|
-
onProgress: function (value) {
|
|
44
|
-
setProgress(value);
|
|
45
|
-
},
|
|
46
|
-
title: (_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.merchant_id
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
19
|
+
var control = useFormContext().control;
|
|
20
|
+
var civilIDFileIdControl = useController({ name: 'civilID', control: control });
|
|
21
|
+
var _b = useAppSelector(individualSelector), loading = _b.loading, data = _b.data;
|
|
22
|
+
var handleCivilIDChange = function (ids) {
|
|
23
|
+
civilIDFileIdControl.field.onChange(ids);
|
|
49
24
|
};
|
|
50
|
-
var handleReset = function () {
|
|
51
|
-
|
|
52
|
-
civilIDFileIdControl.field.onChange('');
|
|
53
|
-
setProgress(0);
|
|
25
|
+
var handleReset = function (ids) {
|
|
26
|
+
civilIDFileIdControl.field.onChange(ids);
|
|
54
27
|
};
|
|
55
|
-
|
|
56
|
-
if (!!civilIDFile) {
|
|
57
|
-
setValue('civilIDFile', civilIDFile);
|
|
58
|
-
setValue('civilID', civilID);
|
|
59
|
-
}
|
|
60
|
-
}, [civilIDFile, civilID]);
|
|
61
|
-
React.useEffect(function () {
|
|
62
|
-
if (sysError === 'file_upload_error') {
|
|
63
|
-
setError('civilIDFileId', { message: sysError });
|
|
64
|
-
civilIDFileControl.field.onChange(null);
|
|
65
|
-
setProgress(0);
|
|
66
|
-
}
|
|
67
|
-
}, [sysError]);
|
|
68
|
-
React.useEffect(function () {
|
|
69
|
-
if ((civilIDFileControl.formState.isValid || !!civilIDValue) && error != 'file_upload_error')
|
|
70
|
-
clearErrors();
|
|
71
|
-
}, [civilIDFileControl.formState.isValid, civilIDValue]);
|
|
72
|
-
React.useEffect(function () {
|
|
73
|
-
if (!!civilIDFile) {
|
|
74
|
-
civilIDFileControl.field.onChange(civilIDFile);
|
|
75
|
-
civilIDFileIdControl.field.onChange(civilID);
|
|
76
|
-
}
|
|
77
|
-
}, []);
|
|
78
|
-
var fileName = civilIDValue ? maskFileName(civilIDValue === null || civilIDValue === void 0 ? void 0 : civilIDValue.name) : '';
|
|
79
|
-
return (_jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_civil_id'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_civilID'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_civil_id'), onFileUploaded: handleCivilIDChange, isFileUploaded: !civilIDUploading && !!civilIDValue, isSubmitting: loading, isUploading: civilIDUploading, progress: progress, onReset: handleReset, initialFileName: fileName, error: error && t(error) }) }));
|
|
28
|
+
return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_civil_id'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_civilID'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_civil_id'), onFileUploaded: handleCivilIDChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, fileTitle: (_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.merchant_id, purpose: 'identity_document', fileUploadingStatus: function (uploading) { return dispatch(civilIDUploadingStatus(uploading)); } }) }));
|
|
80
29
|
};
|
|
81
30
|
export default CivilIDFile;
|