- 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

@@ -1,3 +1,27 @@
export const isVAT = (v) => {
export const isPIVA = (v) => {
return false;
}
export const isCodiceFiscale = (v) => {
return false;
}
export const isCAP = (v) => {
return false;
}
export const isIBAN = (v) => {
return false;
}
export const isEmail = (v) => {
return false;
}
export const isEmailPEC = (v) => {
return false;
}
export const isUrl = (v) => {
return false;
}

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>
}

View File

@@ -28,35 +28,44 @@ const routes = ({ role }) => {
</DefaultLayout>}/>
<Route path="/tenders" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Bandi/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoEdit/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoViewBeneficiario/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoView/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoViewBeneficiario/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/preview-evaluation" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoView/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/forms" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoForms/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/forms/:formId" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoFormsEdit/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/forms/:formId/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoFormsPreview/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/flow" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoFlowEdit/> : null}
</DefaultLayout>}/>
<Route path="/tenders/:id/application/" element={<DefaultLayout>
{'ROLE_BENEFICIARY' === role ? <BandoApplication/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/applications" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <Applications/> : null}
</DefaultLayout>}/>
<Route path="/applications/:id/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoApplication/> : null}
</DefaultLayout>}/>
</Route>
<Route exact path="/login" element={<Login/>}/>
{/*<Route exact path="/forgot-password" element={<ForgotPassword/>}/>*/}

View File

@@ -0,0 +1,14 @@
import { NetworkService } from './network-service';
const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
export default class ApplicationService {
static getApplications = (callback, errCallback) => {
NetworkService.get(`${API_BASE_URL}/application`, callback, errCallback);
};
static getApplication = (id, callback, errCallback) => {
NetworkService.get(`${API_BASE_URL}/application/${id}`, callback, errCallback);
};
}

View File

@@ -551,6 +551,157 @@ export const elementItems = [
maxSize: 100000,
custom: null
}
},
{
id: 11,
sortOrder: 11,
name: 'textinput',
label: 'Campo Partita IVA',
description: "Specifico per l'inserimento del numero di Partita IVA",
settings: [
{
name: "label",
value: "Partita IVA"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: true,
minLength: 11,
maxLength: 11,
custom: 'isPIVA'
}
},
{
id: 12,
sortOrder: 12,
name: 'textinput',
label: 'Campo Codice Fiscale',
description: "Specifico per l'inserimento del Codice Fiscale italiano per persone fisiche e giuridiche",
settings: [
{
name: "label",
value: "Codice Fiscale"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: true,
minLength: 11,
maxLength: 16,
custom: 'isCodiceFiscale'
}
},
{
id: 13,
sortOrder: 13,
name: 'numberinput',
label: 'Campo CAP',
description: "Per l'inserimento del Codice di Avviamento Postale",
settings: [
{
name: "label",
value: "CAP"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: true,
custom: 'isCAP'
}
},
{
id: 14,
sortOrder: 14,
name: 'textinput',
label: 'Campo IBAN',
description: "Per l'inserimento del codice IBAN",
settings: [
{
name: "label",
value: "IBAN"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: true,
custom: 'isIBAN'
}
},
{
id: 15,
sortOrder: 15,
name: 'textinput',
label: 'Campo Email',
description: "Per l'inserimento di indirizzi email standard (non PEC)",
settings: [
{
name: "label",
value: "nome@esempio.it"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: false,
custom: 'isEmail'
}
},
{
id: 16,
sortOrder: 16,
name: 'textinput',
label: 'Campo PEC',
description: "Specifico per l'inserimento di un indirizzo di Posta Elettronica Certificata",
settings: [
{
name: "label",
value: "nome@pec.it"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: false,
custom: 'isEmailPEC'
}
},
{
id: 17,
sortOrder: 17,
name: 'textinput',
label: 'Campo URL',
description: "Per l'inserimento di indirizzi web",
settings: [
{
name: "label",
value: "Indirizzo URL"
},
{
name: "placeholder",
value: ""
}
],
validators: {
isRequired: false,
custom: 'isUrl'
}
}
]