- added new fields;

- corrected route urls;
This commit is contained in:
Vitalii Kiiko
2024-09-16 10:50:59 +02:00
parent 0972c0d753
commit cf149485e0
10 changed files with 266 additions and 37 deletions

View File

@@ -12,7 +12,15 @@ import { storeSet, useStore } from '../../store';
import FormsService from '../../service/forms-service';
// tools
import { isVAT } from '../../helpers/validators';
import {
isPIVA,
isCodiceFiscale,
isCAP,
isIBAN,
isEmail,
isEmailPEC,
isUrl
} from '../../helpers/validators';
// components
import { Skeleton } from 'primereact/skeleton';
@@ -22,6 +30,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import { formData as testformData } from '../../tempData';
import BandoService from '../../service/bando-service';
import ApplicationService from '../../service/application-service';
const BandoApplication = () => {
const { id } = useParams();
@@ -41,20 +50,16 @@ const BandoApplication = () => {
const values = getValues();
const validationFns = {
isVAT
isPIVA,
isCodiceFiscale,
isCAP,
isIBAN,
isEmail,
isEmailPEC,
isUrl
}
const onSubmit = (formData) => {
/*const newFormData = Object.keys(formData).reduce((acc, cur) => {
acc.push({
'fieldId': cur,
'fieldValue': formData[cur] && formData[cur].getMonth ? formData[cur].toISOString() : formData[cur]
});
return acc;
}, []);
console.log('newFormData', newFormData);
console.log('errors', errors);*/
};
const onSubmit = () => {};
const saveDraft = () => {
trigger();
@@ -70,7 +75,7 @@ const BandoApplication = () => {
console.log('errors', errors);
};
const getBandoId = () => {
const getApplicationId = () => {
const parsed = parseInt(id)
return !isNaN(parsed) ? parsed : 0;
}
@@ -94,11 +99,11 @@ const BandoApplication = () => {
}
useEffect(() => {
const bandoId = getBandoId();
const applId = getApplicationId();
if (bandoId) {
if (applId) {
storeSet.main.setAsyncRequest();
FormsService.getFormsForCall(bandoId, getCallback, errGetCallbacks);
ApplicationService.getApplication(applId, getCallback, errGetCallbacks);
}
}, [id]);

View File

@@ -4,7 +4,7 @@ import { ItemTypes } from '../ItemTypes';
import uniqid from '../../../../helpers/uniqid';
const BuilderElementItem = ({ dbId, name, label }) => {
const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
const ref = useRef(null);
const [{ isDragging }, drag] = useDrag(() => ({
@@ -28,7 +28,11 @@ const BuilderElementItem = ({ dbId, name, label }) => {
drag(ref);
return (
<div ref={ref} className="formBuilder__elementItem" style={{ opacity }}>
<div
ref={ref}
title={description}
className="formBuilder__elementItem"
style={{ opacity }}>
{label}
</div>
)

View File

@@ -38,6 +38,7 @@ const FormBuilder = () => {
dbId={item.id}
label={item.label}
name={item.name}
description={item.description}
/>
)
}, []);

View File

@@ -20,6 +20,7 @@ import BandoService from '../../service/bando-service';
import { Messages } from 'primereact/messages';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import FaqItemService from '../../service/faq-item-service';
import ApplicationService from '../../service/application-service';
const BandoViewBeneficiario = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
@@ -27,12 +28,9 @@ const BandoViewBeneficiario = () => {
const navigate = useNavigate();
const [data, setData] = useState({});
const [newQuestion, setNewQuestion] = useState('');
const [isApplRequest, setIsApplRequest] = useState(true);
const bandoMsgs = useRef(null);
const closePreview = () => {
navigate(`/tenders/${id}`);
}
const scaricaBando = () => {
}
@@ -100,14 +98,14 @@ const BandoViewBeneficiario = () => {
storeSet.main.unsetAsyncRequest();
}
const getCallback = (data) => {
const getBandoCallback = (data) => {
if (data.status === 'SUCCESS') {
setData(getFormattedBandiData(data.data));
}
storeSet.main.unsetAsyncRequest();
}
const errGetCallback = (data) => {
const errGetBandoCallback = (data) => {
if (bandoMsgs.current && data.message) {
bandoMsgs.current.show([
{
@@ -126,11 +124,33 @@ const BandoViewBeneficiario = () => {
return data;
};
const getApplCallback = (data) => {
if (data.status === 'SUCCESS') {
console.log(data.data)
}
storeSet.main.unsetAsyncRequest();
}
const errGetApplCallback = (data) => {
/*if (bandoMsgs.current && data.message) {
bandoMsgs.current.show([
{
sticky: true, severity: 'error', summary: '',
detail: data.message,
closable: true
}
]);
}*/
set404FromErrorResponse(data);
storeSet.main.unsetAsyncRequest();
}
useEffect(() => {
const parsed = parseInt(id)
const bandoId = !isNaN(parsed) ? parsed : 0;
storeSet.main.setAsyncRequest();
BandoService.getBando(bandoId, getCallback, errGetCallback);
BandoService.getBando(bandoId, getBandoCallback, errGetBandoCallback);
ApplicationService.getApplications(getApplCallback, errGetApplCallback)
}, [id]);
return (
@@ -289,6 +309,7 @@ const BandoViewBeneficiario = () => {
icon="pi pi-download" iconPos="right"/>
<Button
type="button"
disabled={isApplRequest}
onClick={submitApplication}
label={__('Presenta Domanda', 'gepafin')}
icon="pi pi-save" iconPos="right"/>

View File

@@ -138,7 +138,7 @@ const LatestBandiTable = () => {
};
const actionsBodyTemplate = (rowData) => {
return <Link to={`/tenders/${rowData.id}/preview`}>
return <Link to={`/tenders/${rowData.id}`}>
<Button severity="info" label={__('Partecipa', 'gepafin')} icon="pi pi-arrow-right" size="small" iconPos="right" />
</Link>
}

View File

@@ -38,8 +38,8 @@ const MyLatestSubmissionsTable = () => {
modify_date: '2024-08-30T00:00:00+00:00',
progress: 50,
status: 'DRAFT',
id: 11,
callId: 11
id: 33,
callId: 52
},
{
name: 'Bando Sostenibilità 2024',
@@ -47,8 +47,8 @@ const MyLatestSubmissionsTable = () => {
modify_date: '2024-08-15T00:00:00+00:00',
progress: 25,
status: 'DRAFT',
id: 9,
callId: 12
id: 34,
callId: 53
}
]
setItems(getFormattedBandiData(items));
@@ -140,7 +140,7 @@ const MyLatestSubmissionsTable = () => {
};
const actionsBodyTemplate = (rowData) => {
return <Link to={`/tenders/${rowData.callId}/application`}>
return <Link to={`/applications/${rowData.id}`}>
<Button severity="info" label={__('Modifica', 'gepafin')} icon="pi pi-pencil" size="small" iconPos="right" />
</Link>
}