@tap-payments/auth-jsconnect 2.0.48 → 2.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/@types/app.d.ts +8 -6
- package/build/@types/form.d.ts +23 -22
- package/build/@types/theme.d.ts +1 -1
- package/build/api/account.d.ts +2 -2
- package/build/api/auth.d.ts +11 -11
- package/build/api/availabilityServices.d.ts +3 -3
- package/build/api/axios.js +1 -1
- package/build/api/board.d.ts +3 -3
- package/build/api/country.d.ts +1 -1
- package/build/api/data.d.ts +10 -10
- package/build/api/document.d.ts +25 -0
- package/build/api/document.js +38 -0
- package/build/api/entity.d.ts +10 -20
- package/build/api/entity.js +6 -5
- package/build/api/file.d.ts +2 -1
- package/build/api/file.js +14 -1
- package/build/api/index.d.ts +10 -3
- package/build/api/index.js +3 -1
- package/build/api/individual.d.ts +8 -8
- package/build/api/lead.d.ts +10 -10
- package/build/api/operator.d.ts +1 -1
- package/build/api/operator.js +1 -1
- package/build/api/user.d.ts +2 -2
- package/build/app/settings.d.ts +11 -2
- package/build/app/settings.js +1 -1
- package/build/app/store.d.ts +4 -4
- package/build/assets/locales/ar.json +3 -1
- package/build/assets/locales/en.json +3 -1
- package/build/components/Lottie/Lottie.d.ts +1 -2
- package/build/components/Lottie/Lottie.js +1 -1
- package/build/components/Lottie/index.d.ts +2 -2
- package/build/components/Lottie/index.js +2 -2
- package/build/components/Slide/Slide.d.ts +1 -1
- package/build/constants/app.d.ts +31 -0
- package/build/constants/app.js +43 -1
- package/build/features/app/bank/bankStore.d.ts +73 -10
- package/build/features/app/bank/bankStore.js +29 -15
- package/build/features/app/brand/brandStore.d.ts +104 -12
- package/build/features/app/brand/brandStore.js +65 -66
- package/build/features/app/business/businessStore.d.ts +163 -19
- package/build/features/app/business/businessStore.js +3 -3
- package/build/features/app/connect/connectStore.d.ts +121 -13
- package/build/features/app/connect/connectStore.js +1 -1
- package/build/features/app/connectExpress/connectExpressStore.d.ts +181 -19
- package/build/features/app/connectExpress/connectExpressStore.js +1 -1
- package/build/features/app/entity/entityStore.d.ts +76 -20
- package/build/features/app/entity/entityStore.js +67 -93
- package/build/features/app/individual/individualStore.d.ts +182 -20
- package/build/features/app/individual/individualStore.js +278 -135
- package/build/features/app/password/passwordStore.d.ts +102 -12
- package/build/features/app/password/passwordStore.js +1 -1
- package/build/features/app/signIn/signInStore.d.ts +61 -7
- package/build/features/app/signIn/signInStore.js +1 -1
- package/build/features/app/tax/taxStore.d.ts +62 -8
- package/build/features/app/tax/taxStore.js +25 -12
- package/build/features/bank/screens/BankDetails/BankStatement.d.ts +1 -1
- package/build/features/bank/screens/BankDetails/BankStatement.js +4 -3
- package/build/features/bank/screens/BankDetails/IBAN.js +1 -1
- package/build/features/bank/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/brand/screens/BrandActivities/ActivitiesList.d.ts +13 -13
- package/build/features/brand/screens/BrandActivities/ActivitiesList.js +6 -7
- package/build/features/brand/screens/BrandActivities/CustomerBase.d.ts +11 -11
- package/build/features/brand/screens/BrandActivities/CustomerBase.js +5 -7
- package/build/features/brand/screens/BrandActivities/ExpectedSalesRange.js +5 -7
- package/build/features/brand/screens/BrandActivities/OperationStartDate.d.ts +2 -2
- package/build/features/brand/screens/BrandActivities/RefundPolicy.d.ts +5 -5
- package/build/features/brand/screens/BrandInfo/BrandName.js +1 -1
- package/build/features/brand/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/business/screens/Activities/ActivitiesList.d.ts +13 -13
- package/build/features/business/screens/Activities/OperationStartDate.d.ts +2 -2
- package/build/features/business/screens/BusinessType/Article.d.ts +1 -1
- package/build/features/business/screens/BusinessType/Article.js +1 -1
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
- package/build/features/business/screens/BusinessType/LicenseType.d.ts +5 -5
- package/build/features/business/screens/Customers/CustomerLocations.d.ts +11 -11
- package/build/features/business/screens/Customers/RefundPolicy.d.ts +5 -5
- package/build/features/business/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/connect/screens/Individual/Email.js +1 -1
- package/build/features/connect/screens/Merchant/BrandName.js +1 -1
- package/build/features/connectExpress/screens/CollectBusinessInfo/BrandName.js +1 -1
- package/build/features/connectExpress/screens/CollectBusinessInfo/LicenseType.d.ts +5 -5
- package/build/features/connectExpress/screens/CollectIndividualInfo/Email.js +1 -1
- package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +13 -13
- package/build/features/entity/screens/EntityCapital/ActivityList.js +7 -7
- package/build/features/entity/screens/EntityCapital/CapitalPaid.js +3 -4
- package/build/features/entity/screens/EntityCapital/CapitalShareCount.js +3 -4
- package/build/features/entity/screens/EntityCapital/CapitalShareValue.js +3 -4
- package/build/features/entity/screens/EntityName/Article.d.ts +1 -1
- package/build/features/entity/screens/EntityName/Article.js +16 -53
- package/build/features/entity/screens/EntityName/EntityName.js +2 -3
- package/build/features/entity/screens/EntityName/EntityTypeList.d.ts +13 -13
- package/build/features/entity/screens/EntityName/EntityTypeList.js +4 -6
- package/build/features/entity/screens/EntityName/ExpiryDate.d.ts +2 -2
- package/build/features/entity/screens/EntityName/ExpiryDate.js +6 -6
- package/build/features/entity/screens/EntityName/IssuingDate.d.ts +2 -2
- package/build/features/entity/screens/EntityName/IssuingDate.js +4 -5
- package/build/features/entity/screens/EntityName/LegalName.js +2 -4
- package/build/features/entity/screens/EntityName/LicenseCertificate.js +4 -3
- package/build/features/entity/screens/EntityName/LicenseNumber.js +4 -4
- package/build/features/entity/screens/EntityName/UnifiedNumber.js +3 -4
- package/build/features/entity/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/featuresScreens.js +5 -0
- package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.d.ts +2 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +4 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/InfluencerSwitch.js +2 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/MonthlyIncome.js +5 -6
- package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +5 -6
- package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.d.ts +4 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/PEPSwitch.js +2 -4
- package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +4 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/SourceOfIncome.js +5 -6
- package/build/features/individual/screens/IndividualList/CollectPhoneEmail.d.ts +2 -0
- package/build/features/individual/screens/IndividualList/CollectPhoneEmail.js +3 -2
- package/build/features/individual/screens/IndividualList/Email.d.ts +5 -1
- package/build/features/individual/screens/IndividualList/Email.js +73 -8
- package/build/features/individual/screens/IndividualList/IndividualList.d.ts +4 -4
- package/build/features/individual/screens/IndividualList/UserList.js +36 -19
- package/build/features/individual/screens/IndividualList/validation.js +2 -1
- package/build/features/individual/screens/IndividualPersonalInfo/Email.js +2 -3
- package/build/features/individual/screens/IndividualPersonalInfo/ExpiryDate.js +3 -4
- package/build/features/individual/screens/IndividualPersonalInfo/Gender.d.ts +5 -5
- package/build/features/individual/screens/IndividualPersonalInfo/ID.js +2 -3
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.d.ts +2 -2
- package/build/features/individual/screens/IndividualPersonalInfo/IssuedCountry.js +6 -7
- package/build/features/individual/screens/IndividualPersonalInfo/MobileNumber.js +5 -6
- package/build/features/individual/screens/IndividualPersonalInfo/Name.js +2 -3
- package/build/features/individual/screens/IndividualPersonalInfo/Nationality.js +6 -7
- package/build/features/individual/screens/IndividualPhoneInfo/MobileNumber.d.ts +12 -0
- package/build/features/individual/screens/IndividualPhoneInfo/MobileNumber.js +143 -0
- package/build/features/individual/screens/IndividualPhoneInfo/PhoneInfo.d.ts +5 -0
- package/build/features/individual/screens/IndividualPhoneInfo/PhoneInfo.js +60 -0
- package/build/features/individual/screens/IndividualPhoneInfo/index.d.ts +3 -0
- package/build/features/individual/screens/IndividualPhoneInfo/index.js +2 -0
- package/build/features/individual/screens/IndividualPhoneInfo/validation.d.ts +8 -0
- package/build/features/individual/screens/IndividualPhoneInfo/validation.js +31 -0
- package/build/features/individual/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/password/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/shared/Address/CountryList.d.ts +9 -9
- package/build/features/shared/Address/InputSelect.d.ts +9 -9
- package/build/features/shared/Address/InputSelect.js +1 -1
- package/build/features/shared/Button/Button.js +1 -1
- package/build/features/shared/Button/EmailProvidersButtons.d.ts +1 -1
- package/build/features/shared/Button/FlowsButtons.d.ts +1 -1
- package/build/features/shared/Button/FlowsButtons.js +1 -1
- package/build/features/shared/Button/{ListButton.d.ts → IndividualActionButtons.d.ts} +5 -4
- package/build/features/shared/Button/IndividualActionButtons.js +132 -0
- package/build/features/shared/Button/index.d.ts +1 -1
- package/build/features/shared/Button/index.js +1 -1
- package/build/features/shared/Containers/FeatureContainer.d.ts +1 -1
- package/build/features/shared/Containers/ScreenContainer.d.ts +1 -1
- package/build/features/shared/Input/Input.d.ts +3 -3
- package/build/features/shared/SuccessFlowButtons/SuccessFlowButtons.js +11 -1
- package/build/features/shared/UploadFile/FileUpload.d.ts +29 -0
- package/build/features/shared/UploadFile/FileUpload.js +263 -0
- package/build/features/shared/UploadFile/UploadFile.d.ts +2 -2
- package/build/features/shared/UploadFile/UploadWrapper.d.ts +33 -0
- package/build/features/shared/UploadFile/UploadWrapper.js +114 -0
- package/build/features/shared/UploadFile/index.d.ts +2 -1
- package/build/features/shared/UploadFile/index.js +2 -1
- package/build/features/shared/UploadMultipleFile/UploadFile.d.ts +9 -20
- package/build/features/shared/UploadMultipleFile/UploadFile.js +109 -24
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +6 -4
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +26 -19
- package/build/features/tax/screens/ResetPasswordSuccess/ResetPasswordSuccess.js +1 -1
- package/build/features/tax/screens/TaxDetails/TaxDocument.js +4 -3
- package/build/features/tax/screens/TaxDetails/VATId.js +3 -4
- package/build/index.d.ts +2 -2
- package/build/index.js +4 -3
- package/build/utils/array.d.ts +3 -1
- package/build/utils/array.js +35 -6
- package/package.json +1 -1
- package/build/features/shared/Button/ListButton.js +0 -125
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useController } from 'react-hook-form';
|
|
16
|
+
import { styled } from '@mui/material/styles';
|
|
17
|
+
import Box from '@mui/material/Box';
|
|
18
|
+
import { DragAndDrop } from '../../../components/FileInput';
|
|
19
|
+
import Collapse from '../../../components/Collapse';
|
|
20
|
+
import { getFileType } from '../../../utils';
|
|
21
|
+
import { DeleteFileStatus, FileStatus } from '../../../constants';
|
|
22
|
+
import { InputLabelStyled } from '../../shared/Input/Input';
|
|
23
|
+
import { ScreenContainer } from '../../shared/Containers';
|
|
24
|
+
import Mandatory from '../../shared/Mandatory';
|
|
25
|
+
import FileUpload from './FileUpload';
|
|
26
|
+
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
27
|
+
var theme = _a.theme;
|
|
28
|
+
return ({
|
|
29
|
+
marginBlockStart: theme.spacing(0)
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
33
|
+
var theme = _a.theme;
|
|
34
|
+
return ({
|
|
35
|
+
display: 'flex',
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
padding: theme.spacing(0, 2.5, 1.25, 2.5),
|
|
38
|
+
alignItems: 'center'
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
export var InputContainerStyled = styled(Box)(function () { return ({
|
|
42
|
+
display: 'flex',
|
|
43
|
+
width: '100%',
|
|
44
|
+
justifyContent: 'center'
|
|
45
|
+
}); });
|
|
46
|
+
var UploadWrapper = function (_a) {
|
|
47
|
+
var id = _a.id, label = _a.label, control = _a.control, required = _a.required, fileRemoveType = _a.fileRemoveType, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, purpose = _a.purpose, fileTitle = _a.fileTitle, defaultFile = _a.defaultFile;
|
|
48
|
+
var t = useTranslation().t;
|
|
49
|
+
var _b = React.useState(''), error = _b[0], setError = _b[1];
|
|
50
|
+
var fileControl = useController({ name: "".concat(id, "File"), control: control });
|
|
51
|
+
var fileInfoControl = useController({ name: "".concat(id, "FileInfo"), control: control });
|
|
52
|
+
var fileData = fileControl.field.value;
|
|
53
|
+
var fileInfo = fileInfoControl.field.value;
|
|
54
|
+
React.useEffect(function () {
|
|
55
|
+
if (!fileData && !fileInfo && defaultFile) {
|
|
56
|
+
var title_1 = defaultFile.title, size = defaultFile.size, type = defaultFile.type, id_1 = defaultFile.id, docId = defaultFile.docId;
|
|
57
|
+
var fileData_1 = { name: title_1, size: size, type: getFileType(type) };
|
|
58
|
+
var fileInfoData = {
|
|
59
|
+
fileId: id_1,
|
|
60
|
+
docId: docId,
|
|
61
|
+
status: FileStatus.SUCCESS,
|
|
62
|
+
progress: 100,
|
|
63
|
+
error: '',
|
|
64
|
+
name: title_1 || ''
|
|
65
|
+
};
|
|
66
|
+
fileControl.field.onChange(fileData_1);
|
|
67
|
+
fileInfoControl.field.onChange(fileInfoData);
|
|
68
|
+
}
|
|
69
|
+
}, [defaultFile]);
|
|
70
|
+
var handleFileChange = function (files) {
|
|
71
|
+
if (!isSubmitting) {
|
|
72
|
+
if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
|
|
73
|
+
setError('');
|
|
74
|
+
var fileData_2 = files[0];
|
|
75
|
+
fileControl.field.onChange(fileData_2);
|
|
76
|
+
fileInfoControl.field.onChange({
|
|
77
|
+
fileId: '',
|
|
78
|
+
docId: '',
|
|
79
|
+
status: FileStatus.INIT,
|
|
80
|
+
progress: 0,
|
|
81
|
+
error: '',
|
|
82
|
+
name: fileData_2.name
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var handleDelete = function () {
|
|
88
|
+
if (!isSubmitting) {
|
|
89
|
+
setError('');
|
|
90
|
+
if (required)
|
|
91
|
+
setError(t('should_upload_file'));
|
|
92
|
+
fileControl.field.onChange(null);
|
|
93
|
+
fileInfoControl.field.onChange(null);
|
|
94
|
+
onDeleteFile();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var handleSuccess = function (fileInfo) {
|
|
98
|
+
if (fileInfo) {
|
|
99
|
+
fileInfoControl.field.onChange(__assign({}, fileInfo));
|
|
100
|
+
onFileUploaded(fileInfo.fileId);
|
|
101
|
+
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var handleUpdate = function (fileInfo, loadingStatus) {
|
|
105
|
+
if (fileInfo) {
|
|
106
|
+
fileInfoControl.field.onChange(__assign({}, fileInfo));
|
|
107
|
+
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(loadingStatus);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var fileExists = !!fileInfo;
|
|
111
|
+
var showUploadedInputField = (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.SUCCESS || (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.DOWNLOADING || (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.deleteStatus) === DeleteFileStatus.DELETING;
|
|
112
|
+
return (_jsxs(FeatureStyled, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: _jsxs(_Fragment, { children: [label, required && _jsx(Mandatory, {})] }) }) }), _jsx(Collapse, __assign({ in: !showUploadedInputField }, { children: _jsx(InputContainerStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: fileExists, uploadingTitle: uploadingTitle, successTitle: successTitle, progress: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.progress, uploading: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.UPLOADING, uploadSuccess: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.status) === FileStatus.SUCCESS, onSuccess: handleFileChange, error: (fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.error) || error, multiple: false }) })) })), _jsx(Collapse, __assign({ in: fileExists, timeout: 300 }, { children: _jsx(FileUpload, { show: showUploadedInputField, fileRemoveType: fileRemoveType, purpose: purpose, title: fileTitle || '', isSubmitting: isSubmitting, uploadedFile: fileInfo, file: fileData, onSuccess: handleSuccess, onDelete: handleDelete, onUpdate: handleUpdate, initialFileId: defaultFile === null || defaultFile === void 0 ? void 0 : defaultFile.id }) }))] }));
|
|
113
|
+
};
|
|
114
|
+
export default React.memo(UploadWrapper);
|
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { FileInfo, FileType } from '../../../constants';
|
|
3
4
|
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<Theme> & {
|
|
4
5
|
children?: React.ReactNode;
|
|
5
6
|
component?: React.ElementType<any> | undefined;
|
|
6
7
|
ref?: React.Ref<unknown> | undefined;
|
|
7
8
|
sx?: SxProps<Theme> | undefined;
|
|
8
|
-
} &
|
|
9
|
+
} & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
9
10
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
10
|
-
},
|
|
11
|
-
export
|
|
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 = {
|
|
11
|
+
}, ("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>, {}, {}>;
|
|
12
|
+
export type UploadFileProps = {
|
|
26
13
|
index: number;
|
|
27
14
|
purpose: string;
|
|
28
15
|
file: File;
|
|
16
|
+
fileType: FileType;
|
|
17
|
+
required?: boolean;
|
|
29
18
|
title?: string;
|
|
30
19
|
uploadedFiles: Array<FileInfo>;
|
|
31
20
|
onSuccess: (index: number, file: FileInfo) => void;
|
|
32
|
-
onFailure: (index: number, file: FileInfo) => void;
|
|
33
21
|
onDelete: (index: number) => void;
|
|
34
|
-
|
|
22
|
+
onUpdate: (index: number, file: FileInfo, loadingStatus: boolean) => void;
|
|
35
23
|
sx?: SxProps<Theme> | undefined;
|
|
24
|
+
isSubmitting?: boolean;
|
|
36
25
|
};
|
|
37
|
-
declare const UploadFile: ({ index, title, file, uploadedFiles, onSuccess,
|
|
26
|
+
declare const UploadFile: ({ index, title, file, fileType, uploadedFiles, onSuccess, onDelete, onUpdate, sx, purpose, isSubmitting }: UploadFileProps) => JSX.Element;
|
|
38
27
|
export default UploadFile;
|
|
@@ -24,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
24
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
25
|
function step(op) {
|
|
26
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
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
29
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
30
|
switch (op[0]) {
|
|
@@ -45,19 +45,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
import { jsx as _jsx,
|
|
48
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
49
|
import React from 'react';
|
|
50
50
|
import { useTranslation } from 'react-i18next';
|
|
51
51
|
import { alpha, styled, useTheme } from '@mui/material/styles';
|
|
52
52
|
import Box from '@mui/material/Box';
|
|
53
53
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
54
|
+
import { CircularProgress as MUICircularProgress } from '@mui/material';
|
|
54
55
|
import Collapse from '../../../components/Collapse';
|
|
55
56
|
import { CircularProgress } from '../../../components/ProgressBar';
|
|
56
57
|
import Text from '../../../components/Text';
|
|
57
58
|
import Icon from '../../../components/Icon';
|
|
58
59
|
import { maskFileName } from '../../../utils';
|
|
59
60
|
import API from '../../../api';
|
|
60
|
-
import { ICONS_NAMES, MAX_FILE_SIZE_FOUR_MB, VALID_FILE_FORMATS } from '../../../constants';
|
|
61
|
+
import { DeleteFileStatus, FileStatus, ICONS_NAMES, MAX_FILE_SIZE_FOUR_MB, VALID_FILE_FORMATS } from '../../../constants';
|
|
61
62
|
import CheckIcon from '../../shared/CheckIcon';
|
|
62
63
|
var BoxStyled = styled(Box)(function (_a) {
|
|
63
64
|
var theme = _a.theme;
|
|
@@ -81,7 +82,7 @@ export var InputContainerStyled = styled(Box)(function () { return ({
|
|
|
81
82
|
width: '100%',
|
|
82
83
|
justifyContent: 'center'
|
|
83
84
|
}); });
|
|
84
|
-
var
|
|
85
|
+
var ProgressBoxStyled = styled(Box)(function () { return ({
|
|
85
86
|
display: 'flex',
|
|
86
87
|
justifyContent: 'center',
|
|
87
88
|
alignItems: 'center'
|
|
@@ -106,21 +107,16 @@ var WarningContainer = styled(Box)(function (_a) {
|
|
|
106
107
|
var theme = _a.theme;
|
|
107
108
|
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
|
});
|
|
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
110
|
var UploadFile = function (_a) {
|
|
118
|
-
var index = _a.index, title = _a.title, file = _a.file,
|
|
111
|
+
var index = _a.index, title = _a.title, file = _a.file, fileType = _a.fileType, uploadedFiles = _a.uploadedFiles, onSuccess = _a.onSuccess, onDelete = _a.onDelete, onUpdate = _a.onUpdate, sx = _a.sx, purpose = _a.purpose, isSubmitting = _a.isSubmitting;
|
|
119
112
|
var theme = useTheme();
|
|
120
113
|
var t = useTranslation().t;
|
|
121
114
|
var _b = file || {}, name = _b.name, size = _b.size, type = _b.type;
|
|
122
115
|
var uploadedFile = (uploadedFiles === null || uploadedFiles === void 0 ? void 0 : uploadedFiles[index]) || {};
|
|
123
|
-
var status = uploadedFile.status, progress = uploadedFile.progress, error = uploadedFile.error;
|
|
116
|
+
var status = uploadedFile.status, progress = uploadedFile.progress, error = uploadedFile.error, deleteStatus = uploadedFile.deleteStatus;
|
|
117
|
+
var isAnyFileDoingDeleteUploadDownload = React.useMemo(function () {
|
|
118
|
+
return (uploadedFiles || []).find(function (f) { return f.deleteStatus === DeleteFileStatus.DELETING || f.status === FileStatus.UPLOADING || f.status === FileStatus.DOWNLOADING; });
|
|
119
|
+
}, [uploadedFiles]);
|
|
124
120
|
var uploadFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
121
|
var uploadPayload, onUploadProgress, data, fileId;
|
|
126
122
|
return __generator(this, function (_a) {
|
|
@@ -134,51 +130,140 @@ var UploadFile = function (_a) {
|
|
|
134
130
|
};
|
|
135
131
|
onUploadProgress = function (progressEvent) {
|
|
136
132
|
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
|
-
|
|
133
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { progress: Math.floor(progress), status: FileStatus.UPLOADING, error: '' });
|
|
134
|
+
onUpdate(index, uploadedFile, true);
|
|
139
135
|
};
|
|
140
136
|
return [4, API.fileService.uploadFile(uploadPayload, { onUploadProgress: onUploadProgress })];
|
|
141
137
|
case 1:
|
|
142
138
|
data = (_a.sent()).data;
|
|
143
139
|
fileId = (data || {}).id;
|
|
144
140
|
if (fileId) {
|
|
145
|
-
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.SUCCESS, fileId: fileId });
|
|
141
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.SUCCESS, fileId: fileId, error: '' });
|
|
146
142
|
onSuccess(index, uploadedFile);
|
|
147
143
|
}
|
|
148
144
|
else {
|
|
149
145
|
uploadedFile = __assign(__assign({}, uploadedFile), { progress: 0, status: FileStatus.ERROR, error: 'file_upload_error' });
|
|
150
|
-
|
|
146
|
+
onUpdate(index, uploadedFile, false);
|
|
151
147
|
}
|
|
152
148
|
return [2];
|
|
153
149
|
}
|
|
154
150
|
});
|
|
155
151
|
}); };
|
|
152
|
+
var deleteFile = function (index) { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
|
+
var payload, data, docId, _a;
|
|
154
|
+
var _b;
|
|
155
|
+
return __generator(this, function (_c) {
|
|
156
|
+
switch (_c.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
_c.trys.push([0, 2, , 3]);
|
|
159
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.DELETING, error: '' });
|
|
160
|
+
onUpdate(index, uploadedFile, true);
|
|
161
|
+
payload = (_b = {
|
|
162
|
+
id: uploadedFile.docId
|
|
163
|
+
},
|
|
164
|
+
_b[fileType] = [uploadedFile.fileId],
|
|
165
|
+
_b);
|
|
166
|
+
return [4, API.documentService.removeFilesFromDocument(payload)];
|
|
167
|
+
case 1:
|
|
168
|
+
data = (_c.sent()).data;
|
|
169
|
+
docId = (data || {}).id;
|
|
170
|
+
if (docId) {
|
|
171
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.SUCCESS, fileId: '', error: '', docId: '' });
|
|
172
|
+
onUpdate(index, uploadedFile, false);
|
|
173
|
+
onDelete(index);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.ERROR, error: 'file_delete_error' });
|
|
177
|
+
onUpdate(index, uploadedFile, false);
|
|
178
|
+
}
|
|
179
|
+
return [3, 3];
|
|
180
|
+
case 2:
|
|
181
|
+
_a = _c.sent();
|
|
182
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { deleteStatus: DeleteFileStatus.ERROR, error: 'file_delete_error' });
|
|
183
|
+
onUpdate(index, uploadedFile, false);
|
|
184
|
+
return [3, 3];
|
|
185
|
+
case 3: return [2];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}); };
|
|
189
|
+
var downloadFile = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
var onDownloadProgress, data, _a;
|
|
191
|
+
return __generator(this, function (_b) {
|
|
192
|
+
switch (_b.label) {
|
|
193
|
+
case 0:
|
|
194
|
+
onDownloadProgress = function (progressEvent) {
|
|
195
|
+
var progress = ((progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.loaded) / (progressEvent === null || progressEvent === void 0 ? void 0 : progressEvent.total)) * 100;
|
|
196
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { progress: Math.floor(progress), status: FileStatus.DOWNLOADING, error: '' });
|
|
197
|
+
onUpdate(index, uploadedFile, true);
|
|
198
|
+
};
|
|
199
|
+
_b.label = 1;
|
|
200
|
+
case 1:
|
|
201
|
+
_b.trys.push([1, 3, , 4]);
|
|
202
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { progress: 0, status: FileStatus.DOWNLOADING, error: '' });
|
|
203
|
+
onUpdate(index, uploadedFile, true);
|
|
204
|
+
return [4, API.fileService.downloadFile(uploadedFile.fileId, uploadedFile.name, { onDownloadProgress: onDownloadProgress })];
|
|
205
|
+
case 2:
|
|
206
|
+
data = (_b.sent()).data;
|
|
207
|
+
if (data) {
|
|
208
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.SUCCESS, error: '' });
|
|
209
|
+
onSuccess(index, uploadedFile);
|
|
210
|
+
}
|
|
211
|
+
return [3, 4];
|
|
212
|
+
case 3:
|
|
213
|
+
_a = _b.sent();
|
|
214
|
+
uploadedFile = __assign(__assign({}, uploadedFile), { error: 'file_download_error', status: FileStatus.SUCCESS });
|
|
215
|
+
onUpdate(index, uploadedFile, false);
|
|
216
|
+
return [3, 4];
|
|
217
|
+
case 4: return [2];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}); };
|
|
221
|
+
var handleDeleteFile = function (index) {
|
|
222
|
+
if (uploadedFile.docId) {
|
|
223
|
+
deleteFile(index);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
onDelete(index);
|
|
227
|
+
};
|
|
228
|
+
var getProgressComponent = function () {
|
|
229
|
+
if (status === FileStatus.ERROR)
|
|
230
|
+
return _jsx(ErrorIconStyled, { src: ICONS_NAMES.ERROR_ICON });
|
|
231
|
+
if (status === FileStatus.SUCCESS)
|
|
232
|
+
return _jsx(CheckIcon, {});
|
|
233
|
+
if (status === FileStatus.DOWNLOADING && !progress)
|
|
234
|
+
return _jsx(MUICircularProgress, { size: 25, thickness: 5 });
|
|
235
|
+
if (progress)
|
|
236
|
+
return (_jsx(CircularProgress, { sx: { backgroundColor: alpha(theme.palette.primary.main, 0.05), borderRadius: '32px' }, textSx: { fontSize: theme.spacing(1.125) }, value: progress, size: 35 }));
|
|
237
|
+
return _jsx(_Fragment, {});
|
|
238
|
+
};
|
|
156
239
|
React.useEffect(function () {
|
|
157
240
|
if (!file)
|
|
158
241
|
return;
|
|
159
242
|
else if (!VALID_FILE_FORMATS.includes(type)) {
|
|
160
243
|
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.ERROR, error: 'file_not_supported_alert' });
|
|
161
|
-
|
|
244
|
+
onUpdate(index, uploadedFile, false);
|
|
162
245
|
}
|
|
163
246
|
else if (size > MAX_FILE_SIZE_FOUR_MB) {
|
|
164
247
|
uploadedFile = __assign(__assign({}, uploadedFile), { status: FileStatus.ERROR, error: 'file_size_alert' });
|
|
165
|
-
|
|
248
|
+
onUpdate(index, uploadedFile, false);
|
|
166
249
|
}
|
|
167
250
|
else if (status === FileStatus.ALREADY_UPLOADED) {
|
|
168
251
|
uploadedFile = __assign(__assign({}, uploadedFile), { error: 'file_already_exist', progress: 0 });
|
|
169
|
-
|
|
252
|
+
onUpdate(index, uploadedFile, false);
|
|
170
253
|
}
|
|
171
254
|
else {
|
|
172
|
-
if (uploadedFile.status
|
|
255
|
+
if (uploadedFile.status === FileStatus.INIT || uploadedFile.status === FileStatus.ERROR) {
|
|
173
256
|
uploadFile();
|
|
174
257
|
}
|
|
175
258
|
}
|
|
176
259
|
}, []);
|
|
177
|
-
|
|
260
|
+
var canDownloadFile = uploadedFile.fileId && status !== FileStatus.DOWNLOADING;
|
|
261
|
+
var canDeleteFile = !isAnyFileDoingDeleteUploadDownload;
|
|
262
|
+
return (_jsx(Box, __assign({ sx: { pointerEvents: isSubmitting ? 'none' : 'auto' } }, { 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
263
|
display: 'flex',
|
|
179
264
|
flexDirection: 'column',
|
|
180
265
|
padding: theme.spacing(1.5, 0, 1.5),
|
|
181
266
|
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(
|
|
267
|
+
} }, { children: [_jsxs(Box, __assign({ sx: { display: 'flex', flexDirection: 'row', cursor: canDownloadFile ? 'pointer' : 'auto' }, onClick: canDownloadFile ? function () { return downloadFile(); } : undefined }, { 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(ProgressBoxStyled, { children: getProgressComponent() })] }), _jsx(UploadBoxStyled, __assign({ uploading: status === FileStatus.UPLOADING || (!!isAnyFileDoingDeleteUploadDownload && deleteStatus !== DeleteFileStatus.DELETING), onClick: canDeleteFile ? function () { return handleDeleteFile(index); } : undefined }, { children: deleteStatus === DeleteFileStatus.DELETING ? (_jsx(MUICircularProgress, { size: 25, thickness: 5, sx: { color: theme.palette.common.white } })) : (_jsx(ClearIconStyled, {})) }))] })) }), index));
|
|
183
268
|
};
|
|
184
269
|
export default UploadFile;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FileDetails } from '../../../@types';
|
|
3
2
|
import { Control, FieldValues } from 'react-hook-form';
|
|
3
|
+
import { FileDetails } from '../../../@types';
|
|
4
|
+
import { FileType } from '../../../constants';
|
|
4
5
|
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
component?: React.ElementType<any> | undefined;
|
|
7
8
|
ref?: React.Ref<unknown> | undefined;
|
|
8
9
|
sx?: import("@mui/material/styles").SxProps<import("@mui/material/styles").Theme> | undefined;
|
|
9
|
-
} &
|
|
10
|
+
} & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
10
11
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
11
|
-
},
|
|
12
|
+
}, ("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>, {}, {}>;
|
|
12
13
|
interface UploadMultipleFileProps {
|
|
13
14
|
id: string;
|
|
14
15
|
control: Control<FieldValues, any>;
|
|
15
16
|
label: string;
|
|
16
17
|
purpose: string;
|
|
18
|
+
fileType: FileType;
|
|
17
19
|
fileTitle?: string;
|
|
18
20
|
required?: boolean;
|
|
19
21
|
title: string;
|
|
@@ -28,5 +30,5 @@ interface UploadMultipleFileProps {
|
|
|
28
30
|
maxLimit?: number;
|
|
29
31
|
defaultFiles?: Array<FileDetails>;
|
|
30
32
|
}
|
|
31
|
-
declare const UploadMultipleFile: ({ id, label, control, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle, defaultFiles }: UploadMultipleFileProps) => JSX.Element;
|
|
33
|
+
declare const UploadMultipleFile: ({ id, label, control, required, fileType, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle, defaultFiles }: UploadMultipleFileProps) => JSX.Element;
|
|
32
34
|
export default UploadMultipleFile;
|
|
@@ -21,16 +21,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
21
21
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
22
|
import React from 'react';
|
|
23
23
|
import { useTranslation } from 'react-i18next';
|
|
24
|
+
import { useController } from 'react-hook-form';
|
|
24
25
|
import { alpha, styled, useTheme } from '@mui/material/styles';
|
|
25
26
|
import Box from '@mui/material/Box';
|
|
26
27
|
import { DragAndDrop } from '../../../components/FileInput';
|
|
27
28
|
import Collapse from '../../../components/Collapse';
|
|
29
|
+
import { getFileType } from '../../../utils';
|
|
30
|
+
import { DeleteFileStatus, FileStatus } from '../../../constants';
|
|
28
31
|
import { InputLabelStyled } from '../../shared/Input/Input';
|
|
29
32
|
import { ScreenContainer } from '../../shared/Containers';
|
|
30
33
|
import Mandatory from '../../shared/Mandatory';
|
|
31
|
-
import UploadFile
|
|
32
|
-
import { useController } from 'react-hook-form';
|
|
33
|
-
import { getFileType } from '../../../utils';
|
|
34
|
+
import UploadFile from './UploadFile';
|
|
34
35
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
35
36
|
var theme = _a.theme;
|
|
36
37
|
return ({
|
|
@@ -61,7 +62,7 @@ var UploadCountBox = styled(Box)(function (_a) {
|
|
|
61
62
|
});
|
|
62
63
|
});
|
|
63
64
|
var UploadMultipleFile = function (_a) {
|
|
64
|
-
var id = _a.id, label = _a.label, control = _a.control, required = _a.required, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle, defaultFiles = _a.defaultFiles;
|
|
65
|
+
var id = _a.id, label = _a.label, control = _a.control, required = _a.required, fileType = _a.fileType, title = _a.title, subTitle = _a.subTitle, dragDescription = _a.dragDescription, uploadingTitle = _a.uploadingTitle, successTitle = _a.successTitle, isSubmitting = _a.isSubmitting, onFileUploaded = _a.onFileUploaded, fileUploadingStatus = _a.fileUploadingStatus, onDeleteFile = _a.onDeleteFile, maxLimit = _a.maxLimit, purpose = _a.purpose, fileTitle = _a.fileTitle, defaultFiles = _a.defaultFiles;
|
|
65
66
|
var t = useTranslation().t;
|
|
66
67
|
var theme = useTheme();
|
|
67
68
|
var _b = React.useState(''), error = _b[0], setError = _b[1];
|
|
@@ -76,10 +77,12 @@ var UploadMultipleFile = function (_a) {
|
|
|
76
77
|
fileArray.push({ name: file.title, size: file.size, type: getFileType(file.type) });
|
|
77
78
|
fileInfoArray.push({
|
|
78
79
|
fileId: file.id,
|
|
80
|
+
docId: file.docId,
|
|
79
81
|
status: FileStatus.SUCCESS,
|
|
80
82
|
progress: 100,
|
|
81
83
|
error: '',
|
|
82
|
-
name: file.title || ''
|
|
84
|
+
name: file.title || '',
|
|
85
|
+
deleteStatus: DeleteFileStatus.NONE
|
|
83
86
|
});
|
|
84
87
|
});
|
|
85
88
|
fileControl.field.onChange(__spreadArray([], fileArray, true));
|
|
@@ -107,14 +110,24 @@ var UploadMultipleFile = function (_a) {
|
|
|
107
110
|
if (isFileAlreadyUploaded) {
|
|
108
111
|
fileInfoArray.push({
|
|
109
112
|
fileId: '',
|
|
113
|
+
docId: '',
|
|
110
114
|
status: FileStatus.ALREADY_UPLOADED,
|
|
111
115
|
progress: 0,
|
|
112
116
|
error: '',
|
|
113
|
-
name: file.name
|
|
117
|
+
name: file.name,
|
|
118
|
+
deleteStatus: DeleteFileStatus.NONE
|
|
114
119
|
});
|
|
115
120
|
}
|
|
116
121
|
else {
|
|
117
|
-
fileInfoArray.push({
|
|
122
|
+
fileInfoArray.push({
|
|
123
|
+
fileId: '',
|
|
124
|
+
docId: '',
|
|
125
|
+
status: FileStatus.INIT,
|
|
126
|
+
progress: 0,
|
|
127
|
+
error: '',
|
|
128
|
+
name: file.name,
|
|
129
|
+
deleteStatus: DeleteFileStatus.NONE
|
|
130
|
+
});
|
|
118
131
|
}
|
|
119
132
|
});
|
|
120
133
|
fileControl.field.onChange(__spreadArray([], fileArray, true));
|
|
@@ -133,7 +146,8 @@ var UploadMultipleFile = function (_a) {
|
|
|
133
146
|
fileInfoArray.splice(index, 1);
|
|
134
147
|
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
135
148
|
var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
|
|
136
|
-
|
|
149
|
+
var filteredFromDefaultFiles = fileIds.filter(function (id) { return !(defaultFiles || []).some(function (file) { return file.id === id; }); });
|
|
150
|
+
onDeleteFile(filteredFromDefaultFiles);
|
|
137
151
|
}
|
|
138
152
|
}
|
|
139
153
|
};
|
|
@@ -147,25 +161,18 @@ var UploadMultipleFile = function (_a) {
|
|
|
147
161
|
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
|
|
148
162
|
}
|
|
149
163
|
};
|
|
150
|
-
var
|
|
151
|
-
if (fileInfoArray.length > 0) {
|
|
152
|
-
fileInfoArray[index] = file;
|
|
153
|
-
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
154
|
-
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var handleProgress = function (index, file) {
|
|
164
|
+
var handleUpdate = function (index, file, loadingStatus) {
|
|
158
165
|
if (fileInfoArray.length > 0) {
|
|
159
166
|
fileInfoArray[index] = file;
|
|
160
167
|
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
161
|
-
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(
|
|
168
|
+
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(loadingStatus);
|
|
162
169
|
}
|
|
163
170
|
};
|
|
164
171
|
var fileExists = fileInfoArray.length > 0;
|
|
165
172
|
return (_jsxs(FeatureStyled, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: _jsxs(_Fragment, { children: [label, required && _jsx(Mandatory, {})] }) }), _jsx(Collapse, __assign({ in: !!uploadedFileCount, timeout: 100, unmountOnExit: true }, { children: _jsx(UploadCountBox, { children: "".concat(uploadedFileCount, " ").concat(t('uploaded_file')) }) }))] }), _jsx(InputContainerStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(DragAndDrop, { title: title, subTitle: subTitle, description: dragDescription, fileExists: fileExists, uploadingTitle: uploadingTitle, successTitle: successTitle, onSuccess: handleFileChange, multiple: true, error: error }) })), _jsx(Collapse, __assign({ in: fileExists, timeout: 300 }, { children: (fileArray || []).map(function (file, index) {
|
|
166
|
-
return (_jsx(UploadFile, { purpose: purpose, title: fileTitle, uploadedFiles: fileInfoArray, index: index, file: file, sx: {
|
|
173
|
+
return (_jsx(UploadFile, { required: required, purpose: purpose, fileType: fileType, title: fileTitle, isSubmitting: isSubmitting, uploadedFiles: fileInfoArray, index: index, file: file, sx: {
|
|
167
174
|
borderBottom: index === fileArray.length - 1 ? "1px solid ".concat(alpha(theme.palette.divider, 0.8)) : ''
|
|
168
|
-
}, onSuccess: handleSuccess, onDelete: handleDelete,
|
|
175
|
+
}, onSuccess: handleSuccess, onDelete: handleDelete, onUpdate: handleUpdate }, index));
|
|
169
176
|
}) }))] }));
|
|
170
177
|
};
|
|
171
178
|
export default UploadMultipleFile;
|
|
@@ -9,7 +9,7 @@ var ResetPasswordSuccess = function (_a) {
|
|
|
9
9
|
var _b, _c;
|
|
10
10
|
var t = useTranslation().t;
|
|
11
11
|
var data = useAppSelector(taxSelector).data;
|
|
12
|
-
var email = ((_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.business) === null || _c === void 0 ? void 0 : _c.primary_contact).email;
|
|
12
|
+
var email = (((_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.business) === null || _c === void 0 ? void 0 : _c.primary_contact) || {}).email;
|
|
13
13
|
var maskedEmail = maskEmail(email);
|
|
14
14
|
return (_jsx(SuccessScreen, { title: t("reset_password_success_title"), description: _jsx(Trans, { i18nKey: 'reset_password_success_description_dev', values: { email: maskedEmail } }), showEmailProviders: true }));
|
|
15
15
|
};
|
|
@@ -17,7 +17,8 @@ import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
|
17
17
|
import { DocumentPurpose } from '../../../../@types';
|
|
18
18
|
import { styled } from '@mui/material/styles';
|
|
19
19
|
import Collapse from '../../../../components/Collapse';
|
|
20
|
-
import {
|
|
20
|
+
import { getFileDetailsFromDocument } from '../../../../utils';
|
|
21
|
+
import { FileType } from '../../../../constants';
|
|
21
22
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
22
23
|
import { taxSelector, uploadingStatus } from '../../../app/tax/taxStore';
|
|
23
24
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
@@ -42,7 +43,7 @@ var TaxDocument = function (_a) {
|
|
|
42
43
|
var handleReset = function (ids) {
|
|
43
44
|
documentIdControl.field.onChange(ids);
|
|
44
45
|
};
|
|
45
|
-
var defaultFiles = React.useMemo(function () { return
|
|
46
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(UploadMultipleFile, { id: 'documentId', control: control, label: t('title_tax_document'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_tax_document'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleTaxDocumentChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, defaultFiles: defaultFiles, purpose: DocumentPurpose.TAX_DOCUMENT, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) })) })));
|
|
46
|
+
var defaultFiles = React.useMemo(function () { return getFileDetailsFromDocument(documents, DocumentPurpose.TAX_DOCUMENT); }, [documents]);
|
|
47
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, __assign({ sx: { mb: 2.5 } }, { children: _jsx(UploadMultipleFile, { id: 'documentId', control: control, label: t('title_tax_document'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_tax_document'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleTaxDocumentChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, defaultFiles: defaultFiles, purpose: DocumentPurpose.TAX_DOCUMENT, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); }, fileType: FileType.IMAGES }) })) })));
|
|
47
48
|
};
|
|
48
49
|
export default TaxDocument;
|
|
@@ -17,14 +17,13 @@ import { useTranslation } from 'react-i18next';
|
|
|
17
17
|
import { useController, useFormContext } from 'react-hook-form';
|
|
18
18
|
import { VAT_ID_LENGTH } from '../../../../constants';
|
|
19
19
|
import { useAppSelector } from '../../../../hooks';
|
|
20
|
-
import { FieldType } from '../../../../@types';
|
|
21
20
|
import { isSA, removeAllCharsFromNumber } from '../../../../utils';
|
|
22
21
|
import { settingsSelector } from '../../../../app/settings';
|
|
23
22
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
24
23
|
import CheckIcon from '../../../shared/CheckIcon';
|
|
25
24
|
import { taxSelector } from '../../../app/tax/taxStore';
|
|
26
25
|
var VATId = function () {
|
|
27
|
-
var _a
|
|
26
|
+
var _a;
|
|
28
27
|
var t = useTranslation().t;
|
|
29
28
|
var control = useFormContext().control;
|
|
30
29
|
var vatControl = useController({ name: 'vatId', control: control });
|
|
@@ -32,13 +31,13 @@ var VATId = function () {
|
|
|
32
31
|
var isSACountry = React.useMemo(function () { return isSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
33
32
|
var data = useAppSelector(taxSelector).data;
|
|
34
33
|
var entity = (data.verify.responseBody || {}).entity;
|
|
35
|
-
var disabled =
|
|
34
|
+
var disabled = false;
|
|
36
35
|
var handleOnChange = function (vat) {
|
|
37
36
|
var value = removeAllCharsFromNumber(vat);
|
|
38
37
|
vatControl.field.onChange(value);
|
|
39
38
|
};
|
|
40
39
|
var vatValue = vatControl.field.value;
|
|
41
|
-
var vatError = (
|
|
40
|
+
var vatError = (_a = vatControl.fieldState.error) === null || _a === void 0 ? void 0 : _a.message;
|
|
42
41
|
var clearValue = function () {
|
|
43
42
|
vatControl.field.onChange('');
|
|
44
43
|
};
|