@tap-payments/auth-jsconnect 2.1.96-test → 2.1.97-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/app.d.ts +17 -0
- package/build/@types/app.js +9 -0
- package/build/features/app/business/businessStore.js +2 -2
- package/build/features/app/entity/entityStore.js +2 -2
- package/build/features/bank/screens/BankDetails/BankStatement.js +8 -2
- package/build/features/business/screens/BusinessType/LicenseCertificate.js +2 -1
- package/build/features/entity/screens/EntityName/LicenseCertificate.js +9 -3
- package/build/features/individual/screens/AdditionalIndividualInfo/CivilIDFile.js +8 -2
- package/build/features/individual/screens/AdditionalIndividualInfo/SignatureFile.js +8 -2
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.d.ts +3 -4
- package/build/features/shared/UploadMultipleFile/UploadMultipleFile.js +21 -2
- package/build/features/tax/screens/TaxDetails/TaxDocument.js +8 -2
- package/build/utils/array.d.ts +1 -0
- package/build/utils/array.js +8 -0
- package/build/utils/string.d.ts +1 -0
- package/build/utils/string.js +14 -0
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
|
@@ -324,4 +324,21 @@ export declare enum IndividualType {
|
|
|
324
324
|
CUSTOMER = "customer",
|
|
325
325
|
BUYER = "buyer"
|
|
326
326
|
}
|
|
327
|
+
export declare enum DocumentPurpose {
|
|
328
|
+
CR = "commercial_registration",
|
|
329
|
+
ARTICLE_ASSOCIATION = "article_of_association",
|
|
330
|
+
BANK_STATEMENT = "bank_statement",
|
|
331
|
+
IDENTITY_DOCUMENT = "identity_document",
|
|
332
|
+
CUSTOMER_SIGNATURE = "customer_signature",
|
|
333
|
+
TAX_DOCUMENT = "tax_document_user_upload"
|
|
334
|
+
}
|
|
335
|
+
export declare type FileDetails = {
|
|
336
|
+
created: string;
|
|
337
|
+
id: string;
|
|
338
|
+
object: string;
|
|
339
|
+
purpose: string;
|
|
340
|
+
size: string;
|
|
341
|
+
title: string;
|
|
342
|
+
type: string;
|
|
343
|
+
};
|
|
327
344
|
export {};
|
package/build/@types/app.js
CHANGED
|
@@ -59,3 +59,12 @@ export var IndividualType;
|
|
|
59
59
|
IndividualType["CUSTOMER"] = "customer";
|
|
60
60
|
IndividualType["BUYER"] = "buyer";
|
|
61
61
|
})(IndividualType || (IndividualType = {}));
|
|
62
|
+
export var DocumentPurpose;
|
|
63
|
+
(function (DocumentPurpose) {
|
|
64
|
+
DocumentPurpose["CR"] = "commercial_registration";
|
|
65
|
+
DocumentPurpose["ARTICLE_ASSOCIATION"] = "article_of_association";
|
|
66
|
+
DocumentPurpose["BANK_STATEMENT"] = "bank_statement";
|
|
67
|
+
DocumentPurpose["IDENTITY_DOCUMENT"] = "identity_document";
|
|
68
|
+
DocumentPurpose["CUSTOMER_SIGNATURE"] = "customer_signature";
|
|
69
|
+
DocumentPurpose["TAX_DOCUMENT"] = "tax_document_user_upload";
|
|
70
|
+
})(DocumentPurpose || (DocumentPurpose = {}));
|
|
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
57
57
|
var _a;
|
|
58
58
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
59
59
|
import API from '../../../api';
|
|
60
|
-
import { BusinessType, FlowsTypes } from '../../../@types';
|
|
60
|
+
import { BusinessType, FlowsTypes, DocumentPurpose } from '../../../@types';
|
|
61
61
|
import { BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
|
|
62
62
|
import { convertNumbers2English, getEighteenYearsAgo, hasKey, sleep, isKW, isSA, dateFormat } from '../../../utils';
|
|
63
63
|
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
@@ -528,7 +528,7 @@ export var uploadArticle = createAsyncThunk('businessUploadArticle', function (_
|
|
|
528
528
|
uploadPayload = {
|
|
529
529
|
file_link_create: true,
|
|
530
530
|
title: file === null || file === void 0 ? void 0 : file.name,
|
|
531
|
-
purpose:
|
|
531
|
+
purpose: DocumentPurpose.ARTICLE_ASSOCIATION,
|
|
532
532
|
type: type,
|
|
533
533
|
file: file
|
|
534
534
|
};
|
|
@@ -59,7 +59,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
59
59
|
var _a;
|
|
60
60
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
61
61
|
import API from '../../../api';
|
|
62
|
-
import { BusinessType, FieldType, FlowsTypes } from '../../../@types';
|
|
62
|
+
import { BusinessType, DocumentPurpose, FieldType, FlowsTypes } from '../../../@types';
|
|
63
63
|
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
64
64
|
import { ENTITY_STEP_NAMES } from '../../../constants';
|
|
65
65
|
import moment from 'moment';
|
|
@@ -331,7 +331,7 @@ export var uploadArticle = createAsyncThunk('entityUploadArticle', function (_a)
|
|
|
331
331
|
uploadPayload = {
|
|
332
332
|
file_link_create: true,
|
|
333
333
|
title: file === null || file === void 0 ? void 0 : file.name,
|
|
334
|
-
purpose:
|
|
334
|
+
purpose: DocumentPurpose.ARTICLE_ASSOCIATION,
|
|
335
335
|
type: type,
|
|
336
336
|
file: file
|
|
337
337
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { styled } from '@mui/material/styles';
|
|
3
4
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { useController, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
8
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
9
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
7
10
|
import { bankSelector, bankStatementUploadingStatus } from '../../../app/bank/bankStore';
|
|
8
11
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
9
12
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
@@ -13,18 +16,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
13
16
|
});
|
|
14
17
|
});
|
|
15
18
|
var BankStatement = function (_a) {
|
|
19
|
+
var _b;
|
|
16
20
|
var required = _a.required;
|
|
17
21
|
var t = useTranslation().t;
|
|
18
22
|
var control = useFormContext().control;
|
|
19
23
|
var bankStatementIdControl = useController({ name: 'bankStatementId', control: control });
|
|
20
|
-
var
|
|
24
|
+
var _c = useAppSelector(bankSelector), loading = _c.loading, data = _c.data;
|
|
21
25
|
var dispatch = useAppDispatch();
|
|
26
|
+
var document = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.bank_account) || {}).document;
|
|
22
27
|
var handleBankStatementChange = function (ids) {
|
|
23
28
|
bankStatementIdControl.field.onChange(ids);
|
|
24
29
|
};
|
|
25
30
|
var handleReset = function (ids) {
|
|
26
31
|
bankStatementIdControl.field.onChange(ids);
|
|
27
32
|
};
|
|
28
|
-
|
|
33
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(document ? [document] : [], DocumentPurpose.BANK_STATEMENT); }, [document]);
|
|
34
|
+
return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'bankStatementId', control: control, label: t('title_bank_statement'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleBankStatementChange, isSubmitting: loading, required: required, onDeleteFile: handleReset, purpose: DocumentPurpose.BANK_STATEMENT, defaultFiles: defaultFiles, maxLimit: 4, fileUploadingStatus: function (uploading) { return dispatch(bankStatementUploadingStatus(uploading)); } }) }));
|
|
29
35
|
};
|
|
30
36
|
export default BankStatement;
|
|
@@ -13,6 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
16
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
16
17
|
import { styled } from '@mui/material/styles';
|
|
17
18
|
import Collapse from '../../../../components/Collapse';
|
|
18
19
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
@@ -37,6 +38,6 @@ var LicenseCertificate = function (_a) {
|
|
|
37
38
|
var handleReset = function (ids) {
|
|
38
39
|
certificateIdControl.field.onChange(ids);
|
|
39
40
|
};
|
|
40
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'certificateId', control: control, label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose:
|
|
41
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'certificateId', control: control, label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, purpose: DocumentPurpose.CR, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
|
|
41
42
|
};
|
|
42
43
|
export default LicenseCertificate;
|
|
@@ -10,11 +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';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
|
-
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
16
16
|
import { styled } from '@mui/material/styles';
|
|
17
17
|
import Collapse from '../../../../components/Collapse';
|
|
18
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
19
|
+
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
20
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
18
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
22
|
import { entitySelector, uploadingStatus } from '../../../app/entity/entityStore';
|
|
20
23
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
@@ -25,18 +28,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
var LicenseCertificate = function (_a) {
|
|
31
|
+
var _b;
|
|
28
32
|
var show = _a.show;
|
|
29
33
|
var t = useTranslation().t;
|
|
30
34
|
var control = useFormContext().control;
|
|
31
35
|
var dispatch = useAppDispatch();
|
|
32
36
|
var certificateIdControl = useController({ name: 'certificateId', control: control });
|
|
33
|
-
var
|
|
37
|
+
var _c = useAppSelector(entitySelector), loading = _c.loading, data = _c.data;
|
|
38
|
+
var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).documents;
|
|
34
39
|
var handleLicenseCertificateChange = function (ids) {
|
|
35
40
|
certificateIdControl.field.onChange(ids);
|
|
36
41
|
};
|
|
37
42
|
var handleReset = function (ids) {
|
|
38
43
|
certificateIdControl.field.onChange(ids);
|
|
39
44
|
};
|
|
40
|
-
|
|
45
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.CR); }, [documents]);
|
|
46
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'certificateId', control: control, label: t('title_license_certificate'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_certificate'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_bank_statement'), onFileUploaded: handleLicenseCertificateChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, defaultFiles: defaultFiles, purpose: DocumentPurpose.CR, fileUploadingStatus: function (uploading) { return dispatch(uploadingStatus(uploading)); } }) }) })));
|
|
41
47
|
};
|
|
42
48
|
export default LicenseCertificate;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { ScreenContainer } from '../../../../features/shared/Containers';
|
|
3
4
|
import { styled } from '@mui/material/styles';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { useController, useFormContext } from 'react-hook-form';
|
|
6
7
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
8
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
9
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
7
10
|
import { civilIDUploadingStatus, individualSelector } from '../../../app/individual/individualStore';
|
|
8
11
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
9
12
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
@@ -13,17 +16,20 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
13
16
|
});
|
|
14
17
|
});
|
|
15
18
|
var CivilIDFile = function () {
|
|
19
|
+
var _a;
|
|
16
20
|
var t = useTranslation().t;
|
|
17
21
|
var dispatch = useAppDispatch();
|
|
18
22
|
var control = useFormContext().control;
|
|
19
23
|
var civilIDFileIdControl = useController({ name: 'civilID', control: control });
|
|
20
|
-
var
|
|
24
|
+
var _b = useAppSelector(individualSelector), loading = _b.loading, data = _b.data;
|
|
25
|
+
var documents = (((_a = data.verify.responseBody) === null || _a === void 0 ? void 0 : _a.user) || {}).documents;
|
|
21
26
|
var handleCivilIDChange = function (ids) {
|
|
22
27
|
civilIDFileIdControl.field.onChange(ids);
|
|
23
28
|
};
|
|
24
29
|
var handleReset = function (ids) {
|
|
25
30
|
civilIDFileIdControl.field.onChange(ids);
|
|
26
31
|
};
|
|
27
|
-
|
|
32
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.IDENTITY_DOCUMENT); }, [documents]);
|
|
33
|
+
return (_jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'civilID', control: control, label: t('title_civil_id'), title: t('drag_and_drop'), subTitle: t('subtitle_drop'), dragDescription: t('desc_drag_and_drop_civilID'), uploadingTitle: t('file_uploading_title'), successTitle: t('success_upload_civil_id'), onFileUploaded: handleCivilIDChange, isSubmitting: loading, onDeleteFile: handleReset, maxLimit: 4, defaultFiles: defaultFiles, purpose: DocumentPurpose.IDENTITY_DOCUMENT, fileUploadingStatus: function (uploading) { return dispatch(civilIDUploadingStatus(uploading)); } }) }));
|
|
28
34
|
};
|
|
29
35
|
export default CivilIDFile;
|
|
@@ -10,10 +10,13 @@ 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';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
16
|
import { styled } from '@mui/material/styles';
|
|
16
17
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
18
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
19
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
17
20
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
18
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
22
|
import { individualSelector, signatureFileUploadingStatus } from '../../../app/individual/individualStore';
|
|
@@ -25,11 +28,13 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
var SignatureFile = function (_a) {
|
|
31
|
+
var _b;
|
|
28
32
|
var show = _a.show;
|
|
29
33
|
var t = useTranslation().t;
|
|
30
34
|
var control = useFormContext().control;
|
|
31
35
|
var signatureFileIdControl = useController({ name: 'signatureFileId', control: control });
|
|
32
|
-
var
|
|
36
|
+
var _c = useAppSelector(individualSelector), loading = _c.loading, data = _c.data;
|
|
37
|
+
var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.user) || {}).documents;
|
|
33
38
|
var dispatch = useAppDispatch();
|
|
34
39
|
var handleSignatureChange = function (ids) {
|
|
35
40
|
signatureFileIdControl.field.onChange(ids);
|
|
@@ -37,6 +42,7 @@ var SignatureFile = function (_a) {
|
|
|
37
42
|
var handleReset = function (ids) {
|
|
38
43
|
signatureFileIdControl.field.onChange(ids);
|
|
39
44
|
};
|
|
40
|
-
|
|
45
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.CUSTOMER_SIGNATURE); }, [documents]);
|
|
46
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(FeatureStyled, { children: _jsx(UploadMultipleFile, { id: 'signatureFileId', control: control, 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, defaultFiles: defaultFiles, purpose: DocumentPurpose.CUSTOMER_SIGNATURE, fileUploadingStatus: function (uploading) { return dispatch(signatureFileUploadingStatus(uploading)); } }) }) })));
|
|
41
47
|
};
|
|
42
48
|
export default SignatureFile;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FileDetails } from '../../../@types';
|
|
3
3
|
import { Control, FieldValues } from 'react-hook-form';
|
|
4
4
|
export declare const InputContainerStyled: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material/styles").Theme> & {
|
|
5
5
|
children?: React.ReactNode;
|
|
@@ -26,8 +26,7 @@ interface UploadMultipleFileProps {
|
|
|
26
26
|
fileUploadingStatus?: (uploading: boolean) => void;
|
|
27
27
|
onDeleteFile: (fileIds: Array<string>) => void;
|
|
28
28
|
maxLimit?: number;
|
|
29
|
-
|
|
30
|
-
initialFileInfoArray?: Array<FileInfo>;
|
|
29
|
+
defaultFiles?: Array<FileDetails>;
|
|
31
30
|
}
|
|
32
|
-
declare const UploadMultipleFile: ({ id, label, control, required, title, subTitle, dragDescription, uploadingTitle, successTitle, isSubmitting, onFileUploaded, fileUploadingStatus, onDeleteFile, maxLimit, purpose, fileTitle }: UploadMultipleFileProps) => JSX.Element;
|
|
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
32
|
export default UploadMultipleFile;
|
|
@@ -30,6 +30,7 @@ import { ScreenContainer } from '../../shared/Containers';
|
|
|
30
30
|
import Mandatory from '../../shared/Mandatory';
|
|
31
31
|
import UploadFile, { FileStatus } from './UploadFile';
|
|
32
32
|
import { useController } from 'react-hook-form';
|
|
33
|
+
import { getFileType } from '../../../utils';
|
|
33
34
|
var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
34
35
|
var theme = _a.theme;
|
|
35
36
|
return ({
|
|
@@ -60,7 +61,7 @@ var UploadCountBox = styled(Box)(function (_a) {
|
|
|
60
61
|
});
|
|
61
62
|
});
|
|
62
63
|
var UploadMultipleFile = function (_a) {
|
|
63
|
-
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;
|
|
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;
|
|
64
65
|
var t = useTranslation().t;
|
|
65
66
|
var theme = useTheme();
|
|
66
67
|
var _b = React.useState(''), error = _b[0], setError = _b[1];
|
|
@@ -68,6 +69,23 @@ var UploadMultipleFile = function (_a) {
|
|
|
68
69
|
var fileInfoControl = useController({ name: "".concat(id, "FileInfo"), control: control });
|
|
69
70
|
var fileArray = fileControl.field.value || [];
|
|
70
71
|
var fileInfoArray = fileInfoControl.field.value || [];
|
|
72
|
+
React.useEffect(function () {
|
|
73
|
+
var files = defaultFiles || [];
|
|
74
|
+
if (fileArray.length === 0 && files.length > 0) {
|
|
75
|
+
files.forEach(function (file) {
|
|
76
|
+
fileArray.push({ name: file.title, size: file.size, type: getFileType(file.type) });
|
|
77
|
+
fileInfoArray.push({
|
|
78
|
+
fileId: file.id,
|
|
79
|
+
status: FileStatus.SUCCESS,
|
|
80
|
+
progress: 100,
|
|
81
|
+
error: '',
|
|
82
|
+
name: file.title || ''
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
fileControl.field.onChange(__spreadArray([], fileArray, true));
|
|
86
|
+
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
87
|
+
}
|
|
88
|
+
}, [defaultFiles]);
|
|
71
89
|
var uploadedFileCount = React.useMemo(function () { return (fileInfoArray || []).filter(function (file) { return file.fileId; }).length; }, [fileInfoArray]);
|
|
72
90
|
var handleFileChange = function (files) {
|
|
73
91
|
if (!isSubmitting) {
|
|
@@ -124,7 +142,8 @@ var UploadMultipleFile = function (_a) {
|
|
|
124
142
|
fileInfoArray[index] = file;
|
|
125
143
|
fileInfoControl.field.onChange(__spreadArray([], fileInfoArray, true));
|
|
126
144
|
var fileIds = fileInfoArray.filter(function (f) { return f.fileId; }).map(function (f) { return f.fileId; });
|
|
127
|
-
|
|
145
|
+
var filteredFromDefaultFiles = fileIds.filter(function (id) { return !(defaultFiles || []).some(function (file) { return file.id === id; }); });
|
|
146
|
+
onFileUploaded(filteredFromDefaultFiles);
|
|
128
147
|
fileUploadingStatus === null || fileUploadingStatus === void 0 ? void 0 : fileUploadingStatus(false);
|
|
129
148
|
}
|
|
130
149
|
};
|
|
@@ -10,11 +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';
|
|
13
14
|
import { useTranslation } from 'react-i18next';
|
|
14
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
15
16
|
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
17
|
+
import { DocumentPurpose } from '../../../../@types';
|
|
16
18
|
import { styled } from '@mui/material/styles';
|
|
17
19
|
import Collapse from '../../../../components/Collapse';
|
|
20
|
+
import { getRecentDocumentFiles } from '../../../../utils';
|
|
18
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
19
22
|
import { taxSelector, uploadingStatus } from '../../../app/tax/taxStore';
|
|
20
23
|
import UploadMultipleFile from '../../../shared/UploadMultipleFile';
|
|
@@ -25,18 +28,21 @@ var FeatureStyled = styled(ScreenContainer)(function (_a) {
|
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
var TaxDocument = function (_a) {
|
|
31
|
+
var _b;
|
|
28
32
|
var show = _a.show;
|
|
29
33
|
var t = useTranslation().t;
|
|
30
34
|
var control = useFormContext().control;
|
|
31
35
|
var dispatch = useAppDispatch();
|
|
32
36
|
var documentIdControl = useController({ name: 'documentId', control: control });
|
|
33
|
-
var
|
|
37
|
+
var _c = useAppSelector(taxSelector), loading = _c.loading, data = _c.data;
|
|
38
|
+
var documents = (((_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.entity) || {}).documents;
|
|
34
39
|
var handleTaxDocumentChange = function (ids) {
|
|
35
40
|
documentIdControl.field.onChange(ids);
|
|
36
41
|
};
|
|
37
42
|
var handleReset = function (ids) {
|
|
38
43
|
documentIdControl.field.onChange(ids);
|
|
39
44
|
};
|
|
40
|
-
|
|
45
|
+
var defaultFiles = React.useMemo(function () { return getRecentDocumentFiles(documents, DocumentPurpose.TAX_DOCUMENT); }, [documents]);
|
|
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)); } }) })) })));
|
|
41
47
|
};
|
|
42
48
|
export default TaxDocument;
|
package/build/utils/array.d.ts
CHANGED
|
@@ -62,3 +62,4 @@ export declare const fixBrandList: (items: Array<{
|
|
|
62
62
|
}[];
|
|
63
63
|
export declare const findFirstId: (items: Array<SaleChannel>) => string;
|
|
64
64
|
export declare const sortActivitiesByName: (items: Array<Activity>, path: string) => Activity[];
|
|
65
|
+
export declare const getRecentDocumentFiles: (documents: Array<any>, purpose: string) => any;
|
package/build/utils/array.js
CHANGED
|
@@ -142,3 +142,11 @@ export var sortActivitiesByName = function (items, path) {
|
|
|
142
142
|
return get(a, path).trim().toLowerCase().localeCompare(get(b, path).trim().toLowerCase().trim().toLowerCase());
|
|
143
143
|
});
|
|
144
144
|
};
|
|
145
|
+
export var getRecentDocumentFiles = function (documents, purpose) {
|
|
146
|
+
var _a;
|
|
147
|
+
if ((documents === null || documents === void 0 ? void 0 : documents.length) === 0)
|
|
148
|
+
return [];
|
|
149
|
+
return (((_a = (documents || [])
|
|
150
|
+
.filter(function (doc) { return (doc.file_details || []).find(function (file) { return file.purpose === purpose; }); })
|
|
151
|
+
.sort(function (a, b) { return b.created - a.created; })[0]) === null || _a === void 0 ? void 0 : _a.file_details) || []);
|
|
152
|
+
};
|
package/build/utils/string.d.ts
CHANGED
package/build/utils/string.js
CHANGED
|
@@ -278,3 +278,17 @@ export var getUserNameObject = function (name) {
|
|
|
278
278
|
var lastName = rest.join(' ') || '';
|
|
279
279
|
return { first: first, middle: middle || '', third: third || '', last: lastName };
|
|
280
280
|
};
|
|
281
|
+
export var getFileType = function (type) {
|
|
282
|
+
switch (type) {
|
|
283
|
+
case 'jpeg':
|
|
284
|
+
return 'image/jpeg';
|
|
285
|
+
case 'png':
|
|
286
|
+
return 'image/png';
|
|
287
|
+
case 'jpg':
|
|
288
|
+
return 'image/jpg';
|
|
289
|
+
case 'pdf':
|
|
290
|
+
return 'application/pdf';
|
|
291
|
+
default:
|
|
292
|
+
return '';
|
|
293
|
+
}
|
|
294
|
+
};
|