- added bando preview page;

- added bando form preview;
This commit is contained in:
Vitalii Kiiko
2024-08-27 17:02:16 +02:00
parent 5095ed7365
commit 87684bc76b
37 changed files with 1235 additions and 246 deletions

View File

@@ -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);
}