diff --git a/src/components/FormField/components/FileSelect/index.js b/src/components/FormField/components/FileSelect/index.js
index 089b625..7c0a151 100644
--- a/src/components/FormField/components/FileSelect/index.js
+++ b/src/components/FormField/components/FileSelect/index.js
@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { classNames } from 'primereact/utils';
import { __ } from '@wordpress/i18n';
-import { isEmpty, pathOr, pluck } from 'ramda';
+import { isEmpty, isNil, pathOr, pluck } from 'ramda';
// service
import FileUploadService from '../../../../service/file-upload-service';
@@ -27,7 +27,8 @@ const FileSelect = ({
sourceId = 0,
source = 'DOCUMENT',
documentCategories = [],
- saveFormCallback
+ saveFormCallback,
+ attachFilesCallback,
}) => {
//const [stateFieldData, setStateFieldData] = useState([]);
const stateFieldData = useRef([]);
@@ -52,6 +53,16 @@ const FileSelect = ({
setAddNewMode(false);
}, [selectedUnconfirmed]);
+ const attachSelectedFilesCallback = useCallback(() => {
+ const existingIds = pluck('id', stateFieldData.current);
+ const selectedToBeAdded = selectedUnconfirmed.filter(o => !existingIds.includes(o.id));
+ setSelectedUnconfirmed([]);
+
+ // eslint-disable-next-line array-callback-return
+ selectedToBeAdded.map(o => attachFilesCallback(o));
+ setAddNewMode(false);
+ }, [selectedUnconfirmed]);
+
const doGoBackToListOfFiles = () => {
setSelectedUnconfirmed([]);
setAddNewMode(false);
@@ -100,7 +111,8 @@ const FileSelect = ({
defaultFocus: 'reject',
acceptClassName: 'p-button-danger',
accept: () => removeAttached(id),
- reject: () => {}
+ reject: () => {
+ }
});
};
@@ -116,19 +128,19 @@ const FileSelect = ({
? o
: documentCategories.includes(o.category.id))
.reduce((acc, cur) => {
- const catName = pathOr('', ['category', 'categoryName'], cur);
- const catLabel = pathOr('', ['category', 'description'], cur);
+ const catName = pathOr('', ['category', 'categoryName'], cur);
+ const catLabel = pathOr('', ['category', 'description'], cur);
- if (!acc[catName]) {
- acc[catName] = {
- code: catName,
- label: catLabel,
- items: []
- };
- }
- acc[catName].items.push(cur)
- return acc;
- }, {});
+ if (!acc[catName]) {
+ acc[catName] = {
+ code: catName,
+ label: catLabel,
+ items: []
+ };
+ }
+ acc[catName].items.push(cur)
+ return acc;
+ }, {});
setOptionsTransformed(Object.values(optionsDefault));
}
@@ -137,13 +149,14 @@ const FileSelect = ({
useEffect(() => {
stateFieldData.current = defaultValue;
}, [defaultValue]);
- //console.log([...stateFieldData.current])
+
return (
<>
-
+ {!isNil(label)
+ ? : null}
{addNewMode
?
@@ -160,7 +173,7 @@ const FileSelect = ({
?
:
}
- const doCloseAmendment = () => {
- doUpdateAmendment(true);
- }
+ const doCloseAmendment = useCallback(() => {
+ if (data.status === 'AWAITING') {
+ const submitData = {
+ internalNote
+ }
+ storeSet('setAsyncRequest');
+ AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
+ } else {
+ doUpdateAmendment(true);
+ }
+ }, [data]);
const closeAmendmentCallback = (data) => {
if (data.status === 'SUCCESS') {
diff --git a/src/service/application-service.js b/src/service/application-service.js
index a6e1ea2..4b7c523 100644
--- a/src/service/application-service.js
+++ b/src/service/application-service.js
@@ -71,4 +71,8 @@ export default class ApplicationService {
static downloadRanking = (callId, callback, errCallback)=> {
NetworkService.getBlob(`${API_BASE_URL}/application/call/${callId}/ranking-csv`, callback, errCallback);
}
+
+ static setApplicationDocuments = (id, callback, errCallback, queryParams) => {
+ NetworkService.get(`${API_BASE_URL}/application/${id}/companyDocuments`, callback, errCallback, queryParams);
+ };
}
diff --git a/src/service/company-service.js b/src/service/company-service.js
index 1246a91..b6365ff 100644
--- a/src/service/company-service.js
+++ b/src/service/company-service.js
@@ -39,4 +39,8 @@ export default class CompanyService {
static deleteCompany = (id, callback, errCallback) => {
NetworkService.delete(`${API_BASE_URL}/company/user/${id}`, {}, callback, errCallback);
};
+
+ static getCompanyDocuments = (id, callback, errCallback, queryParams) => {
+ NetworkService.get(`${API_BASE_URL}/companyDocument/company/${id}`, callback, errCallback, queryParams);
+ };
}