- added download application pdf button for submitted applications;
- fixed adding files for call;
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
"@wordpress/react-i18n": "4.8.0",
|
"@wordpress/react-i18n": "4.8.0",
|
||||||
"@xyflow/react": "12.3.1",
|
"@xyflow/react": "12.3.1",
|
||||||
"codice-fiscale-js": "2.3.22",
|
"codice-fiscale-js": "2.3.22",
|
||||||
"deep-object-diff": "1.1.9",
|
"deep-object-diff": "^1.1.9",
|
||||||
"dompurify": "3.1.7",
|
"dompurify": "3.1.7",
|
||||||
"fast-deep-equal": "3.1.3",
|
"fast-deep-equal": "3.1.3",
|
||||||
"html-react-parser": "5.1.16",
|
"html-react-parser": "5.1.16",
|
||||||
|
|||||||
@@ -170,7 +170,7 @@
|
|||||||
|
|
||||||
.appPageSection__hero {
|
.appPageSection__hero {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 172px;
|
height: 250px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
|
|||||||
194
src/components/FileuploadApplicationSignedPdf/index.js
Normal file
194
src/components/FileuploadApplicationSignedPdf/index.js
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { head, isEmpty } from 'ramda';
|
||||||
|
|
||||||
|
import { FileUpload } from 'primereact/fileupload';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import ApplicationService from '../../service/application-service';
|
||||||
|
|
||||||
|
import { mimeTypes } from '../../configData';
|
||||||
|
|
||||||
|
const FileuploadApplicationSignedPdf = ({
|
||||||
|
fieldName,
|
||||||
|
setDataFn,
|
||||||
|
defaultValue = [],
|
||||||
|
accept = [],
|
||||||
|
maxSize = 100000000,
|
||||||
|
emptyText = __('Trascina qui il tuo file', 'gepafin'),
|
||||||
|
chooseLabel = __('Aggiungi documento', 'gepafin'),
|
||||||
|
uploadLabel = __('Salva documento', 'gepafin'),
|
||||||
|
cancelLabel = __('Cancella documento', 'gepafin'),
|
||||||
|
multiple = false,
|
||||||
|
applicationId = 0,
|
||||||
|
disabled = false
|
||||||
|
}) => {
|
||||||
|
const [stateFieldData, setStateFieldData] = useState([]);
|
||||||
|
const [acceptFormats, setAcceptFormats] = useState('');
|
||||||
|
const [formatsForInput, setFormatsForInput] = useState('');
|
||||||
|
const inputRef = useRef();
|
||||||
|
|
||||||
|
const customBase64Uploader = (event) => {
|
||||||
|
const formData = new FormData()
|
||||||
|
for (const file of event.files) {
|
||||||
|
formData.append('file', file)
|
||||||
|
}
|
||||||
|
ApplicationService.uploadApplicationSignedPdf(applicationId, formData, callback, errorCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
const callback = (data) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
setStateFieldData([data.data]);
|
||||||
|
inputRef.current.setFiles([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const errorCallback = (err) => {
|
||||||
|
console.log('err', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemTemplate = (file) => {
|
||||||
|
let fileName = file.fileName ? file.fileName : file.name;
|
||||||
|
return (
|
||||||
|
<div className="appForm__fileUploadItem">
|
||||||
|
<div>
|
||||||
|
<span className="appForm__fileUploadItemName">
|
||||||
|
{fileName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{file.id ? <Tag value={__('Caricato', 'gepafin')} severity="success"></Tag> : null}
|
||||||
|
{!file.id ? <Tag value={__('In attesa', 'gepafin')} severity="warning"></Tag> : null}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={disabled}
|
||||||
|
icon="pi pi-times"
|
||||||
|
severity="danger"
|
||||||
|
aria-label={__('Anulla', 'gepafin')}
|
||||||
|
onClick={() => onTemplateRemove(file)}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onTemplateRemove = (file) => {
|
||||||
|
if (file.id) {
|
||||||
|
ApplicationService.deleteApplicationSignedPdf(
|
||||||
|
applicationId,
|
||||||
|
(data) => dCallback(data, file.id),
|
||||||
|
dErrorCallback
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const files = inputRef.current.getFiles()
|
||||||
|
const newFiles = files.filter(o => o.lastModified !== file.lastModified && o.name !== file.name);
|
||||||
|
inputRef.current.setFiles(newFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dCallback = (data, id) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
setStateFieldData(prevState => {
|
||||||
|
const newFiles = prevState.filter(o => o.id !== id);
|
||||||
|
inputRef.current.setUploadedFiles(newFiles);
|
||||||
|
console.log('dCallback - newFiles', newFiles)
|
||||||
|
return newFiles;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dErrorCallback = (err) => {
|
||||||
|
console.log('err', err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBeforeDrop = (e) => {
|
||||||
|
return !isEmpty(e.dataTransfer.files) ? validateFileInputType(e.dataTransfer.files) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onBeforeSelect = (e) => {
|
||||||
|
const files = inputRef.current.getFiles();
|
||||||
|
const uploadedfiles = inputRef.current.getUploadedFiles();
|
||||||
|
|
||||||
|
if (!multiple && (uploadedfiles.length > 0 || files.length > 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.originalEvent.target.files) {
|
||||||
|
return !isEmpty(e.originalEvent.target.files)
|
||||||
|
? validateFileInputType(e.originalEvent.target.files)
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const validateFileInputType = (files) => {
|
||||||
|
const MIMEtype = new RegExp(acceptFormats);
|
||||||
|
|
||||||
|
return Array.prototype.every.call(files, function passesAcceptedFormat(file) {
|
||||||
|
const fileExtension = `.${file.name.split('.').pop().toLowerCase()}`;
|
||||||
|
const fileType = file.type;
|
||||||
|
return MIMEtype.test(fileType) || MIMEtype.test(fileExtension);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setStateFieldData(defaultValue);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.setUploadedFiles(defaultValue);
|
||||||
|
}
|
||||||
|
}, [defaultValue]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const properMime = accept
|
||||||
|
.map(v => {
|
||||||
|
const found = head(mimeTypes.filter(o => o.code.includes(v)));
|
||||||
|
let res = v;
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
res = found.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
|
setAcceptFormats(properMime.join(',').replace(/\*/g, '.\*').replace(/,/g, '|'));
|
||||||
|
setFormatsForInput(properMime.join(','))
|
||||||
|
}, [accept]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.setUploadedFiles(stateFieldData);
|
||||||
|
}
|
||||||
|
setDataFn(fieldName, stateFieldData, { shouldValidate: true });
|
||||||
|
}, [stateFieldData])
|
||||||
|
|
||||||
|
return (
|
||||||
|
applicationId && applicationId !== 0
|
||||||
|
? <FileUpload
|
||||||
|
ref={inputRef}
|
||||||
|
disabled={disabled}
|
||||||
|
id={fieldName}
|
||||||
|
name={fieldName}
|
||||||
|
url={'/document/uploadFile'}
|
||||||
|
multiple={multiple}
|
||||||
|
accept={formatsForInput}
|
||||||
|
maxFileSize={maxSize}
|
||||||
|
emptyTemplate={<p>{emptyText}</p>}
|
||||||
|
chooseLabel={chooseLabel}
|
||||||
|
cancelLabel={cancelLabel}
|
||||||
|
uploadLabel={uploadLabel}
|
||||||
|
itemTemplate={itemTemplate}
|
||||||
|
customUpload
|
||||||
|
onBeforeDrop={onBeforeDrop}
|
||||||
|
onBeforeSelect={onBeforeSelect}
|
||||||
|
uploadHandler={customBase64Uploader}/>
|
||||||
|
: null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FileuploadApplicationSignedPdf;
|
||||||
@@ -35,11 +35,11 @@ const Checkboxes = ({
|
|||||||
|
|
||||||
const properConfig = (config) => {
|
const properConfig = (config) => {
|
||||||
let newConfig = klona(config);
|
let newConfig = klona(config);
|
||||||
if (config.minLength) {
|
if (config.min) {
|
||||||
newConfig = wrap(newConfig).set(['validate', 'minChecks'], (v) => minChecks(v, config.minLength)).value();
|
newConfig = wrap(newConfig).set(['validate', 'minChecks'], (v) => minChecks(v, config.min)).value();
|
||||||
}
|
}
|
||||||
if (config.maxLength) {
|
if (config.max) {
|
||||||
newConfig = wrap(newConfig).set(['validate', 'maxChecks'], (v) => maxChecks(v, config.maxLength)).value();
|
newConfig = wrap(newConfig).set(['validate', 'maxChecks'], (v) => maxChecks(v, config.max)).value();
|
||||||
}
|
}
|
||||||
|
|
||||||
return newConfig;
|
return newConfig;
|
||||||
|
|||||||
@@ -60,9 +60,8 @@ const Fileupload = ({
|
|||||||
const callback = (data) => {
|
const callback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
setStateFieldData(data.data);
|
setStateFieldData(data.data);
|
||||||
const files = inputRef.current.getFiles();
|
const uploadedFiles = inputRef.current.getUploadedFiles();
|
||||||
inputRef.current.setUploadedFiles(files);
|
setDataFn(fieldName, [...uploadedFiles, ...data.data], { shouldValidate: true });
|
||||||
setDataFn(fieldName, data.data, { shouldValidate: true });
|
|
||||||
inputRef.current.setFiles([]);
|
inputRef.current.setFiles([]);
|
||||||
saveFormCallback();
|
saveFormCallback();
|
||||||
}
|
}
|
||||||
@@ -116,7 +115,6 @@ const Fileupload = ({
|
|||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
setStateFieldData(prevState => {
|
setStateFieldData(prevState => {
|
||||||
const newFiles = prevState.filter(o => o.id !== id);
|
const newFiles = prevState.filter(o => o.id !== id);
|
||||||
inputRef.current.setUploadedFiles(newFiles);
|
|
||||||
setDataFn(fieldName, newFiles, { shouldValidate: true });
|
setDataFn(fieldName, newFiles, { shouldValidate: true });
|
||||||
saveFormCallback();
|
saveFormCallback();
|
||||||
return newFiles;
|
return newFiles;
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ const FileuploadAsync = ({
|
|||||||
const callback = (data) => {
|
const callback = (data) => {
|
||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
setStateFieldData(data.data);
|
setStateFieldData(data.data);
|
||||||
const files = inputRef.current.getFiles();
|
const uploadedFiles = inputRef.current.getUploadedFiles();
|
||||||
inputRef.current.setUploadedFiles(files);
|
setDataFn(fieldName, [...uploadedFiles, ...data.data], { shouldValidate: true });
|
||||||
inputRef.current.setFiles([]);
|
inputRef.current.setFiles([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ const FileuploadAsync = ({
|
|||||||
if (data.status === 'SUCCESS') {
|
if (data.status === 'SUCCESS') {
|
||||||
setStateFieldData(prevState => {
|
setStateFieldData(prevState => {
|
||||||
const newFiles = prevState.filter(o => o.id !== id);
|
const newFiles = prevState.filter(o => o.id !== id);
|
||||||
inputRef.current.setUploadedFiles(newFiles);
|
setDataFn(fieldName, newFiles, { shouldValidate: true });
|
||||||
return newFiles;
|
return newFiles;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -123,6 +123,13 @@ const FileuploadAsync = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onBeforeSelect = (e) => {
|
const onBeforeSelect = (e) => {
|
||||||
|
const files = inputRef.current.getFiles();
|
||||||
|
const uploadedfiles = inputRef.current.getUploadedFiles();
|
||||||
|
|
||||||
|
if (!multiple && (uploadedfiles.length > 0 || files.length > 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.originalEvent.target.files) {
|
if (e.originalEvent.target.files) {
|
||||||
return !isEmpty(e.originalEvent.target.files)
|
return !isEmpty(e.originalEvent.target.files)
|
||||||
? validateFileInputType(e.originalEvent.target.files)
|
? validateFileInputType(e.originalEvent.target.files)
|
||||||
@@ -147,11 +154,9 @@ const FileuploadAsync = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
const properValue = multiple
|
inputRef.current.setUploadedFiles(defaultValue);
|
||||||
? defaultValue
|
|
||||||
: !isEmpty(defaultValue) ? [defaultValue] : [];
|
|
||||||
inputRef.current.setUploadedFiles(properValue);
|
|
||||||
}
|
}
|
||||||
|
setStateFieldData(defaultValue);
|
||||||
}, [defaultValue]);
|
}, [defaultValue]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -171,13 +176,6 @@ const FileuploadAsync = ({
|
|||||||
setFormatsForInput(properMime.join(','))
|
setFormatsForInput(properMime.join(','))
|
||||||
}, [accept]);
|
}, [accept]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (inputRef.current) {
|
|
||||||
inputRef.current.setUploadedFiles(stateFieldData);
|
|
||||||
}
|
|
||||||
setDataFn(fieldName, [...stateFieldData], { shouldValidate: true });
|
|
||||||
}, [stateFieldData])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
sourceId && sourceId !== 0
|
sourceId && sourceId !== 0
|
||||||
? <>
|
? <>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import equal from 'fast-deep-equal';
|
import equal from 'fast-deep-equal';
|
||||||
|
import { diff } from 'deep-object-diff';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeGet } from '../../store';
|
import { storeGet } from '../../store';
|
||||||
@@ -10,7 +11,8 @@ const UnsavedChangesDetector = ({ getValuesFn }) => {
|
|||||||
const formData = getValuesFn();
|
const formData = getValuesFn();
|
||||||
const initial = storeGet.main.formInitialData();
|
const initial = storeGet.main.formInitialData();
|
||||||
const isEqual = equal(initial, formData);
|
const isEqual = equal(initial, formData);
|
||||||
|
// TODO
|
||||||
|
//console.log('isEqual', isEqual, initial, formData, diff(initial, formData))
|
||||||
if (!isEqual) {
|
if (!isEqual) {
|
||||||
event.returnValue = __('You have unsaved changes. If you proceed, they will be lost.', 'gepafin');
|
event.returnValue = __('You have unsaved changes. If you proceed, they will be lost.', 'gepafin');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,15 +33,12 @@ const AddCompany = () => {
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
setValue,
|
setValue,
|
||||||
getValues,
|
|
||||||
watch
|
watch
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: {},
|
defaultValues: {},
|
||||||
mode: 'onChange'
|
mode: 'onChange'
|
||||||
});
|
});
|
||||||
const values = getValues();
|
const isPiva = watch('vatNumber');
|
||||||
const emptyValues = Object.values(values).filter(v => isEmpty(v) || isNil(v)).length;
|
|
||||||
const isPiva = watch('vatNumber')
|
|
||||||
|
|
||||||
const setEmptyValues = () => {
|
const setEmptyValues = () => {
|
||||||
const formData = {
|
const formData = {
|
||||||
@@ -75,7 +72,6 @@ const AddCompany = () => {
|
|||||||
} else {
|
} else {
|
||||||
newCompanies = [...companies, company];
|
newCompanies = [...companies, company];
|
||||||
storeSet.main.chosenCompanyId(company.id);
|
storeSet.main.chosenCompanyId(company.id);
|
||||||
console.log('set company 1', company.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storeSet.main.companies(newCompanies);
|
storeSet.main.companies(newCompanies);
|
||||||
@@ -210,7 +206,7 @@ const AddCompany = () => {
|
|||||||
config={{
|
config={{
|
||||||
required: __('È obbligatorio', 'gepafin'),
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
validate: {
|
validate: {
|
||||||
isEmailPEC
|
isEmailPEC: isEmailPEC
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -225,7 +221,7 @@ const AddCompany = () => {
|
|||||||
config={{
|
config={{
|
||||||
required: __('È obbligatorio', 'gepafin'),
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
validate: {
|
validate: {
|
||||||
isEmail
|
isEmail: isEmail
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -291,7 +287,7 @@ const AddCompany = () => {
|
|||||||
config={{
|
config={{
|
||||||
required: __('È obbligatorio', 'gepafin'),
|
required: __('È obbligatorio', 'gepafin'),
|
||||||
validate: {
|
validate: {
|
||||||
isEmail
|
isEmail: isEmail
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -321,7 +317,7 @@ const AddCompany = () => {
|
|||||||
<div className="appPageSection__actions">
|
<div className="appPageSection__actions">
|
||||||
<Button
|
<Button
|
||||||
form="companyForm"
|
form="companyForm"
|
||||||
disabled={isAsyncRequest || emptyValues}
|
disabled={isAsyncRequest}
|
||||||
label={__('Salva modifiche', 'gepafin')}
|
label={__('Salva modifiche', 'gepafin')}
|
||||||
icon="pi pi-check" iconPos="right"/>
|
icon="pi pi-check" iconPos="right"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import { Messages } from 'primereact/messages';
|
|||||||
import ApplicationSteps from './ApplicationSteps';
|
import ApplicationSteps from './ApplicationSteps';
|
||||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
//import FileuploadApplicationSignedPdf from '../../components/FileuploadApplicationSignedPdf';
|
||||||
|
|
||||||
const BandoApplication = () => {
|
const BandoApplication = () => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
@@ -46,6 +47,8 @@ const BandoApplication = () => {
|
|||||||
const [visibleConfirmation, setVisibleConfirmation] = useState(false);
|
const [visibleConfirmation, setVisibleConfirmation] = useState(false);
|
||||||
const [applicationStatus, setApplicationStatus] = useState('');
|
const [applicationStatus, setApplicationStatus] = useState('');
|
||||||
const [activeStep, setActiveStep] = useState(1);
|
const [activeStep, setActiveStep] = useState(1);
|
||||||
|
// TODO
|
||||||
|
//const [signedPdfFile, setSignedPdfFile] = useState([]);
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
const formMsgs = useRef(null);
|
const formMsgs = useRef(null);
|
||||||
@@ -337,6 +340,30 @@ const BandoApplication = () => {
|
|||||||
iconPos="right"/>
|
iconPos="right"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
const onDownloadApplicationPdf = () => {
|
||||||
|
const applId = getApplicationId();
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
|
||||||
|
ApplicationService.downloadApplicationPdf(applId, {}, getPdfCallback, errPdfCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getPdfCallback = (data) => {
|
||||||
|
const applId = getApplicationId();
|
||||||
|
const pdfFile = new Blob([data], { type: 'application/octet-stream' })
|
||||||
|
const url = window.URL.createObjectURL(pdfFile);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `application-${applId}.pdf`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errPdfCallback = (data) => {
|
||||||
|
set404FromErrorResponse(data);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (formInitialData) {
|
if (formInitialData) {
|
||||||
reset();
|
reset();
|
||||||
@@ -366,7 +393,9 @@ const BandoApplication = () => {
|
|||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
<ApplicationSteps totalSteps={totalSteps} activeStepIndex={activeStepIndex}/>
|
{'SUBMIT' !== applicationStatus
|
||||||
|
? <ApplicationSteps totalSteps={totalSteps} activeStepIndex={activeStepIndex}/>
|
||||||
|
: null}
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
@@ -375,7 +404,10 @@ const BandoApplication = () => {
|
|||||||
<Dialog header={__('Conferma', 'gepafin')}
|
<Dialog header={__('Conferma', 'gepafin')}
|
||||||
visible={visibleConfirmation}
|
visible={visibleConfirmation}
|
||||||
style={{ width: '50vw' }}
|
style={{ width: '50vw' }}
|
||||||
onHide={() => {if (!visibleConfirmation) return; setVisibleConfirmation(false); }}>
|
onHide={() => {
|
||||||
|
if (!visibleConfirmation) return;
|
||||||
|
setVisibleConfirmation(false);
|
||||||
|
}}>
|
||||||
<p>
|
<p>
|
||||||
{__('Grazie, la tua domanda è stata inviata correttamente. Entro 24 ore riceverai una pec con data, ora e numero di protocollo.', 'gepafin')}
|
{__('Grazie, la tua domanda è stata inviata correttamente. Entro 24 ore riceverai una pec con data, ora e numero di protocollo.', 'gepafin')}
|
||||||
</p>
|
</p>
|
||||||
@@ -384,118 +416,12 @@ const BandoApplication = () => {
|
|||||||
<div className="appPage__content">
|
<div className="appPage__content">
|
||||||
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
||||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="appPageSection">
|
{'SUBMIT' !== applicationStatus
|
||||||
|
? <div className="appPageSection">
|
||||||
{actionBtns}
|
{actionBtns}
|
||||||
</div>
|
</div> : null}
|
||||||
|
|
||||||
{formData.map(o => {
|
{'SUBMIT' !== applicationStatus
|
||||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
|
||||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
|
||||||
const placeholder = head(o.settings.filter(o => o.name === 'placeholder'));
|
|
||||||
const options = head(o.settings.filter(o => o.name === 'options'));
|
|
||||||
const tableColumns = head(o.settings.filter(o => o.name === 'table_columns'));
|
|
||||||
const step = head(o.settings.filter(o => o.name === 'step'));
|
|
||||||
const mime = head(o.settings.filter(o => o.name === 'mime'));
|
|
||||||
let mimeValue = '';
|
|
||||||
|
|
||||||
if (mime) {
|
|
||||||
mimeValue = mime.value.map(o => o.code ? o.code : o.ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
const validations = Object.keys(o.validators).reduce((acc, cur) => {
|
|
||||||
if (o.validators[cur]) {
|
|
||||||
if (['min', 'max', 'minLength', 'maxLength', 'maxSize'].includes(cur)) {
|
|
||||||
acc[cur] = parseInt(o.validators[cur]);
|
|
||||||
} else if ('pattern' === cur) {
|
|
||||||
acc[cur] = new RegExp(o.validators[cur]);
|
|
||||||
} else if ('isRequired' === cur) {
|
|
||||||
//acc[cur] = o.validators[cur];
|
|
||||||
acc['required'] = true;
|
|
||||||
} else if ('custom' === cur && validationFns[o.validators[cur]]) {
|
|
||||||
if (!acc.validate) {
|
|
||||||
acc.validate = {};
|
|
||||||
}
|
|
||||||
acc.validate[o.validators[cur]] = validationFns[o.validators[cur]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
//console.log('validations', validations, o.name)
|
|
||||||
|
|
||||||
return ['paragraph'].includes(o.name) && text
|
|
||||||
? <div className="appForm__content" key={o.id}>{renderHtmlContent(text.value)}</div>
|
|
||||||
: <FormField
|
|
||||||
key={o.id}
|
|
||||||
type={o.name}
|
|
||||||
fieldName={o.id}
|
|
||||||
label={label ? label.value : ''}
|
|
||||||
placeholder={placeholder ? placeholder.value : ''}
|
|
||||||
control={control}
|
|
||||||
register={register}
|
|
||||||
errors={errors}
|
|
||||||
defaultValue={values[o.id] ? values[o.id] : ''}
|
|
||||||
maxFractionDigits={step ? step.value : 0}
|
|
||||||
accept={mimeValue}
|
|
||||||
config={validations}
|
|
||||||
options={options ? options.value : []}
|
|
||||||
setDataFn={setValue}
|
|
||||||
saveFormCallback={saveDraft}
|
|
||||||
sourceId={getApplicationId()}
|
|
||||||
useGrouping={false}
|
|
||||||
tableColumns={tableColumns ? tableColumns.value : {}}
|
|
||||||
/>
|
|
||||||
})}
|
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
|
||||||
|
|
||||||
<div className="appPageSection__hr">
|
|
||||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="appPageSection">
|
|
||||||
{actionBtns}
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/*{!isAsyncRequest
|
|
||||||
? <div className="appPage__content">
|
|
||||||
<form className="appForm" ref={formRef} onSubmit={handleSubmit(onSubmit)}>
|
|
||||||
<div className="appPageSection">
|
|
||||||
<div className="appPageSection__actions">
|
|
||||||
{activeStep > 1 && activeStep <= totalSteps
|
|
||||||
? <Button
|
|
||||||
type="button"
|
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
onClick={goBackward}
|
|
||||||
label={__('Vai indietro', 'gepafin')}
|
|
||||||
icon="pi pi-arrow-left"
|
|
||||||
iconPos="left"/> : null}
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
disabled={isAsyncRequest || 'SUBMIT' === applicationStatus}
|
|
||||||
onClick={saveDraft}
|
|
||||||
outlined
|
|
||||||
label={__('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/>
|
|
||||||
{activeStep < totalSteps
|
|
||||||
//&& activeStep === completedSteps
|
|
||||||
? <Button
|
|
||||||
type="button"
|
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
onClick={goForward}
|
|
||||||
label={__('Vai avanti', 'gepafin')}
|
|
||||||
icon="pi pi-arrow-right"
|
|
||||||
iconPos="right"/> : null}
|
|
||||||
<Button
|
|
||||||
disabled={completedSteps === 0 || completedSteps !== totalSteps || 'SUBMIT' === applicationStatus}
|
|
||||||
label={__('Invia', 'gepafin')}
|
|
||||||
icon="pi pi-check"
|
|
||||||
iconPos="right"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{formInitialData
|
|
||||||
? formData.map(o => {
|
? formData.map(o => {
|
||||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||||
@@ -553,58 +479,60 @@ const BandoApplication = () => {
|
|||||||
useGrouping={false}
|
useGrouping={false}
|
||||||
tableColumns={tableColumns ? tableColumns.value : {}}
|
tableColumns={tableColumns ? tableColumns.value : {}}
|
||||||
/>
|
/>
|
||||||
}) : null}
|
})
|
||||||
|
: null}
|
||||||
|
|
||||||
|
{'SUBMIT' === applicationStatus
|
||||||
|
? <div className="appPageSection">
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label>
|
||||||
|
{__('Scarica documento della domanda nel formato PDF', 'gepafin')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={'SUBMIT' !== applicationStatus}
|
||||||
|
onClick={onDownloadApplicationPdf}
|
||||||
|
label={__('Scarica PDF', 'gepafin')}
|
||||||
|
icon="pi pi-download"
|
||||||
|
iconPos="right"/>
|
||||||
|
</div> : null}
|
||||||
|
|
||||||
|
{/*{'SUBMIT' === applicationStatus
|
||||||
|
? <div className="appPageSection">
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label htmlFor="signedPdfFile">
|
||||||
|
{__('Carica documento della domanda firmato', 'gepafin')}
|
||||||
|
<span className="appForm__field--required">*</span>
|
||||||
|
(.p7m)
|
||||||
|
</label>
|
||||||
|
<FileuploadApplicationSignedPdf
|
||||||
|
setDataFn={setSignedPdfFile}
|
||||||
|
fieldName="signedPdfFile"
|
||||||
|
defaultValue={signedPdfFile}
|
||||||
|
accept={['.p7m,application/pkcs7-mime,application/x-pkcs7-mime']}
|
||||||
|
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
||||||
|
multiple={false}
|
||||||
|
doctype="document"
|
||||||
|
applicationId={id}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
: null}*/}
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
<div className="appPageSection__hr">
|
{'SUBMIT' !== applicationStatus
|
||||||
|
? <div className="appPageSection__hr">
|
||||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||||
</div>
|
</div> : null}
|
||||||
|
|
||||||
<div className="appPageSection">
|
{'SUBMIT' !== applicationStatus
|
||||||
<div className="appPageSection__actions">
|
? <div className="appPageSection">
|
||||||
{activeStep > 1 && activeStep <= totalSteps
|
{actionBtns}
|
||||||
? <Button
|
</div> : null}
|
||||||
type="button"
|
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
onClick={goBackward}
|
|
||||||
label={__('Vai indietro', 'gepafin')}
|
|
||||||
icon="pi pi-arrow-left"
|
|
||||||
iconPos="left"/> : null}
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
disabled={isAsyncRequest || 'SUBMIT' === applicationStatus}
|
|
||||||
onClick={saveDraft}
|
|
||||||
outlined
|
|
||||||
label={__('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/>
|
|
||||||
{activeStep < totalSteps
|
|
||||||
//&& activeStep === completedSteps
|
|
||||||
? <Button
|
|
||||||
type="button"
|
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
onClick={goForward}
|
|
||||||
label={__('Vai avanti', 'gepafin')}
|
|
||||||
icon="pi pi-arrow-right"
|
|
||||||
iconPos="right"/> : null}
|
|
||||||
<Button
|
|
||||||
disabled={completedSteps === 0 || completedSteps !== totalSteps || 'SUBMIT' === applicationStatus}
|
|
||||||
label={__('Invia', 'gepafin')}
|
|
||||||
icon="pi pi-check"
|
|
||||||
iconPos="right"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
: <>
|
|
||||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
|
||||||
<Skeleton width="100%" height="2rem" className="mb-8"></Skeleton>
|
|
||||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
|
||||||
<Skeleton width="100%" height="4rem" className="mb-8"></Skeleton>
|
|
||||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
|
||||||
<Skeleton width="100%" height="2rem" className="mb-8"></Skeleton>
|
|
||||||
<Skeleton width="20%" height="1rem" className="mb-2"></Skeleton>
|
|
||||||
<Skeleton width="100%" height="4rem"></Skeleton>
|
|
||||||
</>}*/}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
|
|||||||
});
|
});
|
||||||
const newFormData = {...formInitialData, ...data.data};
|
const newFormData = {...formInitialData, ...data.data};
|
||||||
setFormInitialData(newFormData);
|
setFormInitialData(newFormData);
|
||||||
|
storeSet.main.formInitialData(newFormData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,6 +265,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors, st
|
|||||||
register={register}
|
register={register}
|
||||||
sourceId={values.id}
|
sourceId={values.id}
|
||||||
source="call"
|
source="call"
|
||||||
|
multiple={false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormFieldRepeater
|
<FormFieldRepeater
|
||||||
|
|||||||
@@ -87,9 +87,9 @@ const BandoViewBeneficiario = () => {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveToFavourites = () => {
|
/*const saveToFavourites = () => {
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const submitNewQuestion = () => {
|
const submitNewQuestion = () => {
|
||||||
if (newQuestion && chosenCompanyId && 0 !== chosenCompanyId) {
|
if (newQuestion && chosenCompanyId && 0 !== chosenCompanyId) {
|
||||||
|
|||||||
@@ -151,11 +151,13 @@ const MyLatestSubmissionsTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actionsBodyTemplate = (rowData) => {
|
const actionsBodyTemplate = (rowData) => {
|
||||||
return 'DRAFT' === rowData.status
|
return <Link to={`/imieibandi/${rowData.id}`}>
|
||||||
? <Link to={`/imieibandi/${rowData.id}`}>
|
{'DRAFT' === rowData.status
|
||||||
<Button severity="info" label={__('Modifica', 'gepafin')} icon="pi pi-pencil" size="small"
|
? <Button severity="info" label={__('Modifica', 'gepafin')} icon="pi pi-pencil" size="small"
|
||||||
iconPos="right"/>
|
iconPos="right"/>
|
||||||
</Link> : null
|
: <Button severity="info" label={__('View', 'gepafin')} icon="pi pi-eye" size="small"
|
||||||
|
iconPos="right"/>}
|
||||||
|
</Link>
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = renderHeader();
|
const header = renderHeader();
|
||||||
|
|||||||
@@ -27,4 +27,20 @@ export default class ApplicationService {
|
|||||||
static updateStatusApplication = (id, body, callback, errCallback, queryParams) => {
|
static updateStatusApplication = (id, body, callback, errCallback, queryParams) => {
|
||||||
NetworkService.put(`${API_BASE_URL}/application/${id}/status`, body, callback, errCallback, queryParams);
|
NetworkService.put(`${API_BASE_URL}/application/${id}/status`, body, callback, errCallback, queryParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static downloadApplicationPdf = (id, body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.postBlob(`${API_BASE_URL}/application/${id}/download-pdf`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
static getApplicationSignedPdf = (id, callback, errCallback) => {
|
||||||
|
NetworkService.get(`${API_BASE_URL}/application/${id}/signedDocument`, callback, errCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
static uploadApplicationSignedPdf = (id, body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.postMultiPart(`${API_BASE_URL}/application/${id}/signedDocument/upload`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
static deleteApplicationSignedPdf = (id, callback, errCallback) => {
|
||||||
|
NetworkService.delete(`${API_BASE_URL}/application/${id}/signedDocument`, {}, callback, errCallback);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user