- added bando preview page;
- added bando form preview;
This commit is contained in:
@@ -13,7 +13,7 @@ const BandoEditFormActions = ({ openPreview, openPreviewEvaluation }) => {
|
||||
label={__('Salva bozza', 'gepafin')} icon="pi pi-save" iconPos="right"/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
disabled={false}
|
||||
outlined
|
||||
onClick={openPreview}
|
||||
label={__('Anteprima beneficiario', 'gepafin')} icon="pi pi-eye" iconPos="right"/>
|
||||
|
||||
@@ -41,11 +41,11 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
// end of temp data
|
||||
|
||||
const openPreview = () => {
|
||||
navigate('/bandi/preview/11');
|
||||
navigate('/bandi/11/preview');
|
||||
}
|
||||
|
||||
const openPreviewEvaluation = () => {
|
||||
navigate('/bandi/preview-evaluation/11');
|
||||
navigate('/bandi/11/preview-evaluation');
|
||||
}
|
||||
|
||||
useImperativeHandle(
|
||||
@@ -57,6 +57,9 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
},
|
||||
getErrors: () => {
|
||||
return errors;
|
||||
},
|
||||
getValues: () => {
|
||||
return getValues();
|
||||
}
|
||||
}
|
||||
}, [errors, isValid]);
|
||||
@@ -106,6 +109,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
fieldName="descriptionLong"
|
||||
label={__('Descrizione completa', 'gepafin')}
|
||||
control={control}
|
||||
rows={7}
|
||||
errors={errors}
|
||||
defaultValue={values['descriptionLong']}
|
||||
config={{
|
||||
@@ -199,6 +203,12 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
}}
|
||||
label={__('FAQ', 'gepafin')}/>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<BandoEditFormActions
|
||||
openPreview={openPreview}
|
||||
openPreviewEvaluation={openPreviewEvaluation}/>
|
||||
|
||||
@@ -60,9 +60,12 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
},
|
||||
getErrors: () => {
|
||||
return errors;
|
||||
},
|
||||
getValues: () => {
|
||||
return getValues();
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
}, [errors, isValid]);
|
||||
|
||||
useEffect(() => {
|
||||
trigger().then(() => clearErrors());
|
||||
@@ -84,7 +87,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
validate: {
|
||||
minOneItem: v => !isEmpty(v) || __('Almeno 1 criterio di valutazione', 'gepafin'),
|
||||
noEmptyValue: v => v
|
||||
.filter(o => isEmpty(o.value) || isEmpty(o.score)).length === 0
|
||||
.filter(o => isEmpty(o.value) || isEmpty(o.score)).length === 0
|
||||
|| __('Non lasciare il valore vuoto', 'gepafin')
|
||||
}
|
||||
}}/>
|
||||
@@ -135,7 +138,12 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
}}
|
||||
/>
|
||||
|
||||
<button type="button" onClick={() => console.log(getValues())}>Check</button>
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<BandoEditFormActions
|
||||
openPreview={openPreview}
|
||||
openPreviewEvaluation={openPreviewEvaluation}/>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
//import equal from 'fast-deep-equal';
|
||||
import { is, isNil } from 'ramda';
|
||||
|
||||
// components
|
||||
import getBandoLabel from '../../helpers/getBandoLabel';
|
||||
@@ -10,7 +12,9 @@ import { Steps } from 'primereact/steps';
|
||||
import BandoEditFormStep1 from './components/BandoEditFormStep1';
|
||||
import BandoEditFormStep2 from './components/BandoEditFormStep2';
|
||||
import { Messages } from 'primereact/messages';
|
||||
import { is, isNil } from 'ramda';
|
||||
|
||||
// TODO temp
|
||||
import { bandoTest } from '../../tempData';
|
||||
|
||||
const BandoEdit = () => {
|
||||
const navigate = useNavigate();
|
||||
@@ -18,8 +22,8 @@ const BandoEdit = () => {
|
||||
const [activeStep, setActiveStep] = useState(0)
|
||||
const [data, setData] = useState({});
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [selectedTemplate, setSelectedTemplate] = useState(null);
|
||||
const [templates, setTemplate] = useState(null);
|
||||
//const [selectedTemplate, setSelectedTemplate] = useState(null);
|
||||
//const [templates, setTemplate] = useState(null);
|
||||
const formRef = useRef(null);
|
||||
const stepErrorMsgs = useRef(null);
|
||||
|
||||
@@ -31,7 +35,11 @@ const BandoEdit = () => {
|
||||
return false
|
||||
}
|
||||
stepErrorMsgs.current.clear();
|
||||
if (formRef.current.isFormValid()) {
|
||||
const isFormValid = formRef.current.isFormValid();
|
||||
//const values = formRef.current.getValues();
|
||||
//const diffData = equal(values, data);
|
||||
// TODO warn about unsaved data
|
||||
if (isFormValid) {
|
||||
goToStep(0)
|
||||
} else {
|
||||
stepErrorMsgs.current.show([
|
||||
@@ -50,7 +58,9 @@ const BandoEdit = () => {
|
||||
}
|
||||
stepErrorMsgs.current.clear();
|
||||
const isFormValid = formRef.current.isFormValid();
|
||||
console.log('before go to step 1:', isFormValid)
|
||||
//const values = formRef.current.getValues();
|
||||
//const diffData = equal(values, data);
|
||||
// TODO warn about unsaved data
|
||||
if (isFormValid) {
|
||||
goToStep(1);
|
||||
} else {
|
||||
@@ -81,47 +91,7 @@ const BandoEdit = () => {
|
||||
status: 'draft',
|
||||
name: ''
|
||||
}
|
||||
: {
|
||||
"name": "Innovazione digitale 2024",
|
||||
"confidi": false,
|
||||
"descriptionShort": "Supporto alle PMI per progetti di digitalizzazione e innovazione tecnologica.",
|
||||
"descriptionLong": "Il bando \"Innovazione Digitale 2024\" mira a sostenere le PMI nell'adozione di tecnologie digitali innovative. I progetti finanziabili includono l'implementazione di soluzioni di intelligenza artificiale, blockchain, IoT, e altre tecnologie avanzate che possono migliorare la competitività delle imprese.",
|
||||
"documentationRequested": "Documentazione richiesta*",
|
||||
"dates": [
|
||||
"2024-08-27T22:00:00.000Z",
|
||||
"2024-10-29T23:00:00.000Z"
|
||||
],
|
||||
"amount": 0,
|
||||
"amountMax": 0,
|
||||
"aimedTo": [
|
||||
{
|
||||
"id": 3,
|
||||
"value": "PMI con sede in Umbria",
|
||||
"status": "existing"
|
||||
}
|
||||
],
|
||||
"faq": [
|
||||
{
|
||||
"id": 2,
|
||||
"question": "Question 1?",
|
||||
"answer": "Lorem ipsum dolor",
|
||||
"visible": true,
|
||||
"status": "existing"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
/*{
|
||||
createdDate: "2024-08-23T12:40:47.700350791",
|
||||
description: null,
|
||||
filePath: "https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/SCR-20240820-kiwn.pdf",
|
||||
id: 10,
|
||||
name: "SCR-20240820-kiwn.pdf",
|
||||
updatedDate: "2024-08-23T12:40:47.700373894"
|
||||
}*/
|
||||
],
|
||||
status: 'draft',
|
||||
id: 11
|
||||
}
|
||||
: bandoTest;
|
||||
|
||||
if (bandoId === 0) {
|
||||
setData(data);
|
||||
@@ -134,11 +104,11 @@ const BandoEdit = () => {
|
||||
|
||||
setData(data);
|
||||
|
||||
const templates = [
|
||||
/*const templates = [
|
||||
{ name: 'Il mio template', value: 22 },
|
||||
{ name: 'Template #11', value: 11 },
|
||||
];
|
||||
setTemplate(templates);
|
||||
setTemplate(templates);*/
|
||||
setIsLoading(false);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user