- added newer flow for appl submissions;
- re enabled appl submissions;
This commit is contained in:
@@ -2,6 +2,9 @@ import { __ } from '@wordpress/i18n';
|
|||||||
|
|
||||||
const getBandoLabel = (status) => {
|
const getBandoLabel = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 'ACTIVE':
|
||||||
|
return __('Attivo', 'gepafin');
|
||||||
|
|
||||||
case 'SUBMIT':
|
case 'SUBMIT':
|
||||||
return __('Inviato', 'gepafin');
|
return __('Inviato', 'gepafin');
|
||||||
|
|
||||||
@@ -11,9 +14,27 @@ const getBandoLabel = (status) => {
|
|||||||
case 'READY_TO_PUBLISH':
|
case 'READY_TO_PUBLISH':
|
||||||
return __('Pronto', 'gepafin');
|
return __('Pronto', 'gepafin');
|
||||||
|
|
||||||
|
case 'READY':
|
||||||
|
return __('Pronto', 'gepafin');
|
||||||
|
|
||||||
case 'DRAFT':
|
case 'DRAFT':
|
||||||
return __('Bozza', 'gepafin');
|
return __('Bozza', 'gepafin');
|
||||||
|
|
||||||
|
case 'AWAITING':
|
||||||
|
return __('In attesa', 'gepafin');
|
||||||
|
|
||||||
|
case 'AWAIT':
|
||||||
|
return __('In attesa', 'gepafin');
|
||||||
|
|
||||||
|
case 'OPEN':
|
||||||
|
return __('Aperto', 'gepafin');
|
||||||
|
|
||||||
|
case 'ASSIGNED':
|
||||||
|
return __('Assegnato', 'gepafin');
|
||||||
|
|
||||||
|
case 'EVALUATION':
|
||||||
|
return __('Valutazione', 'gepafin');
|
||||||
|
|
||||||
case 'EXPIRED':
|
case 'EXPIRED':
|
||||||
return __('Scaduto', 'gepafin');
|
return __('Scaduto', 'gepafin');
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { __ } from '@wordpress/i18n';
|
|
||||||
|
|
||||||
const getBandoSeverity = (status) => {
|
const getBandoSeverity = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 'ACTIVE':
|
||||||
|
return 'success';
|
||||||
|
|
||||||
case 'SUBMIT':
|
case 'SUBMIT':
|
||||||
return 'success';
|
return 'success';
|
||||||
|
|
||||||
@@ -11,9 +12,27 @@ const getBandoSeverity = (status) => {
|
|||||||
case 'READY_TO_PUBLISH':
|
case 'READY_TO_PUBLISH':
|
||||||
return 'info';
|
return 'info';
|
||||||
|
|
||||||
|
case 'READY':
|
||||||
|
return 'info';
|
||||||
|
|
||||||
case 'DRAFT':
|
case 'DRAFT':
|
||||||
return 'warning';
|
return 'warning';
|
||||||
|
|
||||||
|
case 'AWAITING':
|
||||||
|
return 'warning';
|
||||||
|
|
||||||
|
case 'AWAIT':
|
||||||
|
return 'warning';
|
||||||
|
|
||||||
|
case 'OPEN':
|
||||||
|
return 'warning';
|
||||||
|
|
||||||
|
case 'ASSIGNED':
|
||||||
|
return 'warning';
|
||||||
|
|
||||||
|
case 'EVALUATION':
|
||||||
|
return 'info';
|
||||||
|
|
||||||
case 'EXPIRED':
|
case 'EXPIRED':
|
||||||
return 'closed';
|
return 'closed';
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||||
import { __, sprintf } from '@wordpress/i18n';
|
import { __, sprintf } from '@wordpress/i18n';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { head, is, pluck, isEmpty } from 'ramda';
|
import { head, is, pluck, isEmpty, pathOr } from 'ramda';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { TZDate } from '@date-fns/tz';
|
import { TZDate } from '@date-fns/tz';
|
||||||
import "quill/dist/quill.core.css";
|
import "quill/dist/quill.core.css";
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../store';
|
import { storeSet, storeGet, useStore } from '../../store';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import ApplicationService from '../../service/application-service';
|
import ApplicationService from '../../service/application-service';
|
||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
} from '../../helpers/validators';
|
} from '../../helpers/validators';
|
||||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||||
|
import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { Skeleton } from 'primereact/skeleton';
|
import { Skeleton } from 'primereact/skeleton';
|
||||||
@@ -36,7 +37,7 @@ 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';
|
import FileuploadApplicationSignedPdf from '../../components/FileuploadApplicationSignedPdf';
|
||||||
import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
|
||||||
import { defaultMaxFileSize } from '../../configData';
|
import { defaultMaxFileSize } from '../../configData';
|
||||||
|
|
||||||
const BandoApplication = () => {
|
const BandoApplication = () => {
|
||||||
@@ -47,7 +48,6 @@ const BandoApplication = () => {
|
|||||||
const [bandoTitle, setBandoTitle] = useState('');
|
const [bandoTitle, setBandoTitle] = useState('');
|
||||||
const [formId, setFormId] = useState('');
|
const [formId, setFormId] = useState('');
|
||||||
const [totalSteps, setTotalSteps] = useState(0);
|
const [totalSteps, setTotalSteps] = useState(0);
|
||||||
//const [completedSteps, setCompletedSteps] = useState(0);
|
|
||||||
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);
|
||||||
@@ -86,6 +86,14 @@ const BandoApplication = () => {
|
|||||||
const activeStepIndex = activeStep - 1;
|
const activeStepIndex = activeStep - 1;
|
||||||
const values = getValues();
|
const values = getValues();
|
||||||
|
|
||||||
|
const onValidate = () => {
|
||||||
|
const applId = getApplicationId();
|
||||||
|
storeSet.main.setAsyncRequest();
|
||||||
|
formMsgs.current.clear();
|
||||||
|
|
||||||
|
ApplicationService.validateApplication(applId, {}, validateApplicationCallback, errValidateApplicationCallback);
|
||||||
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
const applId = getApplicationId();
|
const applId = getApplicationId();
|
||||||
storeSet.main.setAsyncRequest();
|
storeSet.main.setAsyncRequest();
|
||||||
@@ -150,6 +158,26 @@ const BandoApplication = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const validateApplicationCallback = (data) => {
|
||||||
|
if (data.status === 'SUCCESS') {
|
||||||
|
if (data.data.status) {
|
||||||
|
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errValidateApplicationCallback = (data) => {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'error',
|
||||||
|
summary: '',
|
||||||
|
detail: data.message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
storeSet.main.unsetAsyncRequest();
|
||||||
|
}
|
||||||
|
|
||||||
const saveDraft = (saveAndMove = '') => {
|
const saveDraft = (saveAndMove = '') => {
|
||||||
trigger();
|
trigger();
|
||||||
|
|
||||||
@@ -268,18 +296,60 @@ const BandoApplication = () => {
|
|||||||
setApplicationStatus(data.data.applicationStatus)
|
setApplicationStatus(data.data.applicationStatus)
|
||||||
setActiveStep(data.data.currentStep);
|
setActiveStep(data.data.currentStep);
|
||||||
|
|
||||||
|
const chosenCompanyId = storeGet.main.chosenCompanyId();
|
||||||
|
const companies = storeGet.main.companies();
|
||||||
|
const company = head(companies.filter(o => o.id === chosenCompanyId));
|
||||||
|
let formDataInitial = {};
|
||||||
|
let dynamicData = {
|
||||||
|
company: {},
|
||||||
|
user: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (company) {
|
||||||
|
dynamicData = Object.keys(company).reduce((acc, cur) => {
|
||||||
|
if ([
|
||||||
|
'companyName', 'vatNumber', 'codiceFiscale', 'address', 'phoneNumber',
|
||||||
|
'city', 'province', 'cap', 'country', 'pec', 'email', 'contactName', 'contactEmail'
|
||||||
|
].includes(cur)) {
|
||||||
|
acc.company[cur] = company[cur];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, dynamicData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userData = storeGet.main.userData();
|
||||||
|
Object.keys(userData).reduce((acc, cur) => {
|
||||||
|
if ([
|
||||||
|
'email', 'firstName', 'lastName', 'phoneNumber', 'codiceFiscale'
|
||||||
|
].includes(cur)) {
|
||||||
|
acc.user[cur] = userData[cur];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, dynamicData);
|
||||||
|
|
||||||
|
if (data.data.applicationFormResponse.content) {
|
||||||
|
data.data.applicationFormResponse.content.map((o) => {
|
||||||
|
if (o.dynamicData && !isEmpty(o.dynamicData)) {
|
||||||
|
formDataInitial[o.id] = pathOr('', o.dynamicData.split('.'), dynamicData);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (data.data.applicationFormResponse.formFields) {
|
if (data.data.applicationFormResponse.formFields) {
|
||||||
const submitData = data.data.applicationFormResponse.formFields.map((o) => ({
|
const submitData = data.data.applicationFormResponse.formFields.map((o) => ({
|
||||||
fieldId: o.fieldId,
|
fieldId: o.fieldId,
|
||||||
fieldValue: o.fieldValue
|
fieldValue: o.fieldValue
|
||||||
}));
|
}));
|
||||||
const formDataInitial = submitData.reduce((acc, cur) => {
|
formDataInitial = submitData.reduce((acc, cur) => {
|
||||||
acc[cur.fieldId] = cur.fieldValue;
|
if (cur.fieldValue) {
|
||||||
|
acc[cur.fieldId] = cur.fieldValue;
|
||||||
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, formDataInitial);
|
||||||
reset();
|
|
||||||
setFormInitialData(formDataInitial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
setFormInitialData(formDataInitial);
|
||||||
}
|
}
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
@@ -333,9 +403,8 @@ const BandoApplication = () => {
|
|||||||
icon="pi pi-arrow-right"
|
icon="pi pi-arrow-right"
|
||||||
iconPos="right"/> : null}
|
iconPos="right"/> : null}
|
||||||
<Button
|
<Button
|
||||||
/*disabled={'SUBMIT' === applicationStatus}*/
|
disabled={'SUBMIT' === applicationStatus}
|
||||||
disabled={true}
|
label={__('Convalidare', 'gepafin')}
|
||||||
label={__('Carica dati per stampa', 'gepafin')}
|
|
||||||
icon="pi pi-check"
|
icon="pi pi-check"
|
||||||
iconPos="right"/>
|
iconPos="right"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -372,20 +441,25 @@ const BandoApplication = () => {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const errSignedPdfCallbacks = (data) => {
|
const errSignedPdfCallbacks = () => {
|
||||||
//set404FromErrorResponse(data);
|
|
||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSetSignedDocumentFromFileupload = (fieldName, stateFieldData) => {
|
const handleSetSignedDocumentFromFileupload = (fieldName, stateFieldData) => {
|
||||||
setSignedPdfFile(stateFieldData);
|
setSignedPdfFile(stateFieldData);
|
||||||
if (!isEmpty(stateFieldData)) {
|
setApplicationStatus('READY');
|
||||||
|
|
||||||
|
/*if (!isEmpty(stateFieldData)) {
|
||||||
setVisibleConfirmation(true);
|
setVisibleConfirmation(true);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ('SUBMIT' === applicationStatus) {
|
if ('SUBMIT' === applicationStatus) {
|
||||||
|
setVisibleConfirmation(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (['AWAITING', 'READY', 'SUBMIT'].includes(applicationStatus)) {
|
||||||
const applId = getApplicationId();
|
const applId = getApplicationId();
|
||||||
|
|
||||||
if (applId) {
|
if (applId) {
|
||||||
@@ -425,7 +499,7 @@ const BandoApplication = () => {
|
|||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
{'SUBMIT' !== applicationStatus
|
{'DRAFT' === applicationStatus
|
||||||
? <ApplicationSteps totalSteps={totalSteps} activeStepIndex={activeStepIndex}/>
|
? <ApplicationSteps totalSteps={totalSteps} activeStepIndex={activeStepIndex}/>
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
@@ -447,13 +521,14 @@ 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(onValidate)}>
|
||||||
{'SUBMIT' !== applicationStatus
|
{'DRAFT' === applicationStatus
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
{actionBtns}
|
{actionBtns}
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|
||||||
{'SUBMIT' !== applicationStatus
|
{'DRAFT' === applicationStatus
|
||||||
|
/*|| 'AWAITING' === applicationStatus*/
|
||||||
? 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'));
|
||||||
@@ -492,7 +567,7 @@ const BandoApplication = () => {
|
|||||||
return ['paragraph'].includes(o.name) && text
|
return ['paragraph'].includes(o.name) && text
|
||||||
? <div className="appForm__content ql-editor" key={o.id}>
|
? <div className="appForm__content ql-editor" key={o.id}>
|
||||||
{renderHtmlContent(text.value)}
|
{renderHtmlContent(text.value)}
|
||||||
</div>
|
</div>
|
||||||
: <FormField
|
: <FormField
|
||||||
key={o.id}
|
key={o.id}
|
||||||
type={o.name}
|
type={o.name}
|
||||||
@@ -516,7 +591,7 @@ const BandoApplication = () => {
|
|||||||
})
|
})
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
{'SUBMIT' === applicationStatus
|
{['AWAITING', 'READY', 'SUBMIT', 'EVALUATION'].includes(applicationStatus)
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
<div className="appForm__field">
|
<div className="appForm__field">
|
||||||
<label>
|
<label>
|
||||||
@@ -525,14 +600,14 @@ const BandoApplication = () => {
|
|||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={'SUBMIT' !== applicationStatus}
|
disabled={'SUBMIT' === applicationStatus}
|
||||||
onClick={onDownloadApplicationPdf}
|
onClick={onDownloadApplicationPdf}
|
||||||
label={__('Scarica PDF', 'gepafin')}
|
label={__('Scarica PDF', 'gepafin')}
|
||||||
icon="pi pi-download"
|
icon="pi pi-download"
|
||||||
iconPos="right"/>
|
iconPos="right"/>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|
||||||
{'SUBMIT' === applicationStatus
|
{'DRAFT' !== applicationStatus
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
<div className="appForm__field">
|
<div className="appForm__field">
|
||||||
<label htmlFor="signedPdfFile">
|
<label htmlFor="signedPdfFile">
|
||||||
@@ -543,9 +618,9 @@ const BandoApplication = () => {
|
|||||||
<FileuploadApplicationSignedPdf
|
<FileuploadApplicationSignedPdf
|
||||||
setDataFn={handleSetSignedDocumentFromFileupload}
|
setDataFn={handleSetSignedDocumentFromFileupload}
|
||||||
fieldName="signedPdfFile"
|
fieldName="signedPdfFile"
|
||||||
disabled={is(Array, signedPdfFile) ? !isEmpty(signedPdfFile) : false}
|
disabled={'AWAITING' !== applicationStatus}
|
||||||
defaultValue={is(Array, signedPdfFile) ? signedPdfFile : []}
|
defaultValue={is(Array, signedPdfFile) ? signedPdfFile : []}
|
||||||
accept={['.p7m,application/pkcs7-mime,application/x-pkcs7-mime,.zip']}
|
accept={['.p7m,application/pkcs7-mime,application/x-pkcs7-mime']}
|
||||||
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
chooseLabel={__('Aggiungi documento', 'gepafin')}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
doctype="document"
|
doctype="document"
|
||||||
@@ -555,14 +630,25 @@ const BandoApplication = () => {
|
|||||||
</div>
|
</div>
|
||||||
: null}
|
: null}
|
||||||
|
|
||||||
|
{'DRAFT' !== applicationStatus
|
||||||
|
? <div className="appPageSection">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={'READY' !== applicationStatus}
|
||||||
|
onClick={onSubmit}
|
||||||
|
label={__('Invia', 'gepafin')}
|
||||||
|
icon="pi pi-check"
|
||||||
|
iconPos="right"/>
|
||||||
|
</div> : null}
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
{'SUBMIT' !== applicationStatus
|
{'DRAFT' === applicationStatus
|
||||||
? <div className="appPageSection__hr">
|
? <div className="appPageSection__hr">
|
||||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|
||||||
{'SUBMIT' !== applicationStatus
|
{'DRAFT' === applicationStatus
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
{actionBtns}
|
{actionBtns}
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ export default class ApplicationService {
|
|||||||
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 validateApplication = (id, body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.post(`${API_BASE_URL}/application/${id}/validate`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
static downloadApplicationPdf = (id, body, callback, errCallback, queryParams) => {
|
static downloadApplicationPdf = (id, body, callback, errCallback, queryParams) => {
|
||||||
NetworkService.postBlob(`${API_BASE_URL}/application/${id}/download-pdf`, body, callback, errCallback, queryParams);
|
NetworkService.postBlob(`${API_BASE_URL}/application/${id}/download-pdf`, body, callback, errCallback, queryParams);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user