@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
|
@@ -10,17 +10,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
15
|
-
import { styled } from '@mui/material/styles';
|
|
16
13
|
import { useTranslation } from 'react-i18next';
|
|
17
14
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
+
import { styled } from '@mui/material/styles';
|
|
18
16
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
17
|
+
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
18
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
|
+
import { individualSelector, signatureFileUploadingStatus } from '../../../app/individual/individualStore';
|
|
22
20
|
import Collapse from '../../../../components/Collapse';
|
|
23
|
-
import { maskFileName } from '../../../../utils';
|
|
24
21
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
25
22
|
var theme = _a.theme;
|
|
26
23
|
return ({
|
|
@@ -28,63 +25,18 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
28
25
|
});
|
|
29
26
|
});
|
|
30
27
|
var SignatureFile = function (_a) {
|
|
31
|
-
var _b, _c;
|
|
32
28
|
var show = _a.show;
|
|
33
|
-
var _d = React.useState(0), progress = _d[0], setProgress = _d[1];
|
|
34
29
|
var t = useTranslation().t;
|
|
35
|
-
var
|
|
36
|
-
var signatureFileControl = useController({ name: 'signatureFile', control: control });
|
|
30
|
+
var control = useFormContext().control;
|
|
37
31
|
var signatureFileIdControl = useController({ name: 'signatureFileId', control: control });
|
|
38
|
-
var
|
|
39
|
-
var _g = data.attachmentsData, signatureFileUploading = _g.signatureFileUploading, signatureFile = _g.signatureFile, signatureFileId = _g.signatureFileId;
|
|
32
|
+
var loading = useAppSelector(individualSelector).loading;
|
|
40
33
|
var dispatch = useAppDispatch();
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
var handleSignatureChange = function (files) {
|
|
44
|
-
var file = files === null || files === void 0 ? void 0 : files[0];
|
|
45
|
-
if (!VALID_FILE_FORMATS.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
46
|
-
setError('signatureFile', { message: 'file_not_supported_alert' });
|
|
47
|
-
}
|
|
48
|
-
else if ((file === null || file === void 0 ? void 0 : file.size) > MAX_FILE_SIZE) {
|
|
49
|
-
setError('signatureFile', { message: 'file_size_alert' });
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
signatureFileControl.field.onChange(file);
|
|
53
|
-
dispatch(uploadSignatureFile({
|
|
54
|
-
file: file,
|
|
55
|
-
onProgress: function (value) {
|
|
56
|
-
setProgress(value);
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
34
|
+
var handleSignatureChange = function (ids) {
|
|
35
|
+
signatureFileIdControl.field.onChange(ids);
|
|
60
36
|
};
|
|
61
|
-
var handleReset = function () {
|
|
62
|
-
|
|
63
|
-
signatureFileIdControl.field.onChange('');
|
|
64
|
-
setProgress(0);
|
|
37
|
+
var handleReset = function (ids) {
|
|
38
|
+
signatureFileIdControl.field.onChange(ids);
|
|
65
39
|
};
|
|
66
|
-
|
|
67
|
-
if (sysError === 'file_upload_error') {
|
|
68
|
-
setError('signatureFileId', { message: sysError });
|
|
69
|
-
signatureFileControl.field.onChange(null);
|
|
70
|
-
setProgress(0);
|
|
71
|
-
}
|
|
72
|
-
}, [sysError]);
|
|
73
|
-
React.useEffect(function () {
|
|
74
|
-
if ((signatureFileControl.formState.isValid || !!signatureValue) && error != 'file_upload_error')
|
|
75
|
-
clearErrors();
|
|
76
|
-
}, [signatureFileControl.formState.isValid, signatureValue]);
|
|
77
|
-
React.useEffect(function () {
|
|
78
|
-
if (!!signatureFile) {
|
|
79
|
-
setValue('signatureFile', signatureFile);
|
|
80
|
-
setValue('signatureFileId', signatureFileId);
|
|
81
|
-
}
|
|
82
|
-
}, [signatureFile, signatureFileId]);
|
|
83
|
-
React.useEffect(function () {
|
|
84
|
-
if (!!signatureValue)
|
|
85
|
-
signatureFileControl.field.onChange(signatureFile);
|
|
86
|
-
}, []);
|
|
87
|
-
var fileName = signatureValue ? maskFileName(signatureValue === null || signatureValue === void 0 ? void 0 : signatureValue.name) : '';
|
|
88
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadFile, { label: t('title_signature_file'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_signature'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_signature_file'), onFileUploaded: handleSignatureChange, isFileUploaded: !signatureFileUploading && !!signatureValue, isSubmitting: loading, initialFileName: fileName, isUploading: signatureFileUploading, progress: progress, onReset: handleReset, error: error && t(error) }) }) })));
|
|
40
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { label: t('title_signature_file'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_signature'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_signature_file'), onFileUploaded: handleSignatureChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: 'customer_signature', fileTitle: 'Merchant Signature', fileUploadingStatus: function (uploading) { return dispatch(signatureFileUploadingStatus(uploading)); } }) }) })));
|
|
89
41
|
};
|
|
90
42
|
export default SignatureFile;
|
|
@@ -6,10 +6,8 @@ export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yu
|
|
|
6
6
|
sourceIncome: import("yup/lib/object").RequiredObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
|
|
7
7
|
monthlyIncome: import("yup/lib/object").OptionalObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
|
|
8
8
|
employerLocation: import("yup/lib/object").OptionalObjectSchema<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>>>;
|
|
9
|
-
civilID: yup.
|
|
10
|
-
|
|
11
|
-
signatureFileId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
12
|
-
signatureFile: any;
|
|
9
|
+
civilID: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
10
|
+
signatureFileId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
13
11
|
isPEP: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
14
12
|
isInfluencer: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
15
13
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<ObjectShape, {
|
|
@@ -17,10 +15,8 @@ export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yu
|
|
|
17
15
|
sourceIncome: import("yup/lib/object").RequiredObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
|
|
18
16
|
monthlyIncome: import("yup/lib/object").OptionalObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
|
|
19
17
|
employerLocation: import("yup/lib/object").OptionalObjectSchema<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>>>;
|
|
20
|
-
civilID: yup.
|
|
21
|
-
|
|
22
|
-
signatureFileId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
23
|
-
signatureFile: any;
|
|
18
|
+
civilID: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
19
|
+
signatureFileId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
24
20
|
isPEP: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
25
21
|
isInfluencer: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
26
22
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<ObjectShape, {
|
|
@@ -28,10 +24,8 @@ export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yu
|
|
|
28
24
|
sourceIncome: import("yup/lib/object").RequiredObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
|
|
29
25
|
monthlyIncome: import("yup/lib/object").OptionalObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>>;
|
|
30
26
|
employerLocation: import("yup/lib/object").OptionalObjectSchema<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<Partial<Record<keyof CountryCode, yup.AnySchema<any, any, any> | import("yup/lib/Reference").default<unknown> | import("yup/lib/Lazy").default<any, any>>>>>;
|
|
31
|
-
civilID: yup.
|
|
32
|
-
|
|
33
|
-
signatureFileId: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
34
|
-
signatureFile: any;
|
|
27
|
+
civilID: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
28
|
+
signatureFileId: yup.ArraySchema<yup.AnySchema<any, any, any>, import("yup/lib/types").AnyObject, any[] | undefined, any[] | undefined>;
|
|
35
29
|
isPEP: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
36
30
|
isInfluencer: import("yup/lib/boolean").RequiredBooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject>;
|
|
37
31
|
}>>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
import { MAX_FILE_SIZE, VALID_FILE_FORMATS } from '../../../../constants';
|
|
3
2
|
export var IndividualInfoValidationSchema = yup.object().shape({
|
|
4
3
|
occupation: yup.object().required('alert_choose_occupation'),
|
|
5
4
|
sourceIncome: yup.object().required('choose_any_source_of_income'),
|
|
@@ -20,28 +19,8 @@ export var IndividualInfoValidationSchema = yup.object().shape({
|
|
|
20
19
|
return yup.object().optional();
|
|
21
20
|
}
|
|
22
21
|
}),
|
|
23
|
-
civilID: yup.
|
|
24
|
-
|
|
25
|
-
.mixed()
|
|
26
|
-
.test({
|
|
27
|
-
test: function (value) {
|
|
28
|
-
if (!!value)
|
|
29
|
-
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 ? true : this.createError({ message: 'alert_file_upload' });
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.optional(),
|
|
34
|
-
signatureFileId: yup.string().optional(),
|
|
35
|
-
signatureFile: yup
|
|
36
|
-
.mixed()
|
|
37
|
-
.test({
|
|
38
|
-
test: function (value) {
|
|
39
|
-
if (!!value)
|
|
40
|
-
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 ? true : this.createError({ message: 'alert_file_upload' });
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
.optional(),
|
|
22
|
+
civilID: yup.array().optional(),
|
|
23
|
+
signatureFileId: yup.array().optional(),
|
|
45
24
|
isPEP: yup.boolean().required('please_choose_relative_pep'),
|
|
46
25
|
isInfluencer: yup.boolean().required('please_choose_are_you_influncer')
|
|
47
26
|
});
|
|
@@ -80,7 +80,7 @@ function CountryList(_a) {
|
|
|
80
80
|
return '';
|
|
81
81
|
return isAr ? item.name.arabic : item.name.english;
|
|
82
82
|
}, [isAr, list, value]);
|
|
83
|
-
return (_jsxs(Box, { children: [_jsx(LabelContainerStyled, { children: _jsxs(InputLabelStyled, { children: [t(label), " ", isRequired && _jsx(MandatoryStyled, { children: "*" })] }) }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: nameValue, placeholder: placeholder, onClick: handleListOpenClose, endAdornment: !disabled && _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleListStyled, { searchValuePath: 'name.english', searchKeyPath: 'name.english', list: list, onSelectItem: handleValueChange, renderItem: function (item) {
|
|
83
|
+
return (_jsxs(Box, { children: [_jsx(LabelContainerStyled, { children: _jsxs(InputLabelStyled, { children: [t(label), " ", isRequired && _jsx(MandatoryStyled, { children: "*" })] }) }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: nameValue, placeholder: placeholder, onClick: handleListOpenClose, endAdornment: !disabled && _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleListStyled, { searchValuePath: ['name.english', 'name.arabic'], searchKeyPath: 'name.english', list: list, onSelectItem: handleValueChange, renderItem: function (item) {
|
|
84
84
|
var _a, _b;
|
|
85
85
|
var isChecked = item.countryId === value;
|
|
86
86
|
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: isChecked }, { children: isAr ? (_a = item.name) === null || _a === void 0 ? void 0 : _a.arabic : (_b = item.name) === null || _b === void 0 ? void 0 : _b.english })) })), isChecked && _jsx(CheckIconStyled, {})] }));
|
|
@@ -141,7 +141,7 @@ function InputSelect(_a) {
|
|
|
141
141
|
return React.useMemo(function () {
|
|
142
142
|
if (data.length === 0 && countryIso2)
|
|
143
143
|
return (_jsx(InputText, { label: label, onChange: function (value) { return onSelect(value); }, placeholder: placeholder, isRequired: isRequired, value: value, error: error }, 'input-text'));
|
|
144
|
-
return (_jsxs(Box, { children: [_jsx(LabelContainerStyled, { children: _jsxs(InputLabelStyled, { children: [t(label), " ", isRequired && _jsx(MandatoryStyled, { children: "*" })] }) }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: nameValue, placeholder: placeholder, onClick: handleListOpenClose, endAdornment: loading ? _jsx(CircularProgress, { size: 25, thickness: 5 }) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleListStyled, { searchValuePath: 'name.en', searchKeyPath: 'name.en', list: data, onSelectItem: function (item) {
|
|
144
|
+
return (_jsxs(Box, { children: [_jsx(LabelContainerStyled, { children: _jsxs(InputLabelStyled, { children: [t(label), " ", isRequired && _jsx(MandatoryStyled, { children: "*" })] }) }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: true, value: nameValue, placeholder: placeholder, onClick: handleListOpenClose, endAdornment: loading ? _jsx(CircularProgress, { size: 25, thickness: 5 }) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleListStyled, { searchValuePath: ['name.en', 'name.ar'], searchKeyPath: 'name.en', list: data, onSelectItem: function (item) {
|
|
145
145
|
onSelect(item.id);
|
|
146
146
|
setAnchorEl(null);
|
|
147
147
|
}, renderItem: function (item) {
|
|
@@ -4,7 +4,8 @@ interface SalesChannelProps {
|
|
|
4
4
|
list: SaleChannel[];
|
|
5
5
|
error: string | undefined;
|
|
6
6
|
onChange: (channel: SaleChannel[]) => void;
|
|
7
|
-
|
|
7
|
+
defaultValue?: SaleChannel[];
|
|
8
|
+
selectFirstIconListener?: string | number | boolean;
|
|
8
9
|
}
|
|
9
|
-
declare const _default: React.MemoExoticComponent<({ list, onChange, error,
|
|
10
|
+
declare const _default: React.MemoExoticComponent<({ list, onChange, error, defaultValue, selectFirstIconListener }: SalesChannelProps) => JSX.Element>;
|
|
10
11
|
export default _default;
|
|
@@ -74,9 +74,9 @@ var CollapseStyled = styled(Collapse)(function (_a) {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
var SalesChannel = function (_a) {
|
|
77
|
-
var _b = _a.list, list = _b === void 0 ? [] : _b, onChange = _a.onChange, error = _a.error, _c = _a.
|
|
78
|
-
var _d = React.useState([]), selectedSalas = _d[0], setSelectedSales = _d[1];
|
|
77
|
+
var _b = _a.list, list = _b === void 0 ? [] : _b, onChange = _a.onChange, error = _a.error, _c = _a.defaultValue, defaultValue = _c === void 0 ? [] : _c, _d = _a.selectFirstIconListener, selectFirstIconListener = _d === void 0 ? '' : _d;
|
|
79
78
|
var _e = React.useState(''), activeSaleIconId = _e[0], setActiveSaleIconId = _e[1];
|
|
79
|
+
var _f = React.useState([]), selectedSalas = _f[0], setSelectedSales = _f[1];
|
|
80
80
|
var t = useTranslation().t;
|
|
81
81
|
var isAr = useLanguage().isAr;
|
|
82
82
|
var isChecked = function (id) {
|
|
@@ -85,19 +85,28 @@ var SalesChannel = function (_a) {
|
|
|
85
85
|
var onChangeActiveSaleIcon = function (id) {
|
|
86
86
|
setActiveSaleIconId(id);
|
|
87
87
|
};
|
|
88
|
+
var selectFirstIcon = function (salesChannels) {
|
|
89
|
+
var firstItem = salesChannels.at(0);
|
|
90
|
+
if (firstItem)
|
|
91
|
+
onChangeActiveSaleIcon(findFirstId([firstItem]));
|
|
92
|
+
};
|
|
93
|
+
var selectLastIcon = function (salesChannels) {
|
|
94
|
+
var lastItem = salesChannels.at(-1);
|
|
95
|
+
if (lastItem)
|
|
96
|
+
onChangeActiveSaleIcon(findFirstId([lastItem]));
|
|
97
|
+
};
|
|
88
98
|
var onSelectSalesChannel = function (channel) {
|
|
89
99
|
if (isChecked(channel.id)) {
|
|
90
100
|
var newSelectedSales = selectedSalas.filter(function (item) { return item.id !== channel.id; });
|
|
91
101
|
setSelectedSales(newSelectedSales);
|
|
92
102
|
onChange(newSelectedSales);
|
|
93
|
-
|
|
94
|
-
if (item)
|
|
95
|
-
onChangeActiveSaleIcon(findFirstId([item]));
|
|
103
|
+
selectLastIcon(newSelectedSales);
|
|
96
104
|
return;
|
|
97
105
|
}
|
|
98
106
|
onChangeActiveSaleIcon(findFirstId([channel]));
|
|
99
107
|
setSelectedSales(__spreadArray(__spreadArray([], selectedSalas, true), [channel], false));
|
|
100
108
|
onChange(__spreadArray(__spreadArray([], selectedSalas, true), [channel], false));
|
|
109
|
+
selectLastIcon(__spreadArray(__spreadArray([], selectedSalas, true), [channel], false));
|
|
101
110
|
};
|
|
102
111
|
var onValueChange = function (value, id) {
|
|
103
112
|
var newSelectedSales = selectedSalas.map(function (item) {
|
|
@@ -120,13 +129,18 @@ var SalesChannel = function (_a) {
|
|
|
120
129
|
onChange(newSelectedSales);
|
|
121
130
|
};
|
|
122
131
|
React.useEffect(function () {
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
if (defaultValue.length && !activeSaleIconId) {
|
|
133
|
+
selectFirstIcon(defaultValue);
|
|
134
|
+
}
|
|
135
|
+
}, [defaultValue]);
|
|
136
|
+
React.useEffect(function () {
|
|
137
|
+
setSelectedSales(defaultValue);
|
|
138
|
+
}, [defaultValue]);
|
|
139
|
+
React.useEffect(function () {
|
|
140
|
+
if (defaultValue.length) {
|
|
141
|
+
selectFirstIcon(defaultValue);
|
|
128
142
|
}
|
|
129
|
-
}, [
|
|
143
|
+
}, [selectFirstIconListener]);
|
|
130
144
|
return (_jsxs(_Fragment, { children: [_jsxs(Box, __assign({ sx: { mb: 3 } }, { children: [_jsxs(InputLabelStyled, { children: [t('channel_of_service'), " ", _jsx(MandatoryStyled, { children: "*" })] }), list.map(function (channel, index) {
|
|
131
145
|
var _a, _b;
|
|
132
146
|
return (_jsxs(ContainerStyled, { children: [_jsx(CheckBoxStyled, { id: channel.id, disableRipple: true, disableFocusRipple: true, focusRipple: false, checked: isChecked(channel.id), onChange: function () { return onSelectSalesChannel(channel); } }), _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, " "] })] }, "".concat(channel.id, "-indx").concat(index)));
|
|
@@ -86,6 +86,6 @@ var UploadFile = function (_a) {
|
|
|
86
86
|
else
|
|
87
87
|
setShowFile(false);
|
|
88
88
|
}, [isFileUploaded]);
|
|
89
|
-
return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {})] }), _jsx(Collapse, __assign({ in: !showFile }, { children: _jsx(InputContainerStyled, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: !!fileName, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: progress, uploading: isUploading, uploadSuccess: isFileUploaded, onSuccess: handleFileChange, error: error, multiple: multiple }) }) })), _jsx(Collapse, __assign({ in: showFile, timeout: 300 }, { children: _jsxs(InputContainerStyled, { children: [_jsxs(BoxStyled, { children: [_jsxs(Box, __assign({ sx: { display: 'flex' } }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: fileName })] })), _jsx(Box, { children: _jsx(CheckIcon, {}) })] }), _jsx(UploadBoxStyled, __assign({ onClick: handleReset }, { children: _jsx(ClearIconStyled, {}) }))] }) }))] }));
|
|
89
|
+
return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: label }), required && _jsx(Mandatory, {})] }), _jsx(Collapse, __assign({ in: !showFile || !!error }, { children: _jsx(InputContainerStyled, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: !!fileName, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: progress, uploading: isUploading, uploadSuccess: isFileUploaded, onSuccess: handleFileChange, error: error, multiple: multiple }) }) })), _jsx(Collapse, __assign({ in: showFile && !error, timeout: 300 }, { children: _jsxs(InputContainerStyled, { children: [_jsxs(BoxStyled, { children: [_jsxs(Box, __assign({ sx: { display: 'flex' } }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: fileName })] })), _jsx(Box, { children: _jsx(CheckIcon, {}) })] }), _jsx(UploadBoxStyled, __assign({ onClick: handleReset }, { children: _jsx(ClearIconStyled, {}) }))] }) }))] }));
|
|
90
90
|
};
|
|
91
91
|
export default UploadFile;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
component?: React.ElementType<any> | undefined;
|
|
6
|
+
ref?: React.Ref<unknown> | undefined;
|
|
7
|
+
sx?: SxProps<Theme> | undefined;
|
|
8
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
9
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
10
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "ref" | "children" | "component" | "sx"> & import("@mui/system").MUIStyledCommonProps<Theme>, {}, {}>;
|
|
11
|
+
export declare enum FileStatus {
|
|
12
|
+
INIT = "init",
|
|
13
|
+
UPLOADING = "uploading",
|
|
14
|
+
SUCCESS = "success",
|
|
15
|
+
ERROR = "error",
|
|
16
|
+
ALREADY_UPLOADED = "already_uploaded"
|
|
17
|
+
}
|
|
18
|
+
export declare type FileInfo = {
|
|
19
|
+
fileId: string;
|
|
20
|
+
name: string;
|
|
21
|
+
status: FileStatus;
|
|
22
|
+
progress: number;
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
export declare type UploadFileProps = {
|
|
26
|
+
index: number;
|
|
27
|
+
purpose: string;
|
|
28
|
+
file: File;
|
|
29
|
+
title?: string;
|
|
30
|
+
uploadedFiles: Array<FileInfo>;
|
|
31
|
+
onSuccess: (index: number, file: FileInfo) => void;
|
|
32
|
+
onFailure: (index: number, file: FileInfo) => void;
|
|
33
|
+
onDelete: (index: number) => void;
|
|
34
|
+
onProgress: (index: number, file: FileInfo) => void;
|
|
35
|
+
sx?: SxProps<Theme> | undefined;
|
|
36
|
+
};
|
|
37
|
+
declare const UploadFile: ({ index, title, file, uploadedFiles, onSuccess, onFailure, onDelete, onProgress, sx, purpose }: UploadFileProps) => JSX.Element;
|
|
38
|
+
export default UploadFile;
|
|
@@ -1 +1,184 @@
|
|
|
1
|
-
|
|
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, Fragment as _Fragment } from "react/jsx-runtime";
|
|
49
|
+
import React from 'react';
|
|
50
|
+
import { useTranslation } from 'react-i18next';
|
|
51
|
+
import { alpha, styled, useTheme } from '@mui/material/styles';
|
|
52
|
+
import Box from '@mui/material/Box';
|
|
53
|
+
import ClearIcon from '@mui/icons-material/Clear';
|
|
54
|
+
import Collapse from '../../../components/Collapse';
|
|
55
|
+
import { CircularProgress } from '../../../components/ProgressBar';
|
|
56
|
+
import Text from '../../../components/Text';
|
|
57
|
+
import Icon from '../../../components/Icon';
|
|
58
|
+
import { maskFileName } from '../../../utils';
|
|
59
|
+
import API from '../../../api';
|
|
60
|
+
import { ICONS_NAMES, MAX_FILE_SIZE_FOUR_MB, VALID_FILE_FORMATS } from '../../../constants';
|
|
61
|
+
import CheckIcon from '../../shared/CheckIcon';
|
|
62
|
+
var BoxStyled = styled(Box)(function (_a) {
|
|
63
|
+
var theme = _a.theme;
|
|
64
|
+
return (__assign(__assign({ direction: theme.direction }, theme.typography.subtitle2), { color: theme.palette.primary.main, fontWeight: theme.typography.fontWeightBold, background: theme.palette.background.default, padding: theme.spacing(0, 2.5, 0), width: '88%', wordBreak: 'break-all', display: 'flex', justifyContent: 'space-between' }));
|
|
65
|
+
});
|
|
66
|
+
var UploadBoxStyled = styled(Box, { shouldForwardProp: function (prop) { return prop !== 'uploading'; } })(function (_a) {
|
|
67
|
+
var theme = _a.theme, uploading = _a.uploading;
|
|
68
|
+
return (__assign(__assign({}, theme.typography.caption), { background: uploading ? alpha(theme.palette.primary.main, 0.5) : theme.palette.primary.main, color: theme.palette.common.white, fontWeight: theme.typography.fontWeightRegular, cursor: 'pointer', width: '12%', display: 'flex', justifyContent: 'center', alignItems: 'center' }));
|
|
69
|
+
});
|
|
70
|
+
var ClearIconStyled = styled(ClearIcon)(function (_a) {
|
|
71
|
+
var theme = _a.theme;
|
|
72
|
+
return ({
|
|
73
|
+
width: theme.spacing(3),
|
|
74
|
+
height: theme.spacing(3),
|
|
75
|
+
cursor: 'pointer',
|
|
76
|
+
color: theme.palette.common.white
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
export var InputContainerStyled = styled(Box)(function () { return ({
|
|
80
|
+
display: 'flex',
|
|
81
|
+
width: '100%',
|
|
82
|
+
justifyContent: 'center'
|
|
83
|
+
}); });
|
|
84
|
+
var CenterBoxStyled = styled(Box)(function () { return ({
|
|
85
|
+
display: 'flex',
|
|
86
|
+
justifyContent: 'center',
|
|
87
|
+
alignItems: 'center'
|
|
88
|
+
}); });
|
|
89
|
+
var WarningIconStyled = styled(Icon)(function (_a) {
|
|
90
|
+
var theme = _a.theme;
|
|
91
|
+
return ({
|
|
92
|
+
width: theme.spacing(1.625),
|
|
93
|
+
height: theme.spacing(1.625),
|
|
94
|
+
marginInline: theme.spacing(0.5)
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
var ErrorIconStyled = styled(Icon)(function (_a) {
|
|
98
|
+
var theme = _a.theme;
|
|
99
|
+
return ({
|
|
100
|
+
width: theme.spacing(1.625),
|
|
101
|
+
height: theme.spacing(1.625),
|
|
102
|
+
marginInline: theme.spacing(0.5)
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var WarningContainer = styled(Box)(function (_a) {
|
|
106
|
+
var theme = _a.theme;
|
|
107
|
+
return (__assign({ background: alpha(theme.palette.warning.main, 0.1), paddingBlock: theme.spacing(1.5), paddingInlineStart: theme.spacing(2.5), flexDirection: 'row', display: 'flex', justifyContent: 'center', color: theme.palette.warning.light, padding: theme.spacing(0.5, 1), borderRadius: '101px', alignItems: 'center', marginTop: theme.spacing(1.25) }, theme.typography.caption));
|
|
108
|
+
});
|
|
109
|
+
export var FileStatus;
|
|
110
|
+
(function (FileStatus) {
|
|
111
|
+
FileStatus["INIT"] = "init";
|
|
112
|
+
FileStatus["UPLOADING"] = "uploading";
|
|
113
|
+
FileStatus["SUCCESS"] = "success";
|
|
114
|
+
FileStatus["ERROR"] = "error";
|
|
115
|
+
FileStatus["ALREADY_UPLOADED"] = "already_uploaded";
|
|
116
|
+
})(FileStatus || (FileStatus = {}));
|
|
117
|
+
var UploadFile = function (_a) {
|
|
118
|
+
var index = _a.index, title = _a.title, file = _a.file, uploadedFiles = _a.uploadedFiles, onSuccess = _a.onSuccess, onFailure = _a.onFailure, onDelete = _a.onDelete, onProgress = _a.onProgress, sx = _a.sx, purpose = _a.purpose;
|
|
119
|
+
var theme = useTheme();
|
|
120
|
+
var t = useTranslation().t;
|
|
121
|
+
var _b = file || {}, name = _b.name, size = _b.size, type = _b.type;
|
|
122
|
+
var uploadedFile = (uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles[index]) || {};
|
|
123
|
+
var status = uploadedFile.status, progress = uploadedFile.progress, error = uploadedFile.error;
|
|
124
|
+
var uploadFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
+
var uploadPayload, onUploadProgress, data, fileId;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
uploadPayload = {
|
|
130
|
+
file_link_create: true,
|
|
131
|
+
title: title || (file === null || file === void 0 ? void 0 : file.name),
|
|
132
|
+
purpose: purpose,
|
|
133
|
+
file: file
|
|
134
|
+
};
|
|
135
|
+
onUploadProgress = function (progressEvent) {
|
|
136
|
+
var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
|
|
137
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { progress: Math.floor(progress), status: FileStatus.UPLOADING });
|
|
138
|
+
onProgress(index, uploadedFile);
|
|
139
|
+
};
|
|
140
|
+
return [4, API.fileService.uploadFile(uploadPayload, { onUploadProgress: onUploadProgress })];
|
|
141
|
+
case 1:
|
|
142
|
+
data = (_a.sent()).data;
|
|
143
|
+
fileId = (data || {}).id;
|
|
144
|
+
if (fileId) {
|
|
145
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.SUCCESS, fileId: fileId });
|
|
146
|
+
onSuccess(index, uploadedFile);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { progress: 0, status: FileStatus.ERROR, error: 'file_upload_error' });
|
|
150
|
+
onFailure(index, uploadedFile);
|
|
151
|
+
}
|
|
152
|
+
return [2];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}); };
|
|
156
|
+
React.useEffect(function () {
|
|
157
|
+
if (!file)
|
|
158
|
+
return;
|
|
159
|
+
else if (!VALID_FILE_FORMATS.includes(type)) {
|
|
160
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.ERROR, error: 'file_not_supported_alert' });
|
|
161
|
+
onFailure(index, uploadedFile);
|
|
162
|
+
}
|
|
163
|
+
else if (size > MAX_FILE_SIZE_FOUR_MB) {
|
|
164
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.ERROR, error: 'file_size_alert' });
|
|
165
|
+
onFailure(index, uploadedFile);
|
|
166
|
+
}
|
|
167
|
+
else if (status === FileStatus.ALREADY_UPLOADED) {
|
|
168
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { error: 'file_already_exist', progress: 0 });
|
|
169
|
+
onFailure(index, uploadedFile);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if (uploadedFile.status !== FileStatus.UPLOADING && uploadedFile.status !== FileStatus.SUCCESS) {
|
|
173
|
+
uploadFile();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, []);
|
|
177
|
+
return (_jsx(Box, { children: _jsxs(InputContainerStyled, __assign({ sx: __assign({ borderTop: "1px solid ".concat(alpha(theme.palette.divider, 0.8)) }, sx) }, { children: [_jsxs(BoxStyled, { children: [_jsxs(Box, __assign({ sx: {
|
|
178
|
+
display: 'flex',
|
|
179
|
+
flexDirection: 'column',
|
|
180
|
+
padding: theme.spacing(1.5, 0, 1.5),
|
|
181
|
+
width: '100%'
|
|
182
|
+
} }, { children: [_jsxs(Box, __assign({ sx: { display: 'flex', flexDirection: 'row' } }, { children: [_jsx(Icon, { src: ICONS_NAMES.DOC_ICON }), _jsx(Text, { children: maskFileName(name) })] })), _jsx(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', justifyContent: 'center' } }, { children: _jsx(Collapse, __assign({ in: !!error, timeout: 400 }, { children: _jsxs(WarningContainer, { children: [_jsx(WarningIconStyled, { src: ICONS_NAMES.WARNING_ICON }), _jsx(Text, { children: t(error) })] }) })) }))] })), _jsx(CenterBoxStyled, { children: error ? (_jsx(ErrorIconStyled, { src: ICONS_NAMES.ERROR_ICON })) : status === FileStatus.SUCCESS ? (_jsx(CheckIcon, {})) : progress ? (_jsx(CircularProgress, { sx: { backgroundColor: alpha(theme.palette.primary.main, 0.05), borderRadius: '32px' }, textSx: { fontSize: theme.spacing(1.125) }, value: progress, size: 35 })) : (_jsx(_Fragment, {})) })] }), _jsx(UploadBoxStyled, __assign({ uploading: status === FileStatus.UPLOADING, onClick: status === FileStatus.UPLOADING ? undefined : function () { return onDelete(index); } }, { children: _jsx(ClearIconStyled, {}) }))] })) }, index));
|
|
183
|
+
};
|
|
184
|
+
export default UploadFile;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
component?: React.ElementType<any> | undefined;
|
|
5
|
+
ref?: React.Ref<unknown> | undefined;
|
|
6
|
+
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
7
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
8
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
9
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | ("border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "color" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform") | "ref" | "children" | "component" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
10
|
+
interface UploadMultipleFileProps {
|
|
11
|
+
label: string;
|
|
12
|
+
purpose: string;
|
|
13
|
+
fileTitle?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
title: string;
|
|
16
|
+
subTitle: string;
|
|
17
|
+
dragDescription: string;
|
|
18
|
+
uploadingTitle: string;
|
|
19
|
+
successTitle: string;
|
|
20
|
+
isSubmitting?: boolean;
|
|
21
|
+
onFileUploaded: (fileIds: Array<string>) => void;
|
|
22
|
+
fileUploadingStatus?: (uploading: boolean) => void;
|
|
23
|
+
onDeleteFile: (fileIds: Array<string>) => void;
|
|
24
|
+
maxLimit?: number;
|
|
25
|
+
}
|
|
26
|
+
declare const UploadMultipleFile: ({ label, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle }: UploadMultipleFileProps) => JSX.Element;
|
|
27
|
+
export default UploadMultipleFile;
|