diff --git a/src/helpers/getBandoLabel.js b/src/helpers/getBandoLabel.js
index acd7edc..35a850e 100644
--- a/src/helpers/getBandoLabel.js
+++ b/src/helpers/getBandoLabel.js
@@ -26,6 +26,9 @@ const getBandoLabel = (status) => {
case 'AWAIT':
return __('In attesa', 'gepafin');
+ case 'OPEN':
+ return __('Aperto', 'gepafin');
+
case 'ASSIGNED':
return __('Assegnato', 'gepafin');
diff --git a/src/helpers/getBandoSeverity.js b/src/helpers/getBandoSeverity.js
index d7c62d2..d090c80 100644
--- a/src/helpers/getBandoSeverity.js
+++ b/src/helpers/getBandoSeverity.js
@@ -24,6 +24,9 @@ const getBandoSeverity = (status) => {
case 'AWAIT':
return 'warning';
+ case 'OPEN':
+ return 'warning';
+
case 'ASSIGNED':
return 'warning';
diff --git a/src/icons/HelpIcon/index.js b/src/icons/HelpIcon/index.js
new file mode 100644
index 0000000..26dfcd7
--- /dev/null
+++ b/src/icons/HelpIcon/index.js
@@ -0,0 +1,20 @@
+import React from 'react';
+
+const HelpIcon = () => {
+ return
+}
+
+export default HelpIcon;
\ No newline at end of file
diff --git a/src/layouts/DefaultLayout/components/AppSidebar/index.js b/src/layouts/DefaultLayout/components/AppSidebar/index.js
index 85985d2..e336bdb 100644
--- a/src/layouts/DefaultLayout/components/AppSidebar/index.js
+++ b/src/layouts/DefaultLayout/components/AppSidebar/index.js
@@ -1,12 +1,13 @@
import React from 'react';
import { __ } from '@wordpress/i18n';
-import { intersection } from 'ramda';
+import { intersection, is } from 'ramda';
// store
import { useStore } from '../../../../store';
// components
import { NavLink } from 'react-router-dom';
+import HelpIcon from '../../../../icons/HelpIcon';
const AppSidebar = () => {
const permissions = useStore().main.getPermissions();
@@ -54,32 +55,39 @@ const AppSidebar = () => {
id: 6,
enable: intersection(permissions, ['EVALUATE_APPLICATIONS']).length
},
+ {
+ label: __('Soccorso Istruttorio', 'gepafin'),
+ icon: ,
+ href: '/soccorso-istruttorio',
+ id: 7,
+ enable: intersection(permissions, ['EVALUATE_APPLICATIONS']).length
+ },
{
label: __('Gestione Utenti', 'gepafin'),
icon: 'pi pi-users',
href: '/utenti',
- id: 7,
+ id: 8,
enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length
},
{
label: __('Configurazione', 'gepafin'),
icon: 'pi pi-cog',
//href: '/configurazione',
- id: 8,
+ id: 9,
enable: false
},
{
label: __('Report e Analisi', 'gepafin'),
icon: 'pi pi-chart-bar',
//href: '/stats',
- id: 9,
+ id: 10,
enable: false
},
{
label: __('Log di Sistema', 'gepafin'),
icon: 'pi pi-receipt',
clickFn: () => {},
- id: 10,
+ id: 11,
enable: false
}
]
@@ -91,11 +99,15 @@ const AppSidebar = () => {
.map(o =>
{o.href
?
-
+ {is(String, o.icon)
+ ?
+ : o.icon}
{o.label}
: }
)}
diff --git a/src/pages/BandoForms/index.js b/src/pages/BandoForms/index.js
index da67894..ea70e59 100644
--- a/src/pages/BandoForms/index.js
+++ b/src/pages/BandoForms/index.js
@@ -1,8 +1,9 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useRef } from 'react';
import { __ } from '@wordpress/i18n';
import { useParams, useNavigate } from 'react-router-dom';
-import { is, isEmpty, isNil } from 'ramda';
+import { isEmpty } from 'ramda';
import { classNames } from 'primereact/utils';
+import { klona } from 'klona';
// components
import { Button } from 'primereact/button';
@@ -15,6 +16,8 @@ import FormsService from '../../service/forms-service';
import { storeSet } from '../../store';
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import BandoService from '../../service/bando-service';
+import uniqid from '../../helpers/uniqid';
+import { Toast } from 'primereact/toast';
const BandoForms = () => {
const { id } = useParams();
@@ -22,8 +25,10 @@ const BandoForms = () => {
const [templates, setTemplates] = useState(null);
const [selectedTemplate, setSelectedTemplate] = useState(null);
const [selectedForm, setSelectedForm] = useState(null);
+ const [selectedForDuplicateForm, setSelectedForDuplicateForm] = useState(null);
const [forms, setForms] = useState([]);
const [bandoStatus, setBandoStatus] = useState('');
+ const toast = useRef(null);
const doCreateNewForm = () => {
navigate(`/bandi/${id}/forms/new`);
@@ -43,11 +48,74 @@ const BandoForms = () => {
}
}
- const goToEditFormFromTemplate = () => {
- console.log('goToEditFormFromTemplate', selectedTemplate)
- //navigate(`/bandi/${id}`);
+ const doDuplicateForm = () => {
+ const selectedFormArr = forms.filter(o => o.value === selectedForDuplicateForm);
+
+ if (!isEmpty(selectedFormArr)) {
+ storeSet.main.setAsyncRequest();
+ FormsService.getFormById(selectedForDuplicateForm, getFormCallback, errGetFormCallbacks);
+ }
}
+ const getFormCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ const newLabel = `${data.data.label} (copy)`;
+
+ const formData = {
+ label: newLabel,
+ content: data.data.content.map(o => ({
+ ...o,
+ id: uniqid()
+ }))
+ }
+
+ FormsService.createFormForCall(
+ id,
+ formData,
+ formCreateCallback,
+ errFormCreateCallback
+ );
+ }
+ }
+
+ const errGetFormCallbacks = (data) => {
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const formCreateCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ storeSet.main.unsetAsyncRequest();
+
+ if (toast.current) {
+ toast.current.show({
+ severity: 'success',
+ summary: '',
+ detail: __('Il form è stato aggiornato corretamente!', 'gepafin')
+ });
+ }
+
+ setTimeout(() => {
+ navigate(`/bandi/${id}/forms/${data.data.id}`);
+ }, 1000)
+ }
+ }
+
+ const errFormCreateCallback = (data) => {
+ storeSet.main.unsetAsyncRequest();
+ if (toast.current) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ }
+
+ /*const goToEditFormFromTemplate = () => {
+ console.log('goToEditFormFromTemplate', selectedTemplate)
+ }*/
+
const getCallback = (data) => {
if (data.status === 'SUCCESS') {
setBandoStatus(data.data.status);
@@ -62,7 +130,7 @@ const BandoForms = () => {
const getFormsCallback = (data) => {
if (data.status === 'SUCCESS') {
- const forms = data.data.map(o => ({label: o.label, value: o.id}))
+ const forms = data.data.map(o => ({ label: o.label, value: o.id }))
setForms(forms);
}
storeSet.main.unsetAsyncRequest();
@@ -78,7 +146,7 @@ const BandoForms = () => {
const bandoId = !isNaN(parsed) ? parsed : 0;
setTemplates([
- {label: "Form template", value: 11}
+ { label: 'Form template', value: 11 }
])
storeSet.main.setAsyncRequest();
@@ -96,6 +164,7 @@ const BandoForms = () => {
+
@@ -124,16 +193,32 @@ const BandoForms = () => {
{__('Crea un nuovo Form da Zero', 'gepafin')}
-
{__('Inizia con un form completamente vuoto e personalizzabil', 'gepafin')}
+
{__('Inizia con un form completamente vuoto e personalizzabile', 'gepafin')}
+
+
{__('Duplica il form creato in precedenza', 'gepafin')}
+
setSelectedForDuplicateForm(e.value)}
+ options={forms}
+ optionLabel="label"
+ placeholder={__('Seleziona form', 'gepafin')}/>
+
+
-
+
{__('Modifica form esistente', 'gepafin')}
{__('Continua a lavorare su un form precedentemente salvato', 'gepafin')}
diff --git a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js
index 46618ee..a6ed4b5 100644
--- a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js
+++ b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js
@@ -50,7 +50,6 @@ const PreInstructorDomandeTable = () => {
const getFormattedData = (data) => {
return data.map((d) => {
d.callEndDate = is(String, d.callEndDate) ? new Date(d.callEndDate) : (d.callEndDate ? d.callEndDate : '');
- d.updatedDate = is(String, d.updatedDate) ? new Date(d.updatedDate) : (d.updatedDate ? d.updatedDate : '');
d.submissionDate = is(String, d.submissionDate) ? new Date(d.submissionDate) : (d.submissionDate ? d.submissionDate : '');
return d;
});
@@ -89,7 +88,7 @@ const PreInstructorDomandeTable = () => {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
},
- updatedDate : {
+ callEndDate : {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
}
@@ -114,8 +113,7 @@ const PreInstructorDomandeTable = () => {
};
const dateEndBodyTemplate = (rowData) => {
- //return formatDate(rowData.callEndDate);
- return '';
+ return formatDate(rowData.callEndDate);
};
const dateFilterTemplate = (options) => {
@@ -156,7 +154,7 @@ const PreInstructorDomandeTable = () => {
-
{
+const DomandaEditPreInstructor = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
const { id } = useParams();
const navigate = useNavigate();
const [data, setData] = useState({});
const [message, setMessage] = useState('');
- const pageMsgs = useRef(null);
+ const [isAdmissible, setIsAdmissible] = useState(false);
+ const toast = useRef(null);
const goToEvaluationsPage = () => {
navigate('/domande');
}
- /*const getCallback = (data) => {
+ const getCallback = (data) => {
if (data.status === 'SUCCESS') {
- setData(getFormattedBandiData(data.data));
+ setData(getFormattedData(data.data));
}
storeSet.main.unsetAsyncRequest();
}
const errGetCallback = (data) => {
- if (pageMsgs.current && data.message) {
- pageMsgs.current.show([
- {
- sticky: true, severity: 'error', summary: '',
- detail: data.message,
- closable: true
- }
- ]);
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
}
set404FromErrorResponse(data);
storeSet.main.unsetAsyncRequest();
- }*/
+ }
- /*const getFormattedBandiData = (data) => {
- data.dates = data.dates.map(v => is(String, v) ? new Date(v) : (v ? v : ''));
+ const getFormattedData = (data) => {
+ data.submissionDate = is(String, data.submissionDate) ? new Date(data.submissionDate) : (data.submissionDate ? data.submissionDate : '');
+ data.evaluationDate = is(String, data.evaluationDate) ? new Date(data.evaluationDate) : (data.evaluationDate ? data.evaluationDate : '');
return data;
- };*/
+ };
const renderHeader = () => {
return (
@@ -76,58 +85,69 @@ const DomandaEdit = () => {
const header = renderHeader();
+ const updateEvaluationValue = (value, path, maxValue) => {
+ let finalValue = value;
+
+ if (maxValue) {
+ finalValue = value > maxValue ? maxValue : value;
+ }
+
+ const newData = wrap(data).set(path.split('.'), finalValue).value();
+ setData(newData);
+ }
+
+ const doSaveDraft = () => {
+ const formData = {
+ criteria: klona(data.criteria),
+ checklist: klona(data.checklist),
+ files: klona(data.files),
+ note: data.note
+ }
+ ApplicationEvaluationService.updateEvaluation(id, formData, updateCallback, errUpdateCallback);
+ }
+
+ const updateCallback = (data) => {
+ if (data.status === 'SUCCESS') {
+ if (toast.current) {
+ toast.current.show({
+ severity: 'success',
+ summary: '',
+ detail: data.message
+ });
+ }
+ }
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ const errUpdateCallback = (data) => {
+ if (toast.current && data.message) {
+ toast.current.show({
+ severity: 'error',
+ summary: '',
+ detail: data.message
+ });
+ }
+ set404FromErrorResponse(data);
+ storeSet.main.unsetAsyncRequest();
+ }
+
+ useEffect(() => {
+ const maxScore = pathOr(0, ['minScore'], data);
+ const criteria = pathOr([], ['criteria'], data);
+ const scoreSum = sum(criteria.map(o => o.score));
+
+ setIsAdmissible(scoreSum !== 0 && scoreSum >= maxScore);
+ }, [data]);
+
useEffect(() => {
const parsed = parseInt(id)
const entityId = !isNaN(parsed) ? parsed : 0;
- setData({
- id: 'DOM_2024_001',
- callTitle: 'Innovazione 2024',
- beneficiario: 'Azienda Alpha SRL',
- createdAt: '2024-08-01',
- scadenzaAt: '2024-08-05',
- status: 'In Valutazione',
- criteria: [
- { title: 'Innovatività del progetto', score: 25, id: 12 },
- { title: 'Innovatività del progetto2', score: 35, id: 13 },
- { title: 'Innovatività del progetto3', score: 15, id: 14 }
- ],
- minScore: 60
- });
-
- //BandoService.getBando(entityId, getCallback, errGetCallback);
+ ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
+ ['assignedApplicationId', entityId]
+ ]);
}, [id]);
- // TODO
- const checklist = [
- {
- id: 1,
- title: 'Requisiti di ammissibilità soddisfatti'
- },
- {
- id: 2,
- title: 'Documentazione completa'
- },
- {
- id: 3,
- title: 'Obiettivi del progetto chiari e misurabili'
- }
- ];
- const documents = [
- {
- id: 1,
- title: 'Doc 1'
- },
- {
- id: 2,
- title: 'Bilancio ultimo esercizio Bilancio ultimo esercizio Bilancio ultimo esercizio'
- },
- {
- id: 3,
- title: 'Bilancio ultimo esercizio'
- }
- ];
-
return (
@@ -135,7 +155,8 @@ const DomandaEdit = () => {
-
+
+