- added login and loginAdmin;
- fixed bug with saving application data;
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { isEmpty } from 'ramda';
|
||||
import { is, isEmpty, isNil } from 'ramda';
|
||||
import { classNames } from 'primereact/utils';
|
||||
|
||||
// components
|
||||
@@ -14,6 +14,7 @@ import FormsService from '../../service/forms-service';
|
||||
// store
|
||||
import { storeSet } from '../../store';
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import BandoService from '../../service/bando-service';
|
||||
|
||||
const BandoForms = () => {
|
||||
const { id } = useParams();
|
||||
@@ -22,6 +23,7 @@ const BandoForms = () => {
|
||||
const [selectedTemplate, setSelectedTemplate] = useState(null);
|
||||
const [selectedForm, setSelectedForm] = useState(null);
|
||||
const [forms, setForms] = useState([]);
|
||||
const [bandoStatus, setBandoStatus] = useState('');
|
||||
|
||||
const doCreateNewForm = () => {
|
||||
navigate(`/bandi/${id}/forms/new`);
|
||||
@@ -46,6 +48,18 @@ const BandoForms = () => {
|
||||
//navigate(`/bandi/${id}`);
|
||||
}
|
||||
|
||||
const getCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setBandoStatus(data.data.status);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getFormsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const forms = data.data.map(o => ({label: o.label, value: o.id}))
|
||||
@@ -68,6 +82,7 @@ const BandoForms = () => {
|
||||
])
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
BandoService.getBando(id, getCallback, errGetCallback);
|
||||
FormsService.getFormsForCall(bandoId, getFormsCallback, errGetFormsCallback);
|
||||
}, [id]);
|
||||
|
||||
@@ -112,6 +127,7 @@ const BandoForms = () => {
|
||||
<p>{__('Inizia con un form completamente vuoto e personalizzabil', 'gepafin')}</p>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={'PUBLISH' === bandoStatus}
|
||||
onClick={doCreateNewForm}
|
||||
label={__('Crea form', 'gepafin')}/>
|
||||
</div>
|
||||
@@ -134,7 +150,7 @@ const BandoForms = () => {
|
||||
outlined
|
||||
disabled={!selectedForm}
|
||||
onClick={goToEditForm}
|
||||
label={__('Modifica', 'gepafin')}
|
||||
label={'PUBLISH' === bandoStatus ? __('Mostra', 'gepafin') : __('Modifica', 'gepafin')}
|
||||
icon="pi pi-cog" iconPos="right"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user