- 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) => {
|
||||
switch (status) {
|
||||
case 'ACTIVE':
|
||||
return __('Attivo', 'gepafin');
|
||||
|
||||
case 'SUBMIT':
|
||||
return __('Inviato', 'gepafin');
|
||||
|
||||
@@ -11,9 +14,27 @@ const getBandoLabel = (status) => {
|
||||
case 'READY_TO_PUBLISH':
|
||||
return __('Pronto', 'gepafin');
|
||||
|
||||
case 'READY':
|
||||
return __('Pronto', 'gepafin');
|
||||
|
||||
case 'DRAFT':
|
||||
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':
|
||||
return __('Scaduto', 'gepafin');
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
const getBandoSeverity = (status) => {
|
||||
switch (status) {
|
||||
case 'ACTIVE':
|
||||
return 'success';
|
||||
|
||||
case 'SUBMIT':
|
||||
return 'success';
|
||||
|
||||
@@ -11,9 +12,27 @@ const getBandoSeverity = (status) => {
|
||||
case 'READY_TO_PUBLISH':
|
||||
return 'info';
|
||||
|
||||
case 'READY':
|
||||
return 'info';
|
||||
|
||||
case 'DRAFT':
|
||||
return 'warning';
|
||||
|
||||
case 'AWAITING':
|
||||
return 'warning';
|
||||
|
||||
case 'AWAIT':
|
||||
return 'warning';
|
||||
|
||||
case 'OPEN':
|
||||
return 'warning';
|
||||
|
||||
case 'ASSIGNED':
|
||||
return 'warning';
|
||||
|
||||
case 'EVALUATION':
|
||||
return 'info';
|
||||
|
||||
case 'EXPIRED':
|
||||
return 'closed';
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
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 { TZDate } from '@date-fns/tz';
|
||||
import "quill/dist/quill.core.css";
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../store';
|
||||
import { storeSet, storeGet, useStore } from '../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../service/application-service';
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
} from '../../helpers/validators';
|
||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
||||
|
||||
// components
|
||||
import { Skeleton } from 'primereact/skeleton';
|
||||
@@ -36,7 +37,7 @@ import ApplicationSteps from './ApplicationSteps';
|
||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import FileuploadApplicationSignedPdf from '../../components/FileuploadApplicationSignedPdf';
|
||||
import getFormatedFileSizeText from '../../helpers/getFormatedFileSizeText';
|
||||
|
||||
import { defaultMaxFileSize } from '../../configData';
|
||||
|
||||
const BandoApplication = () => {
|
||||
@@ -47,7 +48,6 @@ const BandoApplication = () => {
|
||||
const [bandoTitle, setBandoTitle] = useState('');
|
||||
const [formId, setFormId] = useState('');
|
||||
const [totalSteps, setTotalSteps] = useState(0);
|
||||
//const [completedSteps, setCompletedSteps] = useState(0);
|
||||
const [visibleConfirmation, setVisibleConfirmation] = useState(false);
|
||||
const [applicationStatus, setApplicationStatus] = useState('');
|
||||
const [activeStep, setActiveStep] = useState(1);
|
||||
@@ -86,6 +86,14 @@ const BandoApplication = () => {
|
||||
const activeStepIndex = activeStep - 1;
|
||||
const values = getValues();
|
||||
|
||||
const onValidate = () => {
|
||||
const applId = getApplicationId();
|
||||
storeSet.main.setAsyncRequest();
|
||||
formMsgs.current.clear();
|
||||
|
||||
ApplicationService.validateApplication(applId, {}, validateApplicationCallback, errValidateApplicationCallback);
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
const applId = getApplicationId();
|
||||
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 = '') => {
|
||||
trigger();
|
||||
|
||||
@@ -268,19 +296,61 @@ const BandoApplication = () => {
|
||||
setApplicationStatus(data.data.applicationStatus)
|
||||
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) {
|
||||
const submitData = data.data.applicationFormResponse.formFields.map((o) => ({
|
||||
fieldId: o.fieldId,
|
||||
fieldValue: o.fieldValue
|
||||
}));
|
||||
const formDataInitial = submitData.reduce((acc, cur) => {
|
||||
formDataInitial = submitData.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
}, formDataInitial);
|
||||
}
|
||||
|
||||
reset();
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -333,9 +403,8 @@ const BandoApplication = () => {
|
||||
icon="pi pi-arrow-right"
|
||||
iconPos="right"/> : null}
|
||||
<Button
|
||||
/*disabled={'SUBMIT' === applicationStatus}*/
|
||||
disabled={true}
|
||||
label={__('Carica dati per stampa', 'gepafin')}
|
||||
disabled={'SUBMIT' === applicationStatus}
|
||||
label={__('Convalidare', 'gepafin')}
|
||||
icon="pi pi-check"
|
||||
iconPos="right"/>
|
||||
</div>
|
||||
@@ -372,20 +441,25 @@ const BandoApplication = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errSignedPdfCallbacks = (data) => {
|
||||
//set404FromErrorResponse(data);
|
||||
const errSignedPdfCallbacks = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const handleSetSignedDocumentFromFileupload = (fieldName, stateFieldData) => {
|
||||
setSignedPdfFile(stateFieldData);
|
||||
if (!isEmpty(stateFieldData)) {
|
||||
setApplicationStatus('READY');
|
||||
|
||||
/*if (!isEmpty(stateFieldData)) {
|
||||
setVisibleConfirmation(true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if ('SUBMIT' === applicationStatus) {
|
||||
setVisibleConfirmation(true);
|
||||
}
|
||||
|
||||
if (['AWAITING', 'READY', 'SUBMIT'].includes(applicationStatus)) {
|
||||
const applId = getApplicationId();
|
||||
|
||||
if (applId) {
|
||||
@@ -425,7 +499,7 @@ const BandoApplication = () => {
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
{'SUBMIT' !== applicationStatus
|
||||
{'DRAFT' === applicationStatus
|
||||
? <ApplicationSteps totalSteps={totalSteps} activeStepIndex={activeStepIndex}/>
|
||||
: null}
|
||||
|
||||
@@ -447,13 +521,14 @@ const BandoApplication = () => {
|
||||
|
||||
<div className="appPage__content">
|
||||
<BlockingOverlay shouldDisplay={isAsyncRequest}/>
|
||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
{'SUBMIT' !== applicationStatus
|
||||
<form className="appForm" onSubmit={handleSubmit(onValidate)}>
|
||||
{'DRAFT' === applicationStatus
|
||||
? <div className="appPageSection">
|
||||
{actionBtns}
|
||||
</div> : null}
|
||||
|
||||
{'SUBMIT' !== applicationStatus
|
||||
{'DRAFT' === applicationStatus
|
||||
/*|| 'AWAITING' === applicationStatus*/
|
||||
? formData.map(o => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
@@ -516,7 +591,7 @@ const BandoApplication = () => {
|
||||
})
|
||||
: null}
|
||||
|
||||
{'SUBMIT' === applicationStatus
|
||||
{['AWAITING', 'READY', 'SUBMIT', 'EVALUATION'].includes(applicationStatus)
|
||||
? <div className="appPageSection">
|
||||
<div className="appForm__field">
|
||||
<label>
|
||||
@@ -525,14 +600,14 @@ const BandoApplication = () => {
|
||||
</div>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={'SUBMIT' !== applicationStatus}
|
||||
disabled={'SUBMIT' === applicationStatus}
|
||||
onClick={onDownloadApplicationPdf}
|
||||
label={__('Scarica PDF', 'gepafin')}
|
||||
icon="pi pi-download"
|
||||
iconPos="right"/>
|
||||
</div> : null}
|
||||
|
||||
{'SUBMIT' === applicationStatus
|
||||
{'DRAFT' !== applicationStatus
|
||||
? <div className="appPageSection">
|
||||
<div className="appForm__field">
|
||||
<label htmlFor="signedPdfFile">
|
||||
@@ -543,9 +618,9 @@ const BandoApplication = () => {
|
||||
<FileuploadApplicationSignedPdf
|
||||
setDataFn={handleSetSignedDocumentFromFileupload}
|
||||
fieldName="signedPdfFile"
|
||||
disabled={is(Array, signedPdfFile) ? !isEmpty(signedPdfFile) : false}
|
||||
disabled={'AWAITING' !== applicationStatus}
|
||||
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')}
|
||||
multiple={false}
|
||||
doctype="document"
|
||||
@@ -555,14 +630,25 @@ const BandoApplication = () => {
|
||||
</div>
|
||||
: 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>
|
||||
|
||||
{'SUBMIT' !== applicationStatus
|
||||
{'DRAFT' === applicationStatus
|
||||
? <div className="appPageSection__hr">
|
||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||
</div> : null}
|
||||
|
||||
{'SUBMIT' !== applicationStatus
|
||||
{'DRAFT' === applicationStatus
|
||||
? <div className="appPageSection">
|
||||
{actionBtns}
|
||||
</div> : null}
|
||||
|
||||
@@ -28,6 +28,10 @@ export default class ApplicationService {
|
||||
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) => {
|
||||
NetworkService.postBlob(`${API_BASE_URL}/application/${id}/download-pdf`, body, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user