@tap-payments/auth-jsconnect 2.0.108-test → 2.0.110-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 +6 -4
- package/build/api/entity.d.ts +23 -0
- package/build/api/entity.js +17 -1
- package/build/api/index.d.ts +4 -2
- package/build/assets/locales/ar.json +3 -1
- package/build/assets/locales/en.json +3 -1
- package/build/constants/app.js +1 -1
- package/build/constants/assets.d.ts +3 -0
- package/build/constants/assets.js +3 -0
- package/build/features/app/entity/entityStore.d.ts +27 -7
- package/build/features/app/entity/entityStore.js +205 -141
- package/build/features/connect/screens/Mobile/Mobile.js +8 -4
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.d.ts +1 -0
- package/build/features/entity/screens/EntityInfoConfirm/ActivitiesList.js +21 -11
- package/build/features/entity/screens/EntityInfoConfirm/Article.d.ts +3 -0
- package/build/features/entity/screens/EntityInfoConfirm/Article.js +73 -0
- package/build/features/entity/screens/EntityInfoConfirm/EntityInfo.js +25 -6
- package/build/features/entity/screens/EntityInfoConfirm/LicenseName.js +20 -5
- package/build/features/entity/screens/EntityInfoConfirm/LicenseNumber.js +25 -4
- package/build/features/entity/screens/EntityInfoConfirm/OperationStartDate.js +9 -17
- package/build/features/entity/screens/EntityInfoConfirm/validation.d.ts +12 -51
- package/build/features/entity/screens/EntityInfoConfirm/validation.js +17 -10
- package/build/features/entity/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +2 -2
- package/build/features/entity/screens/Verify/Verify.js +4 -4
- package/build/features/shared/UploadFile/UploadFile.d.ts +2 -1
- package/build/features/shared/UploadFile/UploadFile.js +3 -3
- package/package.json +1 -1
- package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.d.ts +0 -5
- package/build/features/entity/screens/EntityInfoConfirm/SalesChannels.js +0 -115
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
7
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
8
|
+
import { entitySelector, uploadArticle } from '../../../app/entity/entityStore';
|
|
9
|
+
import UploadFile from '../../../shared/UploadFile';
|
|
10
|
+
import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
|
|
11
|
+
import { maskFileName } from '../../../../utils';
|
|
12
|
+
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
13
|
+
var theme = _a.theme;
|
|
14
|
+
return ({
|
|
15
|
+
marginBlockStart: theme.spacing(3)
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
var Article = function () {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var _c = React.useState(0), progress = _c[0], setProgress = _c[1];
|
|
21
|
+
var t = useTranslation().t;
|
|
22
|
+
var _d = useFormContext(), control = _d.control, setError = _d.setError, clearErrors = _d.clearErrors, setValue = _d.setValue;
|
|
23
|
+
var articleFileControl = useController({ name: 'articleFile', control: control });
|
|
24
|
+
var articleIdControl = useController({ name: 'articleId', control: control });
|
|
25
|
+
var _e = useAppSelector(entitySelector), loading = _e.loading, uploading = _e.uploading, sysError = _e.error, data = _e.data;
|
|
26
|
+
var dispatch = useAppDispatch();
|
|
27
|
+
var articleValue = articleFileControl.field.value;
|
|
28
|
+
var error = ((_a = articleFileControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || ((_b = articleIdControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message);
|
|
29
|
+
var entityData = data.entityData;
|
|
30
|
+
var articleFile = entityData.articleFile, articleId = entityData.articleId;
|
|
31
|
+
React.useEffect(function () {
|
|
32
|
+
if (!articleValue) {
|
|
33
|
+
setValue('articleFile', articleFile);
|
|
34
|
+
setValue('articleId', articleId);
|
|
35
|
+
}
|
|
36
|
+
}, [articleFile, articleId]);
|
|
37
|
+
var handleArticleChange = function (file) {
|
|
38
|
+
if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
39
|
+
setError('articleFile', { message: 'file_not_supported_alert' });
|
|
40
|
+
}
|
|
41
|
+
else if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
|
|
42
|
+
setError('articleFile', { message: 'file_size_alert' });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
articleFileControl.field.onChange(file);
|
|
46
|
+
dispatch(uploadArticle({
|
|
47
|
+
file: file,
|
|
48
|
+
onProgress: function (value) {
|
|
49
|
+
setProgress(value);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var handleReset = function () {
|
|
55
|
+
articleFileControl.field.onChange(null);
|
|
56
|
+
articleIdControl.field.onChange('');
|
|
57
|
+
setProgress(0);
|
|
58
|
+
};
|
|
59
|
+
React.useEffect(function () {
|
|
60
|
+
if (sysError === 'file_upload_error') {
|
|
61
|
+
setError('articleId', { message: sysError });
|
|
62
|
+
articleFileControl.field.onChange(null);
|
|
63
|
+
setProgress(0);
|
|
64
|
+
}
|
|
65
|
+
}, [sysError]);
|
|
66
|
+
React.useEffect(function () {
|
|
67
|
+
if ((articleFileControl.formState.isValid || !!articleValue) && error != 'file_upload_error')
|
|
68
|
+
clearErrors();
|
|
69
|
+
}, [articleFileControl.formState.isValid, articleValue]);
|
|
70
|
+
var fileName = articleValue ? maskFileName(articleValue === null || articleValue === void 0 ? void 0 : articleValue.name) : '';
|
|
71
|
+
return (_jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_article'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('article_of_association'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleArticleChange, isFileUploaded: !uploading && !!articleValue, isSubmitting: loading, isUploading: uploading, progress: progress, onReset: handleReset, error: error && t(error), initialFileName: fileName }) }));
|
|
72
|
+
};
|
|
73
|
+
export default Article;
|
|
@@ -16,7 +16,7 @@ import * as React from 'react';
|
|
|
16
16
|
import LicenseNumber from './LicenseNumber';
|
|
17
17
|
import ActivitiesList from './ActivitiesList';
|
|
18
18
|
import { useAppDispatch, useAppSelector, useLanguage } from '../../../../hooks';
|
|
19
|
-
import { entitySelector,
|
|
19
|
+
import { clearError, entitySelector, updateEntity } from '../../../app/entity/entityStore';
|
|
20
20
|
import { FormProvider, useForm } from 'react-hook-form';
|
|
21
21
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
22
22
|
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
@@ -27,30 +27,49 @@ import Collapse from '../../../../components/Collapse';
|
|
|
27
27
|
import Button from '../../../shared/Button';
|
|
28
28
|
import { useTranslation } from 'react-i18next';
|
|
29
29
|
import OperationStartDate from './OperationStartDate';
|
|
30
|
+
import Article from './Article';
|
|
30
31
|
var FormStyled = styled(Form)(function () { return ({
|
|
31
32
|
display: 'flex',
|
|
32
33
|
flexDirection: 'column'
|
|
33
34
|
}); });
|
|
34
35
|
var EntityInfo = function (_a) {
|
|
35
36
|
var _b = React.useState(false), anchorEl = _b[0], setAnchorEl = _b[1];
|
|
36
|
-
var _c =
|
|
37
|
+
var _c = React.useState(false), collapse = _c[0], setCollapse = _c[1];
|
|
38
|
+
var _d = useAppSelector(entitySelector), data = _d.data, loading = _d.loading, error = _d.error, uploading = _d.uploading;
|
|
37
39
|
var isAr = useLanguage().isAr;
|
|
38
40
|
var t = useTranslation().t;
|
|
39
41
|
var dispatch = useAppDispatch();
|
|
42
|
+
var entityData = data.entityData;
|
|
43
|
+
var licenseName = entityData.licenseName, licenseNumber = entityData.licenseNumber, activities = entityData.activities, operationStartDate = entityData.operationStartDate, articleFile = entityData.articleFile, articleId = entityData.articleId;
|
|
40
44
|
var methods = useForm({
|
|
41
45
|
resolver: yupResolver(EntityInfoValidationSchema),
|
|
42
|
-
defaultValues:
|
|
46
|
+
defaultValues: {
|
|
47
|
+
licenseName: licenseName,
|
|
48
|
+
licenseNumber: licenseNumber,
|
|
49
|
+
activities: activities,
|
|
50
|
+
operationStartDate: operationStartDate,
|
|
51
|
+
articleFile: articleFile,
|
|
52
|
+
articleId: articleId
|
|
53
|
+
},
|
|
43
54
|
mode: 'onChange'
|
|
44
55
|
});
|
|
56
|
+
React.useEffect(function () {
|
|
57
|
+
if (error)
|
|
58
|
+
dispatch(clearError());
|
|
59
|
+
}, [methods.formState.isValid]);
|
|
45
60
|
var onSubmit = function (data) {
|
|
46
|
-
dispatch(
|
|
61
|
+
dispatch(updateEntity(__assign({}, data)));
|
|
62
|
+
};
|
|
63
|
+
var handleCollapseOpenClose = function (flag) {
|
|
64
|
+
setCollapse(flag);
|
|
47
65
|
};
|
|
48
66
|
var onBack = function () {
|
|
49
|
-
dispatch(handlePrevScreenStep());
|
|
67
|
+
dispatch(handlePrevScreenStep('ENTITY_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
50
68
|
};
|
|
51
69
|
var handleMenuClick = function () {
|
|
52
70
|
anchorEl ? setAnchorEl(false) : setAnchorEl(true);
|
|
53
71
|
};
|
|
54
|
-
|
|
72
|
+
var disabled = !methods.formState.isValid || !!error || uploading;
|
|
73
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsxs(Collapse, __assign({ in: !collapse && !anchorEl }, { children: [_jsx(LicenseName, {}), _jsx(LicenseNumber, {})] })), _jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(ActivitiesList, { onListOpen: function () { return handleMenuClick(); }, onListClose: function () { return handleMenuClick(); } }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Article, {}) })), _jsx(Collapse, __assign({ in: !anchorEl }, { children: _jsx(OperationStartDate, { onDateClicked: handleCollapseOpenClose }) })), _jsx(Collapse, __assign({ in: !collapse && !anchorEl }, { children: _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
55
74
|
};
|
|
56
75
|
export default EntityInfo;
|
|
@@ -2,16 +2,31 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
5
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
5
6
|
import Input from '../../../shared/Input';
|
|
6
7
|
import { useAppSelector, useLanguage } from '../../../../hooks';
|
|
8
|
+
import { removeAllOtherThanCharsNumbersAndSpace } from '../../../../utils';
|
|
7
9
|
import { entitySelector } from '../../../app/entity/entityStore';
|
|
8
10
|
var LicenseName = function (_a) {
|
|
9
|
-
var _b, _c
|
|
11
|
+
var _b, _c;
|
|
10
12
|
var t = useTranslation().t;
|
|
11
|
-
var isAr = useLanguage()
|
|
13
|
+
var isAr = useLanguage();
|
|
14
|
+
var _d = useFormContext(), control = _d.control, setValue = _d.setValue;
|
|
12
15
|
var data = useAppSelector(entitySelector).data;
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
+
var verify = data.verify;
|
|
17
|
+
var legalName = (_c = (_b = verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.legal_name;
|
|
18
|
+
var name = isAr ? legalName === null || legalName === void 0 ? void 0 : legalName.ar : legalName === null || legalName === void 0 ? void 0 : legalName.en;
|
|
19
|
+
var licenseNameControl = useController({ control: control, name: 'licenseName' });
|
|
20
|
+
var licenseNameValue = licenseNameControl.field.value;
|
|
21
|
+
React.useEffect(function () {
|
|
22
|
+
if (name && !licenseNameValue)
|
|
23
|
+
setValue('licenseName', name, { shouldValidate: true });
|
|
24
|
+
}, [name]);
|
|
25
|
+
var handleChange = function (_a) {
|
|
26
|
+
var target = _a.target;
|
|
27
|
+
var value = removeAllOtherThanCharsNumbersAndSpace(target.value);
|
|
28
|
+
licenseNameControl.field.onChange(value);
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(ScreenContainer, { children: _jsx(Input, { onChange: handleChange, value: licenseNameValue, label: t('license_name_label'), placeholder: t('license_name_label'), sx: { '& .MuiInputBase-input': { cursor: 'auto' } } }) }));
|
|
16
31
|
};
|
|
17
32
|
export default React.memo(LicenseName);
|
|
@@ -12,17 +12,38 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
15
16
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
16
17
|
import Input from '../../../shared/Input';
|
|
17
|
-
import Collapse from '../../../../components/Collapse';
|
|
18
18
|
import { useAppSelector } from '../../../../hooks';
|
|
19
19
|
import { entitySelector } from '../../../app/entity/entityStore';
|
|
20
|
+
import { removeAllOtherThanCharsAndNumber } from '../../../../utils';
|
|
21
|
+
import { BusinessType } from '../../../../@types';
|
|
22
|
+
import { CR_NUMBER_LENGTH, FL_NUMBER_LENGTH } from '../../../../constants';
|
|
20
23
|
var LicenseNumber = function (_a) {
|
|
21
24
|
var _b, _c;
|
|
22
25
|
var t = useTranslation().t;
|
|
23
26
|
var data = useAppSelector(entitySelector).data;
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
+
var _d = useFormContext(), control = _d.control, setValue = _d.setValue;
|
|
28
|
+
var entity = (data.verify.responseBody || {}).entity;
|
|
29
|
+
var licenseType = (_b = entity === null || entity === void 0 ? void 0 : entity.license) === null || _b === void 0 ? void 0 : _b.type;
|
|
30
|
+
var type = licenseType === 'freelance' ? BusinessType.FL : BusinessType.CR;
|
|
31
|
+
var isLicensedTrue = entity === null || entity === void 0 ? void 0 : entity.is_licensed;
|
|
32
|
+
var hasLicenseNumber = (_c = entity === null || entity === void 0 ? void 0 : entity.license) === null || _c === void 0 ? void 0 : _c.number;
|
|
33
|
+
var licenseNumber = data.entityData.licenseNumber;
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
setValue('licenseNumber', licenseNumber, { shouldValidate: true });
|
|
36
|
+
}, [licenseNumber]);
|
|
37
|
+
var handleChange = function (_a) {
|
|
38
|
+
var target = _a.target;
|
|
39
|
+
var value = removeAllOtherThanCharsAndNumber(target.value);
|
|
40
|
+
licenseNumberControl.field.onChange(value);
|
|
41
|
+
};
|
|
42
|
+
var licenseNumberControl = useController({ control: control, name: 'licenseNumber' });
|
|
43
|
+
var licenseNumberValue = licenseNumberControl.field.value;
|
|
44
|
+
var isCR = type === BusinessType.CR;
|
|
45
|
+
var length = isCR ? CR_NUMBER_LENGTH : FL_NUMBER_LENGTH;
|
|
46
|
+
var disabled = hasLicenseNumber && isLicensedTrue;
|
|
47
|
+
return (_jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: _jsx(Input, { label: t('license_number_label'), onChange: handleChange, disabled: disabled, inputProps: { maxLength: length }, value: licenseNumberValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } } }) })));
|
|
27
48
|
};
|
|
28
49
|
export default React.memo(LicenseNumber);
|
|
@@ -1,38 +1,30 @@
|
|
|
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
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
13
3
|
import { useTranslation } from 'react-i18next';
|
|
14
4
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
-
import Input from '../../../shared/Input';
|
|
16
5
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
17
6
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
18
7
|
import { entitySelector, clearError } from '../../../app/entity/entityStore';
|
|
19
8
|
import DatePicker from '../../../../components/DatePicker';
|
|
20
9
|
import { InputLabelStyled } from './ActivitiesList';
|
|
21
10
|
var OperationStartDate = function (_a) {
|
|
22
|
-
var _b
|
|
11
|
+
var _b;
|
|
23
12
|
var onDateClicked = _a.onDateClicked;
|
|
24
13
|
var t = useTranslation().t;
|
|
25
14
|
var dispatch = useAppDispatch();
|
|
26
|
-
var
|
|
27
|
-
var
|
|
15
|
+
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
16
|
+
var _d = useAppSelector(entitySelector), data = _d.data, error = _d.error;
|
|
17
|
+
var operationStartDate = data.entityData.operationStartDate;
|
|
28
18
|
var oDateControl = useController({ control: control, name: 'operationStartDate' });
|
|
19
|
+
React.useEffect(function () {
|
|
20
|
+
setValue('operationStartDate', operationStartDate, { shouldValidate: true });
|
|
21
|
+
}, [operationStartDate]);
|
|
29
22
|
var handleOperationStartDateChange = function (data) {
|
|
30
23
|
if (error)
|
|
31
24
|
dispatch(clearError());
|
|
32
25
|
oDateControl.field.onChange(data);
|
|
33
26
|
};
|
|
34
27
|
var dateValue = (_b = oDateControl === null || oDateControl === void 0 ? void 0 : oDateControl.field) === null || _b === void 0 ? void 0 : _b.value;
|
|
35
|
-
|
|
36
|
-
return (_jsx(ScreenContainer, __assign({ sx: { mt: 2.5 } }, { children: !!storedDate ? (_jsx(Input, { label: t('business_start_date'), readOnly: true, value: dateValue, sx: { '& .MuiInputBase-input': { cursor: 'auto' } } })) : (_jsxs(_Fragment, { children: [_jsx(InputLabelStyled, { children: t('business_start_date') }), _jsx(DatePicker, { readOnly: true, defaultValue: dateValue ? new Date(dateValue) : new Date(), dir: 'ltr', locale: 'en', onClick: function () { return onDateClicked === null || onDateClicked === void 0 ? void 0 : onDateClicked(true); }, onDatePicked: function () { return onDateClicked === null || onDateClicked === void 0 ? void 0 : onDateClicked(false); }, onDateChange: handleOperationStartDateChange })] })) })));
|
|
28
|
+
return (_jsx(ScreenContainer, { children: _jsxs(_Fragment, { children: [_jsx(InputLabelStyled, { children: t('business_start_date') }), _jsx(DatePicker, { readOnly: true, defaultValue: dateValue ? new Date(dateValue) : new Date(), dir: 'ltr', locale: 'en', onClick: function () { return onDateClicked === null || onDateClicked === void 0 ? void 0 : onDateClicked(true); }, onDatePicked: function () { return onDateClicked === null || onDateClicked === void 0 ? void 0 : onDateClicked(false); }, onDateChange: handleOperationStartDateChange })] }) }));
|
|
37
29
|
};
|
|
38
30
|
export default OperationStartDate;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
2
|
export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
3
5
|
activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
4
6
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
5
7
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -16,25 +18,12 @@ export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/li
|
|
|
16
18
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
17
19
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
18
20
|
}>>[] | undefined>;
|
|
19
|
-
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
20
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
21
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
22
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
23
|
-
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
24
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
25
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
26
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
27
|
-
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
28
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
29
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
30
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
31
|
-
}>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
32
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
33
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
34
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
35
|
-
}>>[] | undefined>;
|
|
36
21
|
operationStartDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
22
|
+
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
23
|
+
articleFile: any;
|
|
37
24
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
25
|
+
licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
26
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
38
27
|
activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
39
28
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
40
29
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -51,25 +40,12 @@ export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/li
|
|
|
51
40
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
52
41
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
53
42
|
}>>[] | undefined>;
|
|
54
|
-
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
55
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
56
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
57
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
58
|
-
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
59
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
60
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
61
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
62
|
-
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
63
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
64
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
65
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
66
|
-
}>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
67
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
68
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
69
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
70
|
-
}>>[] | undefined>;
|
|
71
43
|
operationStartDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
44
|
+
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
45
|
+
articleFile: any;
|
|
72
46
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
47
|
+
licenseName: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
48
|
+
licenseNumber: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
73
49
|
activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
74
50
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
75
51
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -86,22 +62,7 @@ export declare const EntityInfoValidationSchema: yup.ObjectSchema<import("yup/li
|
|
|
86
62
|
ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
87
63
|
en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
88
64
|
}>>[] | undefined>;
|
|
89
|
-
salesChannels: import("yup/lib/array").RequiredArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
90
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
91
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
92
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
93
|
-
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
94
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
95
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
96
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
97
|
-
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
98
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
99
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
100
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
101
|
-
}>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
102
|
-
id: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
103
|
-
name_en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
104
|
-
name_ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
105
|
-
}>>[] | undefined>;
|
|
106
65
|
operationStartDate: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
66
|
+
articleId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
67
|
+
articleFile: any;
|
|
107
68
|
}>>>;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
|
|
1
2
|
import * as yup from 'yup';
|
|
2
3
|
export var EntityInfoValidationSchema = yup.object().shape({
|
|
4
|
+
licenseName: yup.string().required(''),
|
|
5
|
+
licenseNumber: yup.string().required(''),
|
|
3
6
|
activities: yup.array().of(yup.object().shape({
|
|
4
7
|
ar: yup.string(),
|
|
5
8
|
en: yup.string()
|
|
6
9
|
})),
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
operationStartDate: yup.string().required('choose_any_business_date'),
|
|
11
|
+
articleId: yup.string().optional(),
|
|
12
|
+
articleFile: yup
|
|
13
|
+
.mixed()
|
|
14
|
+
.test({
|
|
15
|
+
test: function (value) {
|
|
16
|
+
if (!!value)
|
|
17
|
+
return VALID_FILE_FORMATS.includes(value === null || value === void 0 ? void 0 : value.type) && (value === null || value === void 0 ? void 0 : value.size) < MAX_FILE_SIZE
|
|
18
|
+
? true
|
|
19
|
+
: this.createError({ message: 'alert_file_upload' });
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
.optional()
|
|
17
24
|
});
|
|
@@ -48,7 +48,7 @@ var SuccessWithFlowButtons = function () {
|
|
|
48
48
|
var t = useTranslation().t;
|
|
49
49
|
var isAr = useLanguage().isAr;
|
|
50
50
|
var data = useAppSelector(entitySelector).data;
|
|
51
|
-
var _e = data.verify.responseBody || {}, flows = _e.flows, nameObj = _e.name, entity = _e.entity, brand = _e.brand, bank = _e.bank, merchant = _e.merchant,
|
|
51
|
+
var _e = data.verify.responseBody || {}, flows = _e.flows, nameObj = _e.name, entity = _e.entity, brand = _e.brand, bank = _e.bank, merchant = _e.merchant, vatID = _e.vatID, user = _e.user;
|
|
52
52
|
var _f = useState([]), buttons = _f[0], setButtons = _f[1];
|
|
53
53
|
var username = ((nameObj === null || nameObj === void 0 ? void 0 : nameObj.first) || '') + ' ' + ((nameObj === null || nameObj === void 0 ? void 0 : nameObj.last) || '');
|
|
54
54
|
var licenseNumber = ((_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.number) || '';
|
|
@@ -58,7 +58,7 @@ var SuccessWithFlowButtons = function () {
|
|
|
58
58
|
var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
|
|
59
59
|
var isAcceptance = merchant === null || merchant === void 0 ? void 0 : merchant.is_acceptance_allowed;
|
|
60
60
|
var isPayout = merchant === null || merchant === void 0 ? void 0 : merchant.is_payout_allowed;
|
|
61
|
-
var identification = user.identification;
|
|
61
|
+
var identification = (user || {}).identification;
|
|
62
62
|
var maskedId = !!(identification === null || identification === void 0 ? void 0 : identification.id) ? " ".concat(t('masking_symbols')).concat((_d = identification === null || identification === void 0 ? void 0 : identification.id) === null || _d === void 0 ? void 0 : _d.slice(-2)) : '';
|
|
63
63
|
var settings = useAppSelector(settingsSelector);
|
|
64
64
|
var _g = data.verify.responseBody || { contact: {}, board_id: '' }, contact = _g.contact, board_id = _g.board_id, board_info_id = _g.board_info_id;
|
|
@@ -47,9 +47,9 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
47
47
|
flexDirection: 'column'
|
|
48
48
|
}); });
|
|
49
49
|
var VerifyNumber = function (_a) {
|
|
50
|
-
var _b, _c
|
|
50
|
+
var _b, _c;
|
|
51
51
|
var dispatch = useAppDispatch();
|
|
52
|
-
var
|
|
52
|
+
var _d = useAppSelector(entitySelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
53
53
|
var methods = useForm({
|
|
54
54
|
resolver: yupResolver(OTPValidation),
|
|
55
55
|
defaultValues: data.otpData,
|
|
@@ -57,8 +57,8 @@ var VerifyNumber = function (_a) {
|
|
|
57
57
|
});
|
|
58
58
|
var t = useTranslation().t;
|
|
59
59
|
var isAr = useLanguage().isAr;
|
|
60
|
-
var
|
|
61
|
-
var phone = (
|
|
60
|
+
var _e = React.useState(false), resendLoading = _e[0], setResendLoading = _e[1];
|
|
61
|
+
var phone = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.verification_by) === null || _c === void 0 ? void 0 : _c.sent_to;
|
|
62
62
|
React.useEffect(function () {
|
|
63
63
|
if (error && methods.formState.isValid && phone)
|
|
64
64
|
dispatch(clearError());
|
|
@@ -22,6 +22,7 @@ interface UploadFileProps {
|
|
|
22
22
|
isFileUploaded?: boolean;
|
|
23
23
|
onFileUploaded: (file: File) => void;
|
|
24
24
|
onReset: () => void;
|
|
25
|
+
initialFileName?: string;
|
|
25
26
|
}
|
|
26
|
-
declare const UploadFile: ({ label, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, isUploading, isFileUploaded, error, progress, onFileUploaded, onReset }: UploadFileProps) => JSX.Element;
|
|
27
|
+
declare const UploadFile: ({ label, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, isUploading, isFileUploaded, error, progress, onFileUploaded, onReset, initialFileName }: UploadFileProps) => JSX.Element;
|
|
27
28
|
export default UploadFile;
|
|
@@ -64,9 +64,9 @@ export var InputContainerStyled = styled(Box)(function (_a) {
|
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
var UploadFile = function (_a) {
|
|
67
|
-
var label = _a.label, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, isUploading = _a.isUploading, isFileUploaded = _a.isFileUploaded, error = _a.error, progress = _a.progress, onFileUploaded = _a.onFileUploaded, onReset = _a.onReset;
|
|
68
|
-
var _b = React.useState(''), fileName = _b[0], setFileName = _b[1];
|
|
69
|
-
var _c = React.useState(
|
|
67
|
+
var label = _a.label, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, isUploading = _a.isUploading, isFileUploaded = _a.isFileUploaded, error = _a.error, progress = _a.progress, onFileUploaded = _a.onFileUploaded, onReset = _a.onReset, initialFileName = _a.initialFileName;
|
|
68
|
+
var _b = React.useState(initialFileName || ''), fileName = _b[0], setFileName = _b[1];
|
|
69
|
+
var _c = React.useState(!!initialFileName), showFile = _c[0], setShowFile = _c[1];
|
|
70
70
|
var handleFileChange = function (file) {
|
|
71
71
|
setFileName(maskFileName(file === null || file === void 0 ? void 0 : file.name));
|
|
72
72
|
onFileUploaded === null || onFileUploaded === void 0 ? void 0 : onFileUploaded(file);
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare const MandatoryStyled: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
3
|
-
export declare const CollapseStyled: import("@emotion/styled").StyledComponent<import("../../../../components/Collapse").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
4
|
-
declare const SalesChannels: () => JSX.Element;
|
|
5
|
-
export default SalesChannels;
|
|
@@ -1,115 +0,0 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
-
import * as React from 'react';
|
|
23
|
-
import Box from '@mui/material/Box';
|
|
24
|
-
import { alpha, styled } from '@mui/material/styles';
|
|
25
|
-
import { useTranslation } from 'react-i18next';
|
|
26
|
-
import { useController, useFormContext } from 'react-hook-form';
|
|
27
|
-
import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
|
|
28
|
-
import Text from '../../../../components/Text';
|
|
29
|
-
import { entitySelector, clearError } from '../../../app/entity/entityStore';
|
|
30
|
-
import CheckBox from '../../../../components/CheckBox';
|
|
31
|
-
import Warning from '../../../../components/Warning';
|
|
32
|
-
import Collapse from '../../../../components/Collapse';
|
|
33
|
-
import { ScreenContainer } from '../../../shared/Containers';
|
|
34
|
-
var InputLabelStyled = styled(Text)(function (_a) {
|
|
35
|
-
var theme = _a.theme;
|
|
36
|
-
return (__assign({ margin: theme.spacing(2.5, 2.5, 0.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
|
|
37
|
-
});
|
|
38
|
-
var ContainerStyled = styled(Box)(function (_a) {
|
|
39
|
-
var theme = _a.theme;
|
|
40
|
-
return ({
|
|
41
|
-
display: 'flex',
|
|
42
|
-
flexDirection: 'row',
|
|
43
|
-
alignItems: 'center',
|
|
44
|
-
padding: theme.spacing(0, 0.5, 0, 0.5),
|
|
45
|
-
height: theme.spacing(3.625),
|
|
46
|
-
marginBlockEnd: theme.spacing(0.2)
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
var TextStyled = styled(Text)(function (_a) {
|
|
50
|
-
var theme = _a.theme;
|
|
51
|
-
return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.4), fontWeight: theme.typography.fontWeightLight, whiteSpace: 'pre' }, theme.typography.body2), { marginBlockStart: theme.spacing(1.75) }));
|
|
52
|
-
});
|
|
53
|
-
var CheckBoxStyled = styled(CheckBox)(function (_a) {
|
|
54
|
-
var theme = _a.theme;
|
|
55
|
-
return ({
|
|
56
|
-
marginInlineEnd: theme.spacing(-1),
|
|
57
|
-
'& .MuiSvgIcon-root': {
|
|
58
|
-
fontSize: 30
|
|
59
|
-
},
|
|
60
|
-
'&.Mui-checked': {
|
|
61
|
-
color: theme.palette.text.primary,
|
|
62
|
-
borderRadius: theme.spacing(2.5)
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
export var MandatoryStyled = styled('span')(function (_a) {
|
|
67
|
-
var theme = _a.theme;
|
|
68
|
-
return (__assign(__assign({ color: alpha(theme.palette.error.light, 0.4) }, theme.typography.h6), { fontWeight: theme.typography.fontWeightLight, verticalAlign: 'sub' }));
|
|
69
|
-
});
|
|
70
|
-
export var CollapseStyled = styled(Collapse)(function (_a) {
|
|
71
|
-
var theme = _a.theme;
|
|
72
|
-
return ({
|
|
73
|
-
marginBlockStart: theme.spacing(2)
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
var SalesChannels = function () {
|
|
77
|
-
var _a;
|
|
78
|
-
var _b = React.useState([]), channelsMenuList = _b[0], setChannelsMenuList = _b[1];
|
|
79
|
-
var t = useTranslation().t;
|
|
80
|
-
var isAr = useLanguage().isAr;
|
|
81
|
-
var control = useFormContext().control;
|
|
82
|
-
var dispatch = useAppDispatch();
|
|
83
|
-
var channelsControl = useController({ name: 'salesChannels', control: control });
|
|
84
|
-
var channelsChecked = channelsControl.field.value;
|
|
85
|
-
var warningMessage = (_a = channelsControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
86
|
-
var _c = useAppSelector(entitySelector), data = _c.data, error = _c.error;
|
|
87
|
-
var channelList = (data.verify.responseBody || {}).channelList;
|
|
88
|
-
var salesChannels = (data.entityData || {}).salesChannels;
|
|
89
|
-
React.useEffect(function () {
|
|
90
|
-
if ((channelList === null || channelList === void 0 ? void 0 : channelList.length) > 0) {
|
|
91
|
-
setChannelsMenuList(channelList);
|
|
92
|
-
}
|
|
93
|
-
}, [channelList]);
|
|
94
|
-
var handleSalesChannelChange = function (event, checked) {
|
|
95
|
-
var selected = channelsMenuList.find(function (channel) { return channel.id === event.target.id; });
|
|
96
|
-
var isExists = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (selected === null || selected === void 0 ? void 0 : selected.id); });
|
|
97
|
-
if (isExists) {
|
|
98
|
-
var updatedIdList = channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.filter(function (channel) { return channel.id !== (selected === null || selected === void 0 ? void 0 : selected.id); });
|
|
99
|
-
channelsControl.field.onChange(updatedIdList);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
channelsControl.field.onChange(__spreadArray(__spreadArray([], channelsChecked, true), [selected], false));
|
|
103
|
-
if (error)
|
|
104
|
-
dispatch(clearError());
|
|
105
|
-
};
|
|
106
|
-
var getSelectedChannelsFlag = function (item) {
|
|
107
|
-
if (channelsChecked)
|
|
108
|
-
return !!(channelsChecked === null || channelsChecked === void 0 ? void 0 : channelsChecked.find(function (channel) { return channel.id === (item === null || item === void 0 ? void 0 : item.id); }));
|
|
109
|
-
};
|
|
110
|
-
return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('channel_of_service') }), channelsMenuList.map(function (channel) {
|
|
111
|
-
var _a, _b;
|
|
112
|
-
return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disableFocusRipple: true, focusRipple: false, disabled: (salesChannels === null || salesChannels === void 0 ? void 0 : salesChannels.find(function (c) { return c.id === (channel === null || channel === void 0 ? void 0 : channel.id); })) ? true : false, checked: getSelectedChannelsFlag(channel), onChange: handleSalesChannelChange }), _jsxs(TextStyled, { children: [isAr ? (_a = channel === null || channel === void 0 ? void 0 : channel.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = channel === null || channel === void 0 ? void 0 : channel.name) === null || _b === void 0 ? void 0 : _b.en, " "] })] }, channel.id));
|
|
113
|
-
}), _jsx(CollapseStyled, __assign({ in: !!warningMessage }, { children: _jsx(Warning, __assign({ warningType: 'alert' }, { children: t(warningMessage) })) }))] }));
|
|
114
|
-
};
|
|
115
|
-
export default SalesChannels;
|