import React, { useState, useEffect, useRef } from 'react'; import { __ } from '@wordpress/i18n'; import { useParams } from 'react-router-dom'; import { useForm, Controller } from 'react-hook-form'; import { classNames } from 'primereact/utils'; // components import { InputText } from 'primereact/inputtext'; import { InputTextarea } from 'primereact/inputtextarea'; import getBandoLabel from '../../helpers/getBandoLabel'; import { Button } from 'primereact/button'; import { Dropdown } from 'primereact/dropdown'; import { Menu } from 'primereact/menu'; import FormField from '../../components/FormField'; import FormFieldRepeater from '../../components/FormFieldRepeater'; import { Skeleton } from 'primereact/skeleton'; import FormFieldRepeaterCriteria from '../../components/FormFieldRepeaterCriteria'; import FormFieldRepeaterFaq from '../../components/FormFieldRepeaterFaq'; const Bando = () => { const { id } = useParams(); const [data, setData] = useState({}); const [isFormLoading, setIsFormLoading] = useState(true); const [selectedTemplate, setSelectedTemplate] = useState(null); const [templates, setTemplate] = useState(null); const { control, reset, handleSubmit, formState: { errors }, getValues, setValue, register } = useForm(data); let minDateStart = new Date(); const onSubmit = formData => console.log(formData); // temp const exampleOfAimedToOptions = [{ id: 11, value: 'PMI con sede in Umbria' }]; const exampleOfCriteriaOptions = [{ id: 15, value: 'Innovatività del progetto' }]; const exampleOfFaqOptions = [ { id: 2, question: 'Question 1?', answer: 'Lorem ipsum dolor' } ]; const exampleOfChecklistOptions = [ { id: 9, value: 'Requisiti di ammissibilità soddisfatti' }, { id: 9, value: 'Documentazione completa' } ]; const onPublish = () => { console.log('click onPublish'); } useEffect(() => { const parsed = parseInt(id) const bandoId = !isNaN(parsed) ? parsed : 0; setTimeout(() => { const data = 0 === bandoId ? { status: 'draft', name: '', description: '' } : { name: 'Bando Innovazione 2024', description: '', start_date: '2024-08-08T00:00:00+00:00', end_date: '2024-08-30T00:00:00+00:00', submissions: 24, status: 'publish', id: 11 } setData(data); reset(); const templates = [ { name: 'Il mio template', value: 22 }, { name: 'Template #11', value: 11 }, ]; setTemplate(templates); setIsFormLoading(false); }, 3000); }, [id]); return (

{__('Creazione/Modifica Bando', 'gepafin')}

{__('Stato:', 'gepafin')} {getBandoLabel(data.status)}

{!isFormLoading ?
setSelectedTemplate(e.value)} options={templates} optionLabel="name" placeholder={__('Seleziona template', 'gepafin')}/>
: null}
{!isFormLoading ?
{__('A chi si rivolge', 'gepafin')}* {__('(almeno 1 tipo di destinatari)', 'gepafin')}} /> {__('Criteri di valutazione', 'gepafin')}* {__('(almeno 1 criterio di valutazione)', 'gepafin')}}/> {__('Checklist valutazione Pre-Istruttoria', 'gepafin')}* {__('(almeno 1 elemento)', 'gepafin')}} />
: <> }
) } export default Bando;