- updated version;
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { forwardRef, useImperativeHandle, useEffect, useState, useMemo } from 'react';
|
||||
import React, { forwardRef, useImperativeHandle, useEffect, useState, useMemo, useRef } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -11,6 +11,9 @@ import FormFieldRepeater from '../../../../components/FormFieldRepeater';
|
||||
import FormFieldRepeaterFaq from '../../../../components/FormFieldRepeaterFaq';
|
||||
import BandoEditFormActions from '../BandoEditFormActions';
|
||||
import UnsavedChangesDetector from '../../../../components/UnsavedChangesDetector';
|
||||
import { Toast } from 'primereact/toast';
|
||||
|
||||
// api
|
||||
import BandoService from '../../../../service/bando-service';
|
||||
import LookupdataService from '../../../../service/lookupdata-service';
|
||||
|
||||
@@ -39,6 +42,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
}, [formInitialData]), mode: 'onChange'
|
||||
});
|
||||
const values = getValues();
|
||||
const toast = useRef(null);
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
if (!isNil(formData.dates) && formData.dates.length) {
|
||||
@@ -54,6 +58,11 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
|
||||
const createCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('Il bando è stato aggiornato corretamente!', 'gepafin')
|
||||
});
|
||||
const values = getValues();
|
||||
if (!values.id && data.data.id) {
|
||||
navigate(`/tenders/${data.data.id}`);
|
||||
@@ -84,7 +93,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
delete o.type;
|
||||
return {
|
||||
...o,
|
||||
lookUpDataId: o.id
|
||||
lookUpDataId: o.id,
|
||||
id: null
|
||||
};
|
||||
});
|
||||
setAimedToOptions(aimedTo);
|
||||
@@ -94,7 +104,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
delete o.type;
|
||||
return {
|
||||
...o,
|
||||
lookUpDataId: o.id
|
||||
lookUpDataId: o.id,
|
||||
id: null
|
||||
};
|
||||
});
|
||||
setFaqOptions(faqItems);
|
||||
@@ -290,6 +301,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, getFormErrors },
|
||||
<span>{__('Azioni', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<Toast ref={toast} />
|
||||
<BandoEditFormActions
|
||||
id={values.id}
|
||||
openPreview={openPreview}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
||||
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -11,8 +11,13 @@ import FormFieldRepeater from '../../../../components/FormFieldRepeater';
|
||||
import FormFieldRepeaterCriteria from '../../../../components/FormFieldRepeaterCriteria';
|
||||
import BandoEditFormActions from '../BandoEditFormActions';
|
||||
import UnsavedChangesDetector from '../../../../components/UnsavedChangesDetector';
|
||||
import { Toast } from 'primereact/toast';
|
||||
|
||||
// api
|
||||
import BandoService from '../../../../service/bando-service';
|
||||
import LookupdataService from '../../../../service/lookupdata-service';
|
||||
|
||||
// store
|
||||
import { storeSet } from '../../../../store';
|
||||
|
||||
const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors }, ref) {
|
||||
@@ -37,6 +42,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
});
|
||||
const values = getValues();
|
||||
const step2Props = ['threshold', 'criteria', 'checkList', 'docs', 'images'];
|
||||
const toast = useRef(null);
|
||||
|
||||
const onSubmit = (formData) => {
|
||||
if (!isNil(formData.dates) && formData.dates.length) {
|
||||
@@ -55,6 +61,11 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
|
||||
const createCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('Il bando è stato aggiornato corretamente!', 'gepafin')
|
||||
});
|
||||
setFormInitialData(data.data);
|
||||
reset();
|
||||
}
|
||||
@@ -73,7 +84,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
return {
|
||||
...o,
|
||||
score: 0,
|
||||
lookUpDataId: o.id
|
||||
lookUpDataId: o.id,
|
||||
id: null
|
||||
};
|
||||
});
|
||||
setCriteriaOptions(criteria);
|
||||
@@ -83,7 +95,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
delete o.type;
|
||||
return {
|
||||
...o,
|
||||
lookUpDataId: o.id
|
||||
lookUpDataId: o.id,
|
||||
id: null
|
||||
};
|
||||
});
|
||||
setChecklistOptions(checklist);
|
||||
@@ -215,6 +228,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, getFormErrors },
|
||||
<span>{__('Azioni', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<Toast ref={toast} />
|
||||
<BandoEditFormActions
|
||||
openPreview={openPreview}
|
||||
openPreviewEvaluation={openPreviewEvaluation}/>
|
||||
|
||||
Reference in New Issue
Block a user