Merge branch 'develop' into master-sync/fields-calc-feature
This commit is contained in:
@@ -53,6 +53,14 @@
|
||||
font-weight: 400;
|
||||
line-height: 21px;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/*&.selected {
|
||||
border-color: var(--menuitem-active-background);
|
||||
}*/
|
||||
|
||||
.meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -116,7 +124,7 @@
|
||||
border: 1px solid var(--button-secondary-borderColor);
|
||||
background-color: var(--button-secondary-borderColor);
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
padding: 20px 10px;
|
||||
opacity: 0.6;
|
||||
color: white;
|
||||
font-size: 11px;
|
||||
@@ -241,9 +249,13 @@
|
||||
|
||||
.formElementSettings__repeaterItem {
|
||||
display: grid;
|
||||
grid-template-columns: 4.5fr 2.4fr 1fr 1.4fr 0.7fr;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 12px;
|
||||
|
||||
&.tableRow {
|
||||
grid-template-columns: 4.5fr 2.4fr 1fr 1.4fr 0.7fr;
|
||||
}
|
||||
|
||||
> div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -43,6 +43,119 @@
|
||||
}
|
||||
}
|
||||
|
||||
.statsBigBadges__gridItemDoubleStats {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #858585;
|
||||
background: #cecece;
|
||||
align-items: center;
|
||||
gap: 32px;
|
||||
|
||||
span {
|
||||
color: #FFF;
|
||||
font-size: 18px;
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
line-height: normal;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
> span:first-of-type {
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
span.number {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.auxStats {
|
||||
display: flex;
|
||||
gap: 7px;
|
||||
align-items: flex-start;
|
||||
margin-top: auto;
|
||||
|
||||
span {
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
span.badge {
|
||||
display: inline-block;
|
||||
padding: 5px 10px;
|
||||
background-color: var(--card-full-background-color-4);
|
||||
border-radius: 4px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
&:nth-of-type(1) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-2);
|
||||
}
|
||||
|
||||
&:nth-of-type(2) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-3);
|
||||
}
|
||||
|
||||
&:nth-of-type(3) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-5);
|
||||
}
|
||||
|
||||
&:nth-of-type(4) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-7);
|
||||
}
|
||||
}
|
||||
|
||||
.statsBigBadges__gridItemDoubleStatsBeneficiary {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #858585;
|
||||
background: #cecece;
|
||||
align-items: center;
|
||||
gap: 32px;
|
||||
|
||||
span {
|
||||
color: #FFF;
|
||||
font-size: 18px;
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
line-height: normal;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
> span:first-of-type {
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
&:nth-of-type(1) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-2);
|
||||
}
|
||||
|
||||
&:nth-of-type(2) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-4);
|
||||
}
|
||||
|
||||
&:nth-of-type(3) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-3);
|
||||
}
|
||||
|
||||
&:nth-of-type(4) {
|
||||
border: 1px solid var(--yellow-500);
|
||||
background: var(--card-full-background-color-1);
|
||||
}
|
||||
}
|
||||
|
||||
.statsBigBadges__grid {
|
||||
.statsBigBadges__gridItem {
|
||||
&:nth-of-type(1) {
|
||||
@@ -109,11 +222,27 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.doubleStatsItems {
|
||||
grid-template-columns: repeat(4, minmax(220px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1290px) {
|
||||
.statsBigBadges__grid {
|
||||
&.doubleStatsItems {
|
||||
grid-template-columns: repeat(2, minmax(220px, 1fr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.statsBigBadges__grid {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
&.doubleStatsItems {
|
||||
grid-template-columns: minmax(220px, 1fr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
78
src/components/ChartDomandePerStato/index.js
Normal file
78
src/components/ChartDomandePerStato/index.js
Normal file
@@ -0,0 +1,78 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { Tooltip, ResponsiveContainer, Cell, Pie, PieChart, Legend } from 'recharts';
|
||||
import { isEmpty } from 'ramda';
|
||||
|
||||
// tools
|
||||
import getBandoLabel from '../../helpers/getBandoLabel';
|
||||
|
||||
|
||||
const ChartDomandePerStato = ({ title, data = [] }) => {
|
||||
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042', '#8884d8', '#82ca9d'];
|
||||
const [chartData, setChartData] = useState({});
|
||||
|
||||
const CustomTooltip = ({ active, payload }) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="chartCard__tooltip">
|
||||
<p className="chartCard__tooltipTitle">{getBandoLabel(payload[0].name)}</p>
|
||||
<p className="chartCard__tooltipText">
|
||||
{payload[0].name}: {payload[0].value}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const grouped = data.reduce((acc, cur) => {
|
||||
if (cur.status === 'APPROVED') {
|
||||
acc.approved.value = cur.numberOfApplication;
|
||||
} else if (cur.status === 'REJECTED') {
|
||||
acc.rejected.value = cur.numberOfApplication;
|
||||
} else {
|
||||
acc.inProgress.value += cur.numberOfApplication;
|
||||
}
|
||||
return acc;
|
||||
}, {
|
||||
inProgress: {value: 0, label: __('In corso', 'gepafin')},
|
||||
approved: {value: 0, label: __('Approvato', 'gepafin')},
|
||||
rejected: {value: 0, label: __('Respinto', 'gepafin')}
|
||||
});
|
||||
setChartData(grouped)
|
||||
}, [data]);
|
||||
|
||||
return (<div className="chartCard">
|
||||
{title ? <span className="chartCard__title">{title}</span> : null}
|
||||
{chartData && !isEmpty(chartData)
|
||||
? <div className="chartCard__chart">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<PieChart>
|
||||
<Pie
|
||||
data={Object.values(chartData)}
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
labelLine={false}
|
||||
label={({ percent }) => `${(percent * 100).toFixed(0)}%`}
|
||||
outerRadius={120}
|
||||
fill="#8884d8"
|
||||
dataKey="value"
|
||||
nameKey="label"
|
||||
>
|
||||
{Object.values(chartData).map((entry, index) => (
|
||||
<Cell
|
||||
key={`cell-${index}`}
|
||||
fill={COLORS[index % COLORS.length]}
|
||||
/>
|
||||
))}
|
||||
</Pie>
|
||||
<Tooltip content={<CustomTooltip />} />
|
||||
<Legend verticalAlign="top" height={36}/>
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
</div> : null}
|
||||
</div>)
|
||||
}
|
||||
|
||||
export default ChartDomandePerStato;
|
||||
56
src/components/ChartRichiesteVsApprovate/index.js
Normal file
56
src/components/ChartRichiesteVsApprovate/index.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
||||
import { isEmpty } from 'ramda';
|
||||
|
||||
// components
|
||||
|
||||
|
||||
const ChartRichiesteVsApprovate = ({ title, data = [] }) => {
|
||||
|
||||
// Custom tooltip
|
||||
const CustomTooltip = ({ active, payload, label }) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="chartCard__tooltip">
|
||||
<p className="chartCard__tooltipTitle">{label}</p>
|
||||
<p className="chartCard__tooltipText">
|
||||
{__('In bozza', 'gepafin')}: {payload[0].value}
|
||||
</p>
|
||||
<p className="chartCard__tooltipText">
|
||||
{__('Inviate', 'gepafin')}: {payload[1].value}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
return (<div className="chartCard">
|
||||
{title ? <span className="chartCard__title">{title}</span> : null}
|
||||
{data && !isEmpty(data)
|
||||
? <div className="chartCard__chart">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<BarChart
|
||||
data={data}
|
||||
margin={{
|
||||
top: 20,
|
||||
right: 30,
|
||||
left: 20,
|
||||
bottom: 60,
|
||||
}}
|
||||
>
|
||||
<CartesianGrid strokeDasharray="3 3"/>
|
||||
<XAxis dataKey="month"/>
|
||||
<YAxis/>
|
||||
<Tooltip content={<CustomTooltip/>}/>
|
||||
<Legend/>
|
||||
<Bar dataKey="totalRequested" fill="#8884d8" stackId="a" name={__('Richiesti', 'gepafin')}/>
|
||||
<Bar dataKey="totalApproved" fill="#EEC137" stackId="a" name={__('Approvati', 'gepafin')}/>
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
</div> : null}
|
||||
</div>)
|
||||
}
|
||||
|
||||
export default ChartRichiesteVsApprovate;
|
||||
@@ -1,4 +1,4 @@
|
||||
import { head, isNil, pathOr } from 'ramda';
|
||||
import { head, is, isNil, pathOr } from 'ramda';
|
||||
import getNumberFormatted from '../../../../../../../helpers/getNumberFormatted';
|
||||
|
||||
const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) => {
|
||||
@@ -9,7 +9,7 @@ const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) =
|
||||
cellValue = pathOr(0, ['total'], tableValue);
|
||||
}
|
||||
|
||||
return <td>{getNumberFormatted(cellValue)}</td>;
|
||||
return <td>{is(Number, cellValue) ? getNumberFormatted(cellValue) : cellValue}</td>;
|
||||
};
|
||||
|
||||
export default LastRowCell;
|
||||
@@ -7,7 +7,7 @@ import { isEmpty } from 'ramda';
|
||||
import DefaultCell from './components/DefaultCell';
|
||||
import LastRowCell from './components/LastRowCell';
|
||||
|
||||
const RenderTable = ({ rowsData, columnsCfg, lastRowCfg, setRowsFn, disabled }) => {
|
||||
const RenderTable = ({ rowsData = [], columnsCfg, lastRowCfg, setRowsFn, disabled }) => {
|
||||
const table = useReactTable({
|
||||
data: rowsData,
|
||||
columns: columnsCfg,
|
||||
|
||||
@@ -122,13 +122,13 @@ const Table = ({
|
||||
|
||||
useEffect(() => {
|
||||
const stateFieldData = pathOr([], ['stateFieldData'], tableColumns);
|
||||
const obj = stateFieldData
|
||||
/*const obj = stateFieldData
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur.name] = ''
|
||||
return acc;
|
||||
}, {});
|
||||
let rowsData = pathOr([obj], ['rowsData'], tableColumns);
|
||||
rowsData = isEmpty(rowsData) ? [obj] : rowsData;
|
||||
}, {});*/
|
||||
let rowsData = pathOr([], ['rowsData'], tableColumns);
|
||||
//rowsData = isEmpty(rowsData) ? [obj] : rowsData;
|
||||
setColumnsCfg(stateFieldData);
|
||||
setRowsCfg(rowsData);
|
||||
|
||||
@@ -169,7 +169,8 @@ const Table = ({
|
||||
{label}{config.required || config.isRequired || (config.validate && config.validate.nonEmptyTables)
|
||||
? <span className="appForm__field--required">*</span> : null}
|
||||
</label>
|
||||
{rows ? <RenderTable
|
||||
{rows
|
||||
? <RenderTable
|
||||
columnsCfg={columns}
|
||||
rowsData={rows}
|
||||
lastRowCfg={lastRow}
|
||||
|
||||
@@ -59,6 +59,9 @@ const getBandoLabel = (status) => {
|
||||
case 'CLOSE':
|
||||
return __('Chiuso', 'gepafin');
|
||||
|
||||
case 'REJECTED':
|
||||
return __('Respinto', 'gepafin');
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ const getBandoSeverity = (status) => {
|
||||
case 'CLOSE':
|
||||
return 'closed';
|
||||
|
||||
case 'REJECTED':
|
||||
return 'danger';
|
||||
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
|
||||
10
src/helpers/isDateTimeInFuture.js
Normal file
10
src/helpers/isDateTimeInFuture.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const isDateTimeInFuture = (dateStr, timeStr) => {
|
||||
const [hours, minutes, seconds = 0] = timeStr.split(':').map(Number);
|
||||
const dateTime = new Date(dateStr);
|
||||
dateTime.setHours(hours, minutes, seconds);
|
||||
const now = new Date();
|
||||
|
||||
return dateTime > now;
|
||||
}
|
||||
|
||||
export default isDateTimeInFuture;
|
||||
@@ -132,11 +132,11 @@ const AppSidebar = () => {
|
||||
enable: false
|
||||
},
|
||||
{
|
||||
label: __('Report e Analisi', 'gepafin'),
|
||||
label: __('Statistiche', 'gepafin'),
|
||||
icon: 'pi pi-chart-bar',
|
||||
//href: '/stats',
|
||||
href: '/stats',
|
||||
id: 15,
|
||||
enable: false
|
||||
enable: intersection(permissions, ['APPLY_CALLS']).length
|
||||
},
|
||||
{
|
||||
label: __('Log di Sistema', 'gepafin'),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect} from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { is, uniq, isNil, isEmpty } from 'ramda';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
@@ -30,6 +30,8 @@ import { Button } from 'primereact/button';
|
||||
// i18n
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
import isDateTimeInPast from '../../../../helpers/isDateTimeInPast';
|
||||
import isDateTimeInFuture from '../../../../helpers/isDateTimeInFuture';
|
||||
import { Badge } from 'primereact/badge';
|
||||
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
@@ -182,18 +184,22 @@ const AllBandiAccordion = ({ showOnlyPreferred = false }) => {
|
||||
|
||||
const rowExpansionTemplate = (data) => {
|
||||
const isCallExpired = isDateTimeInPast(data.dates[1], data.endTime);
|
||||
const isCallScheduled = isDateTimeInFuture(data.dates[0], data.startTime);
|
||||
|
||||
return (
|
||||
<div className="p-3">
|
||||
{renderHtmlContent(data.descriptionShort)}
|
||||
<p>{__('Scadenza', 'gepafin')}: {getDateFromISOstring(data.dates[1])}</p>
|
||||
{!isCallExpired && !isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && (!data.confidi
|
||||
{!isCallExpired && !isCallScheduled && !isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && (!data.confidi
|
||||
|| (data.confidi && data.id === 6 && REACT_APP_HUB_ID === 'p4lk3bcx1RStqTaIVVbXs'))
|
||||
? <Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{__('Partecipa', 'gepafin')}
|
||||
</Button> : null}
|
||||
{isCallExpired
|
||||
? <p>{__('È scaduto', 'gepafin')}</p> : null}
|
||||
{isCallExpired || (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && data.confidi
|
||||
? <p><Badge value={__('È scaduto', 'gepafin')} severity="danger"></Badge></p> : null}
|
||||
{isCallScheduled
|
||||
? <p><Badge value={sprintf(__('È programmato. Inizia: %s %s', 'gepafin'), getDateFromISOstring(data.dates[0]), data.startTime)}></Badge></p> : null}
|
||||
{isCallExpired || isCallScheduled || (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && data.confidi
|
||||
&& (data.id !== 6 || (data.id === 6 && REACT_APP_HUB_ID !== 'p4lk3bcx1RStqTaIVVbXs')))
|
||||
? <Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{__('Mostra', 'gepafin')}
|
||||
|
||||
@@ -685,7 +685,10 @@ const BandoApplication = () => {
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
//console.log('validations', validations, o.name)
|
||||
|
||||
/*if (o.name === 'table') {
|
||||
console.log('value:', values[o.id] ? values[o.id] : '')
|
||||
}*/
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div key={o.id}>
|
||||
@@ -695,6 +698,7 @@ const BandoApplication = () => {
|
||||
</div>
|
||||
: <FormField
|
||||
key={o.id}
|
||||
disabled={isExpired}
|
||||
readOnly={formula && !isEmpty(formula.value)}
|
||||
type={o.name}
|
||||
fieldName={o.id}
|
||||
|
||||
@@ -27,6 +27,9 @@ import { storeSet } from '../../../../store';
|
||||
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
||||
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
|
||||
import formatDateString from '../../../../helpers/formatDateString';
|
||||
import EvaluationFormsService from '../../../../service/evaluation-forms-service';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, getFormErrors, status }, ref) {
|
||||
const navigate = useNavigate();
|
||||
@@ -50,7 +53,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
const values = getValues();
|
||||
const toast = useRef(null);
|
||||
|
||||
const onSubmit = () => {};
|
||||
const onSubmit = () => {
|
||||
};
|
||||
|
||||
const onSaveDraft = () => {
|
||||
trigger();
|
||||
@@ -115,7 +119,12 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
}
|
||||
const values = getValues();
|
||||
if (!values.id && data.data.id) {
|
||||
navigate(`/bandi/${data.data.id}`);
|
||||
storeSet.main.setAsyncRequest();
|
||||
const sampleFormData = {
|
||||
label: `Evaluation form for call #${data.data.id}`,
|
||||
content: []
|
||||
}
|
||||
EvaluationFormsService.createFormForCall(data.data.id, sampleFormData, createFormCallback, errCreateFormCallback)
|
||||
} else {
|
||||
setFormInitialData(data.data);
|
||||
setInitialData(data.data);
|
||||
@@ -135,6 +144,18 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const createFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
navigate(`/bandi/${resp.data.callId}`);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errCreateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
navigate(`/bandi/${values.id}/preview`);
|
||||
}
|
||||
@@ -180,7 +201,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
![
|
||||
'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold',
|
||||
'aimedTo', 'criteria', 'docs', 'checklist', 'faq', 'amount', 'amountMin', 'amountMax',
|
||||
'email', 'phoneNumber', 'checkList', 'images'
|
||||
'email', 'phoneNumber', 'checkList', 'images', 'numberOfCheck', 'productId'
|
||||
].includes(fieldName)
|
||||
}
|
||||
|
||||
@@ -459,6 +480,35 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="appForm__cols">
|
||||
<FormField
|
||||
type="numberinput"
|
||||
disabled={shouldDisableField('numberOfCheck')}
|
||||
fieldName="numberOfCheck"
|
||||
label={__('Quantità dei checklist per creare un soccorso', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
defaultValue={values['numberOfCheck']}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
}}
|
||||
/>
|
||||
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <FormField
|
||||
type="numberinput"
|
||||
disabled={shouldDisableField('productId')}
|
||||
fieldName="productId"
|
||||
label={__('Prodotto ID dentro Odessa', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
defaultValue={values['productId']}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
}}
|
||||
/> : null}
|
||||
</div>
|
||||
|
||||
<FormFieldRepeaterFaq
|
||||
data={values['faq']}
|
||||
disabled={shouldDisableField('faq')}
|
||||
|
||||
@@ -94,7 +94,11 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
delete formData.endDate;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
if (values.evaluationVersion === 'V1') {
|
||||
BandoService.updateBandoStep2(formData.id, formData, createCallback, errCreateCallback);
|
||||
} else if (values.evaluationVersion === 'V2') {
|
||||
BandoService.updateBandoStep2V2(formData.id, formData, createCallback, errCreateCallback);
|
||||
}
|
||||
}
|
||||
|
||||
const createCallback = (data) => {
|
||||
@@ -221,7 +225,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
return (
|
||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||
<UnsavedChangesDetector getValuesFn={getValues}/>
|
||||
<FormFieldRepeaterCriteria
|
||||
{values.evaluationVersion === 'V1'
|
||||
? <FormFieldRepeaterCriteria
|
||||
data={values}
|
||||
disabled={shouldDisableField('criteria')}
|
||||
setDataFn={setValue}
|
||||
@@ -238,7 +243,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
.filter(o => isEmpty(o.value) || isEmpty(o.score)).length === 0
|
||||
|| __('Non lasciare il valore vuoto', 'gepafin')
|
||||
}
|
||||
}}/>
|
||||
}}/> : null}
|
||||
|
||||
<FormField
|
||||
type="fileuploadasync"
|
||||
@@ -275,7 +280,8 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
multiple={false}
|
||||
/>
|
||||
|
||||
<FormFieldRepeater
|
||||
{values.evaluationVersion === 'V1'
|
||||
? <FormFieldRepeater
|
||||
data={values['checkList']}
|
||||
disabled={shouldDisableField('checkList')}
|
||||
setDataFn={setValue}
|
||||
@@ -292,7 +298,7 @@ const BandoEditFormStep2 = forwardRef(function ({ initialData, setInitialData, g
|
||||
.filter(o => isEmpty(o.value)).length === 0 || __('Non lasciare il valore vuoto', 'gepafin')
|
||||
}
|
||||
}}
|
||||
/>
|
||||
/> : null}
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
|
||||
149
src/pages/BandoEdit/components/BandoEditFormStep3/index.js
Normal file
149
src/pages/BandoEdit/components/BandoEditFormStep3/index.js
Normal file
@@ -0,0 +1,149 @@
|
||||
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { klona } from 'klona';
|
||||
import { DndProvider } from 'react-dnd';
|
||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
|
||||
// api
|
||||
import EvaluationFormsService from '../../../../service/evaluation-forms-service';
|
||||
import FormsService from '../../../../service/forms-service';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse';
|
||||
|
||||
// components
|
||||
import BandoEditFormActions from '../BandoEditFormActions';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import FormBuilder from '../../../BandoFormsEdit/components/FormBuilder';
|
||||
//import { elementItems } from '../../../../tempData';
|
||||
|
||||
|
||||
const BandoEditFormStep3 = forwardRef(function () {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams();
|
||||
const [formName, setFormName] = useState('');
|
||||
const [bandoStatus, setBandoStatus] = useState('');
|
||||
const toast = useRef(null);
|
||||
|
||||
const getBandoId = () => {
|
||||
const parsed = parseInt(id)
|
||||
return !isNaN(parsed) ? parsed : 0;
|
||||
}
|
||||
|
||||
const onSaveDraft = () => {
|
||||
const content = storeGet.main.formElements();
|
||||
const formId = storeGet.main.formId();
|
||||
const formData = {
|
||||
label: formName,
|
||||
content
|
||||
}
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
EvaluationFormsService.updateForm(formId, formData, updateFormCallback, errUpdateFormCallback)
|
||||
}
|
||||
|
||||
const updateFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setBandoStatus(resp.data.callStatus);
|
||||
if (toast.current) {
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: '',
|
||||
detail: __('Il bando è stato aggiornato correttamente!', 'gepafin')
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errUpdateFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const openPreview = () => {
|
||||
const bandoId = getBandoId();
|
||||
navigate(`/bandi/${bandoId}/preview`);
|
||||
}
|
||||
|
||||
const openPreviewEvaluation = () => {
|
||||
const bandoId = getBandoId();
|
||||
navigate(`/bandi/${bandoId}/preview-evaluation`);
|
||||
}
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetElementItemsCallbacks = (data) => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getFormCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
storeSet.main.formId(resp.data.id);
|
||||
storeSet.main.formLabel(resp.data.label);
|
||||
setFormName(resp.data.label);
|
||||
setBandoStatus(resp.data.callStatus);
|
||||
const elements = klona(resp.data.content);
|
||||
storeSet.main.formElements(elements);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetFormCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
EvaluationFormsService.getFormForCall(id, getFormCallback, errGetFormCallback)
|
||||
}, [id]);
|
||||
|
||||
useEffect(() => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
|
||||
return () => {
|
||||
storeSet.main.formId(0);
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="appForm">
|
||||
<div className="appPageSection">
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<FormBuilder callStatus={bandoStatus} context="call"/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<Toast ref={toast} />
|
||||
<BandoEditFormActions
|
||||
id={id}
|
||||
status={bandoStatus}
|
||||
submitFn={onSaveDraft}
|
||||
openPreview={openPreview}
|
||||
openPreviewEvaluation={openPreviewEvaluation}/>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
export default BandoEditFormStep3;
|
||||
@@ -23,6 +23,7 @@ import { Messages } from 'primereact/messages';
|
||||
import FormsService from '../../service/forms-service';
|
||||
import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import BandoEditFormStep3 from './components/BandoEditFormStep3';
|
||||
|
||||
const BandoEdit = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
@@ -35,7 +36,8 @@ const BandoEdit = () => {
|
||||
const bandoMsgs = useRef(null);
|
||||
const toast = useRef(null);
|
||||
|
||||
const stepItems = [
|
||||
const stepItems = (evalProcessVer) => {
|
||||
let steps = [
|
||||
{
|
||||
label: __('Testi', 'gepafin'),
|
||||
command: () => {
|
||||
@@ -58,6 +60,22 @@ const BandoEdit = () => {
|
||||
}
|
||||
];
|
||||
|
||||
if (evalProcessVer === 'V2') {
|
||||
steps.push({
|
||||
label: __('Valutazione', 'gepafin'),
|
||||
command: () => {
|
||||
if (activeStep === 2) {
|
||||
return false
|
||||
}
|
||||
bandoMsgs.current.clear();
|
||||
goToStep(2);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
const goToStep = (step) => {
|
||||
setActiveStep(step);
|
||||
}
|
||||
@@ -238,7 +256,8 @@ const BandoEdit = () => {
|
||||
|
||||
if (bandoId === 0) {
|
||||
setData({
|
||||
status: null
|
||||
status: null,
|
||||
evaluationVersion: 'V2'
|
||||
});
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
|
||||
@@ -274,7 +293,7 @@ const BandoEdit = () => {
|
||||
|
||||
{!isEmpty(data)
|
||||
? <Steps
|
||||
model={stepItems}
|
||||
model={stepItems(data.evaluationVersion)}
|
||||
activeIndex={activeStep}
|
||||
readOnly={isNil(data.status)}/>
|
||||
: null}
|
||||
@@ -293,6 +312,9 @@ const BandoEdit = () => {
|
||||
{activeStep === 1
|
||||
? <BandoEditFormStep2 initialData={data} setInitialData={setData} ref={formRef} status={data.status}/>
|
||||
: null}
|
||||
{activeStep === 2 && data.evaluationVersion === 'V2'
|
||||
? <BandoEditFormStep3/>
|
||||
: null}
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Crea o modifica il Form compilabile dal Beneficiario', 'gepafin')}</h2>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useDrag, useDrop } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import uniqid from '../../../../helpers/uniqid';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
import { Tag } from 'primereact/tag';
|
||||
@@ -14,11 +18,14 @@ import BuilderElementProperLabel from '../BuilderElementProperLabel';
|
||||
|
||||
const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const draggingElementId = useStore().main.draggingElementId();
|
||||
const selectedElement = useStore().main.selectedElement();
|
||||
const ref = useRef(null);
|
||||
const elements = useStore().main.formElements();
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
const [isFormula, setIsFormula] = useState('secondary');
|
||||
const [variableName, setVariableName] = useState('secondary');
|
||||
const [formulaName, setFormulaName] = useState('secondary');
|
||||
const [isRequestedAmount, setIsRequestedAmount] = useState(false);
|
||||
const [isDelegation, setIsDelegation] = useState(false);
|
||||
|
||||
@@ -93,11 +100,33 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
storeSet.main.moveElement(dragIndex, hoverIndex, item);
|
||||
}
|
||||
|
||||
const openSettings = (id) => {
|
||||
const openSettings = () => {
|
||||
storeSet.main.activeElement(id);
|
||||
}
|
||||
|
||||
const remove = (id) => {
|
||||
const selectElement = () => {
|
||||
storeSet.main.selectedElement(id);
|
||||
}
|
||||
|
||||
const duplicateElement = useCallback(() => {
|
||||
const duplicatedElement = head(elements.filter(o => o.id === id));
|
||||
|
||||
if (duplicatedElement) {
|
||||
const copyElement = klona(duplicatedElement);
|
||||
copyElement.settings = copyElement.settings.map((o) => {
|
||||
if (o.name === 'label') {
|
||||
o.value = `Copy - ${o.value}`
|
||||
}
|
||||
return o;
|
||||
})
|
||||
copyElement.id = uniqid();
|
||||
const originalIndex = elements.map(o => o.id).indexOf(id);
|
||||
const newElements = [...elements].toSpliced(originalIndex + 1, 0, copyElement);
|
||||
storeSet.main.formElements(newElements);
|
||||
}
|
||||
}, [elements]);
|
||||
|
||||
const remove = () => {
|
||||
storeSet.main.removeElement(id);
|
||||
}
|
||||
|
||||
@@ -112,10 +141,12 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
setIsVariable('warning');
|
||||
setVariableName(variable.value)
|
||||
}
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
setIsFormula('warning');
|
||||
setFormulaName(formula.value)
|
||||
}
|
||||
|
||||
if (isRequestedAmount && !isEmpty(isRequestedAmount.value) && isRequestedAmount.value) {
|
||||
@@ -132,14 +163,18 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
? <div ref={ref} className="formBuilder__elementNew">
|
||||
{__('lascia qui', 'gepafin')}
|
||||
</div>
|
||||
: <div ref={ref} className="formBuilder__element" style={{ opacity }} data-handler-id={handlerId}>
|
||||
: <div ref={ref}
|
||||
className={`formBuilder__element${selectedElement === id ? ' selected' : ''}`}
|
||||
style={{ opacity }}
|
||||
onClick={selectElement}
|
||||
data-handler-id={handlerId}>
|
||||
<div className="meta">
|
||||
<div className="tagHeader">
|
||||
<Tag value={label} severity="info"/>
|
||||
{['numberinput', 'criteria_table'].includes(name)
|
||||
? <Tag value="var" severity={isVariable}/> : null}
|
||||
? <Tag value="var" severity={isVariable} title={variableName}/> : null}
|
||||
{name === 'numberinput'
|
||||
? <Tag value="f(x)" severity={isFormula}/> : null}
|
||||
? <Tag value="f(x)" severity={isFormula} title={formulaName}/> : null}
|
||||
{isRequestedAmount
|
||||
? <Tag value="importo" severity={isRequestedAmount}/> : null}
|
||||
{isDelegation
|
||||
@@ -148,8 +183,9 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<Button icon="pi pi-cog" onClick={() => openSettings(id)} outlined severity="info"/>
|
||||
<Button icon="pi pi-trash" disabled={bandoStatus === 'PUBLISH'} onClick={() => remove(id)} outlined severity="danger"/>
|
||||
<Button icon="pi pi-clone" onClick={duplicateElement} outlined severity="success"/>
|
||||
<Button icon="pi pi-cog" onClick={openSettings} outlined severity="info"/>
|
||||
<Button icon="pi pi-trash" disabled={bandoStatus === 'PUBLISH'} onClick={remove} outlined severity="danger"/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -36,7 +36,8 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
table_columns: '',
|
||||
criteria_table_columns: '',
|
||||
variable: __('Variabile (lettere, cifre e "_"; il primo carattere deve essere una lettera!)', 'gepafin'),
|
||||
formula: __('Formula di calcolo automatico', 'gepafin')
|
||||
formula: __('Formula di calcolo automatico', 'gepafin'),
|
||||
isChecklistItem: __('Fa parte di "checklist"?', 'gepafin'),
|
||||
}
|
||||
|
||||
const settingDescription = {
|
||||
@@ -104,7 +105,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
name={setting.name}
|
||||
bandoStatus={bandoStatus}
|
||||
setDataFn={updateDataFn}/>
|
||||
} else if (['isRequestedAmount', 'isDelegation'].includes(setting.name)) {
|
||||
} else if (['isRequestedAmount', 'isDelegation', 'isChecklistItem'].includes(setting.name)) {
|
||||
return <InputSwitch
|
||||
checked={setting.value}
|
||||
onChange={(e) => changeFn(e.value, setting.name)}/>
|
||||
|
||||
@@ -277,14 +277,14 @@ const ElementSettingCriteriaTableColumns = ({
|
||||
<>
|
||||
<div className="formElementSettings__repeater">
|
||||
{stateFieldData.length > 0
|
||||
? <div className="formElementSettings__repeaterItem">
|
||||
? <div className="formElementSettings__repeaterItem tableRow">
|
||||
<div>{__('Colonne', 'gepafin')}</div>
|
||||
<div>{__('Tipo', 'gepafin')}</div>
|
||||
<div>{__('Calcola', 'gepafin')}</div>
|
||||
<div>{__('Predefinito?', 'gepafin')}</div>
|
||||
<div></div>
|
||||
</div> : null}
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem">
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem tableRow">
|
||||
{properFields(o, i)}
|
||||
</div>)}
|
||||
<Button
|
||||
|
||||
@@ -268,14 +268,14 @@ const ElementSettingTableColumns = ({
|
||||
<>
|
||||
<div className="formElementSettings__repeater">
|
||||
{stateFieldData.length > 0
|
||||
? <div className="formElementSettings__repeaterItem">
|
||||
? <div className="formElementSettings__repeaterItem tableRow">
|
||||
<div>{__('Colonne', 'gepafin')}</div>
|
||||
<div>{__('Tipo', 'gepafin')}</div>
|
||||
<div>{__('Calcola', 'gepafin')}</div>
|
||||
<div>{__('Predefinito?', 'gepafin')}</div>
|
||||
<div></div>
|
||||
</div> : null}
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem">
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem tableRow">
|
||||
{properFields(o, i)}
|
||||
</div>)}
|
||||
<Button
|
||||
|
||||
@@ -19,7 +19,7 @@ import { MultiSelect } from 'primereact/multiselect';
|
||||
|
||||
import { dynamicDataOptions } from '../../../../configData';
|
||||
|
||||
const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
const BuilderElementSettings = ({ closeSettingsFn, callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
const criteriaOptions = useStore().main.bandoCriteria();
|
||||
@@ -123,6 +123,10 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
});
|
||||
}
|
||||
|
||||
settings = settings.filter(o => context === 'call'
|
||||
? !['isRequestedAmount', 'isDelegation', ''].includes(o.name)
|
||||
: !['isChecklistItem'].includes(o.name));
|
||||
|
||||
if (chosen) {
|
||||
setActiveElementData(klona(chosen));
|
||||
setSettings(settings);
|
||||
@@ -149,11 +153,11 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
.map((o) => <ElementSetting
|
||||
key={o.name}
|
||||
setting={o}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
changeFn={onChange}
|
||||
updateDataFn={onUpdateOptions}/>)
|
||||
: null}
|
||||
{!isNil(dynamicDataOptions[activeElementData.name])
|
||||
{!isNil(dynamicDataOptions[activeElementData.name]) && context === 'application'
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor="dynamicData">{__('Dati dinamici', 'gepafin')}</label>
|
||||
<Dropdown
|
||||
@@ -220,7 +224,8 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
</div> : null}
|
||||
</div>) : null}
|
||||
</TabPanel> : null}
|
||||
<TabPanel header={__('Criteri', 'gepafin')}>
|
||||
{context === 'application'
|
||||
? <TabPanel header={__('Criteri', 'gepafin')}>
|
||||
<div className="formElementSettings__field">
|
||||
<label htmlFor="criteria">{__('Criteri di valutazione', 'gepafin')}</label>
|
||||
<MultiSelect
|
||||
@@ -233,7 +238,7 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
display="chip"
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
</div>
|
||||
</TabPanel>
|
||||
</TabPanel> : null}
|
||||
{settings
|
||||
&& settings
|
||||
.filter(o => ['variable', 'formula'].includes(o.name)).length > 0
|
||||
@@ -244,7 +249,7 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
.map((o) => <ElementSetting
|
||||
key={o.name}
|
||||
setting={o}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
changeFn={onChange}
|
||||
updateDataFn={onUpdateOptions}/>)
|
||||
: null}
|
||||
|
||||
@@ -13,7 +13,7 @@ import BuilderElementSettings from '../BuilderElementSettings';
|
||||
import BuilderDropzone from '../BuilderDropzone';
|
||||
import BlockingOverlay from '../../../../components/BlockingOverlay';
|
||||
|
||||
const FormBuilder = ({ bandoStatus }) => {
|
||||
const FormBuilder = ({ callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const elementItems = useStore().main.elementItems();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
@@ -27,10 +27,10 @@ const FormBuilder = ({ bandoStatus }) => {
|
||||
id={field.id}
|
||||
label={field.label}
|
||||
name={field.name}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
/>
|
||||
)
|
||||
}, [bandoStatus]);
|
||||
}, [callStatus]);
|
||||
|
||||
const renderItem = useCallback((item) => {
|
||||
return (
|
||||
@@ -58,7 +58,9 @@ const FormBuilder = ({ bandoStatus }) => {
|
||||
<>
|
||||
<Sidebar visible={!isEmpty(activeElement)} onHide={closeSettings} dismissable={false} className="formBuilder__elementSettings">
|
||||
<h2>{__('Impostazioni del campo modulo', 'gepafin')}</h2>
|
||||
{!isEmpty(activeElement) ? <BuilderElementSettings closeSettingsFn={closeSettings} bandoStatus={bandoStatus}/> : null}
|
||||
{!isEmpty(activeElement)
|
||||
? <BuilderElementSettings closeSettingsFn={closeSettings} callStatus={callStatus} context={context}/>
|
||||
: null}
|
||||
</Sidebar>
|
||||
<div className="formBuilder">
|
||||
<div className="formBuilder__main">
|
||||
|
||||
@@ -24,7 +24,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import BandoService from '../../service/bando-service';
|
||||
|
||||
// TODO temp data
|
||||
import { elementItems } from '../../tempData';
|
||||
//import { elementItems } from '../../tempData';
|
||||
|
||||
const BandoFormsEdit = () => {
|
||||
const { id, formId } = useParams();
|
||||
@@ -110,7 +110,6 @@ const BandoFormsEdit = () => {
|
||||
|
||||
const formCreateCallback = (data, shouldRedirect) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
const bandoId = getBandoId();
|
||||
if (shouldRedirect) {
|
||||
navigate(`/bandi/${bandoId}/forms/${data.data.id}/preview`);
|
||||
@@ -127,6 +126,7 @@ const BandoFormsEdit = () => {
|
||||
});
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errFormCreateCallback = (data) => {
|
||||
@@ -215,13 +215,15 @@ const BandoFormsEdit = () => {
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(data.data
|
||||
.filter(o => o.id !== 22)
|
||||
.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetElementItemsCallbacks = (data) => {
|
||||
const errGetElementItemsCallback = () => {
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -261,7 +263,7 @@ const BandoFormsEdit = () => {
|
||||
const bandoFormId = !isNaN(parsedFormId) ? parsedFormId : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallbacks);
|
||||
FormsService.getElementItems(getElementItemsCallback, errGetElementItemsCallback);
|
||||
|
||||
if (bandoFormId) {
|
||||
storeSet.main.setAsyncRequest();
|
||||
@@ -276,6 +278,8 @@ const BandoFormsEdit = () => {
|
||||
storeSet.main.formLabel('');
|
||||
storeSet.main.formElements([]);
|
||||
storeSet.main.bandoCriteria([]);
|
||||
storeSet.main.activeElement('');
|
||||
storeSet.main.selectedElement('');
|
||||
}
|
||||
}, [id, formId]);
|
||||
|
||||
@@ -317,7 +321,7 @@ const BandoFormsEdit = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<FormBuilder bandoStatus={bandoStatus}/>
|
||||
<FormBuilder callStatus={bandoStatus} context="application"/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ import getNumberWithCurrency from '../../helpers/getNumberWithCurrency';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
import isDateTimeInPast from '../../helpers/isDateTimeInPast';
|
||||
|
||||
// api
|
||||
import BandoService from '../../service/bando-service';
|
||||
import FaqItemService from '../../service/faq-item-service';
|
||||
import ApplicationService from '../../service/application-service';
|
||||
import PreferredBandoService from '../../service/preferred-bando-service';
|
||||
|
||||
// components
|
||||
import { Skeleton } from 'primereact/skeleton';
|
||||
@@ -28,8 +30,6 @@ import { Message } from 'primereact/message';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import { Editor } from 'primereact/editor';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import PreferredBandoService from '../../service/preferred-bando-service';
|
||||
import isDateTimeInPast from '../../helpers/isDateTimeInPast';
|
||||
|
||||
const REACT_APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ const Dashboard = () => {
|
||||
currency: 'EUR',
|
||||
currencyDisplay: 'symbol'
|
||||
}}
|
||||
locales="en-US"/></span>
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,12 +31,14 @@ const DashboardPreInstructor = () => {
|
||||
|
||||
const errGetStats = () => {}
|
||||
|
||||
const getStatValue = (key, fallback = '') => {
|
||||
return pathOr(fallback, [key], mainStats);
|
||||
const getStatValue = (keys = [], fallback = '') => {
|
||||
return pathOr(fallback, keys, mainStats);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
DashboardService.getEvaluationsStats(getStats, errGetStats);
|
||||
DashboardService.getInstructorAmendmentsStats(getStats, errGetStats, [
|
||||
['userId', userData.id]
|
||||
]);
|
||||
}, []);
|
||||
|
||||
return(
|
||||
@@ -49,49 +51,57 @@ const DashboardPreInstructor = () => {
|
||||
|
||||
<div className="appPageSection statsBigBadges">
|
||||
<h2>{__('Riepilogo', 'gepafin')}</h2>
|
||||
<div className="statsBigBadges__grid applStats">
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Totale domande', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfAssignedApplication', 0)}
|
||||
<div className="statsBigBadges__grid doubleStatsItems">
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Domande da valutare', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['assignedApplication', 'totalAssignedApplication'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span
|
||||
className="badge">{getStatValue(['assignedApplication', 'additionalApplicationPercentage'], 0)}%</span>
|
||||
{__('da ieri', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('In soccorso', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationInAmendmentState', 0)}
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Domande valutate', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['evaluatedApplication', 'evaluatedApplication'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span
|
||||
className="badge">{getStatValue(['evaluatedApplication', 'dailyAverage'], 0)}</span>
|
||||
{__('media giornaliera', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('In valutazione', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationInOpenState', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Completate', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationInCloseState', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Tempo medio di valutazione', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('averageEvaluationDays', 0)}
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Tempo medio valutazione', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['averageEvaluationDays', 'averageEvlauationDaysRating'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
suffix={` ${__('giorni', 'gepafin')}`}
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span className="badge">{getStatValue(['averageEvaluationDays', 'timeDifferenceFromAverage'], 0)}</span>
|
||||
{__('rispetto alla media', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItem">
|
||||
<span>{__('Domande in scadenza (48h)', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('numberOfApplicationExpiringIn48Hours', 0)}
|
||||
<div className="statsBigBadges__gridItemDoubleStats">
|
||||
<span>{__('Soccorsi istruttori in corso', 'gepafin')}</span>
|
||||
<span className="number"><NumberFlow
|
||||
value={getStatValue(['amendmentInProgress', 'totalAmendmentInProgress'], 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="en-US"/></span>
|
||||
locales="it-IT"/></span>
|
||||
{/*<div className="auxStats">
|
||||
<span>
|
||||
<span className="badge">{getStatValue(['amendmentInProgress', 'expiringToday'], 0)}</span>
|
||||
{__('in scadenza oggi', 'gepafin')}</span>
|
||||
</div>*/}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { is, isEmpty, isNil, sum, pathOr, head } from 'ramda';
|
||||
import { is, isEmpty, isNil, sum, pathOr, head, pluck } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { evaluate } from 'mathjs';
|
||||
import equal from 'fast-deep-equal';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../store';
|
||||
@@ -15,8 +18,21 @@ import AppointmentService from '../../service/appointment-service';
|
||||
|
||||
// tools
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import getBandoLabel from '../../helpers/getBandoLabel';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
import {
|
||||
isCAP,
|
||||
isCodiceFiscale,
|
||||
isEmail,
|
||||
isEmailPEC,
|
||||
isIBAN,
|
||||
isMarcaDaBollo,
|
||||
isPIVA,
|
||||
isUrl, maxChecks, minChecks, nonEmptyTables
|
||||
} from '../../helpers/validators';
|
||||
import formatDateString from '../../helpers/formatDateString';
|
||||
import getTokens from '../../helpers/getTokens';
|
||||
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
||||
import renderWithDataVars from '../../helpers/renderWithDataVars';
|
||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
|
||||
// components
|
||||
import { Skeleton } from 'primereact/skeleton';
|
||||
@@ -31,12 +47,11 @@ import HelpIcon from '../../icons/HelpIcon';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import DownloadApplicationArchive from '../DomandaEditPreInstructor/components/DownloadApplicationArchive';
|
||||
import DownloadCompanyDelegation from '../DomandaEditPreInstructor/components/DownloadCompanyDelegation';
|
||||
import DownloadSignedApplication from '../DomandaEditPreInstructor/components/DownloadSignedApplication';
|
||||
import ListOfFiles from '../DomandaEditPreInstructor/components/ListOfFiles';
|
||||
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
||||
import getDateTimeFromISOstring from '../../helpers/getDateTimeFromISOstring';
|
||||
import ApplicationInfo from '../DomandaEditPreInstructor/components/ApplicationInfo';
|
||||
import ApplicationDownloadFiles from '../DomandaEditPreInstructor/components/ApplicationDownloadFiles';
|
||||
import FormField from '../../components/FormField';
|
||||
|
||||
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
@@ -66,12 +81,46 @@ const DomandaEditInstructorManager = () => {
|
||||
duration: 0,
|
||||
amount: 0
|
||||
});
|
||||
const [formData, setFormData] = useState([]);
|
||||
const [formId, setFormId] = useState(0);
|
||||
const [formInitialData, setFormInitialData] = useState(null);
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
setValue,
|
||||
trigger,
|
||||
register,
|
||||
getValues,
|
||||
watch,
|
||||
reset
|
||||
} = useForm({
|
||||
defaultValues: useMemo(() => {
|
||||
return formInitialData ? formInitialData : {}
|
||||
}, [formInitialData]),
|
||||
mode: 'onChange'
|
||||
});
|
||||
const validationFns = {
|
||||
isPIVA,
|
||||
isCodiceFiscale,
|
||||
isCAP,
|
||||
isIBAN,
|
||||
isEmail,
|
||||
isEmailPEC,
|
||||
isUrl,
|
||||
isMarcaDaBollo,
|
||||
minChecks,
|
||||
maxChecks,
|
||||
nonEmptyTables
|
||||
}
|
||||
const values = getValues();
|
||||
const formValues = watch();
|
||||
|
||||
const goToEvaluationsPage = () => {
|
||||
navigate('/mie-domande');
|
||||
}
|
||||
|
||||
const updateFlagsForSoccorso = (data) => {
|
||||
const updateFlagsForSoccorso = useCallback((data) => {
|
||||
let nonRatedFilesLength = 0;
|
||||
|
||||
if (data.files) {
|
||||
@@ -90,6 +139,7 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
setAllFilesRated(nonRatedFilesLength === 0);
|
||||
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
if (data.checklist) {
|
||||
const checkedChecklistItems = data.checklist
|
||||
.map(el => el.valid)
|
||||
@@ -97,7 +147,20 @@ const DomandaEditInstructorManager = () => {
|
||||
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
||||
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
||||
}
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const minChecks = data.numberOfCheck;
|
||||
const formFieldsChecklist = formData
|
||||
.filter(o => head(o.settings.filter(s => s.name === 'isChecklistItem' && s.value)))
|
||||
.map(o => o.id);
|
||||
|
||||
if (formFieldsChecklist.length >= minChecks) {
|
||||
const valuesTotal = formFieldsChecklist.map(v => formValues[v]);
|
||||
const valuesFirst = valuesTotal.toSpliced(minChecks);
|
||||
setAtLeastOneChecked(valuesTotal.filter(v => v === true).length === valuesTotal.length);
|
||||
setAllChecksChecked(valuesFirst.filter(v => v === true).length === valuesFirst.length)
|
||||
}
|
||||
}
|
||||
}, [formValues]);
|
||||
|
||||
const doNewSoccorso = () => {
|
||||
if (connectedSoccorsoId !== 0) {
|
||||
@@ -107,24 +170,75 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setData(getFormattedData(data.data));
|
||||
setMotivation(data.data.motivation);
|
||||
updateFlagsForSoccorso(data.data);
|
||||
const getVersion = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data.evaluationVersion === 'V1') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
} else if (resp.data.evaluationVersion === 'V2') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationV2ByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
const errGetVersion = (resp) => {
|
||||
if (toast.current && data.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: data.message
|
||||
detail: resp.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setData(getFormattedData(resp.data));
|
||||
setMotivation(resp.data.motivation);
|
||||
updateFlagsForSoccorso(resp.data);
|
||||
|
||||
if (resp.data.evaluationVersion === 'V2') {
|
||||
setFormData(resp.data.applicationEvaluationFormResponse.content);
|
||||
setFormId(resp.data.applicationEvaluationFormResponse.id);
|
||||
let formDataInitial = {};
|
||||
|
||||
if (resp.data.applicationEvaluationFormResponse.formFields) {
|
||||
const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
|
||||
fieldId: o.fieldId,
|
||||
fieldValue: o.fieldValue
|
||||
}));
|
||||
formDataInitial = submitData.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formDataInitial);
|
||||
}
|
||||
|
||||
reset();
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetCallback = (resp) => {
|
||||
if (toast.current && resp.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: resp.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -166,8 +280,34 @@ const DomandaEditInstructorManager = () => {
|
||||
updateFlagsForSoccorso(newData);
|
||||
}
|
||||
|
||||
const getTransformedSubmitData = () => {
|
||||
const formValues = getValues();
|
||||
const usedFieldsIds = pluck('id', formData);
|
||||
return Object.keys(formValues)
|
||||
.filter(v => usedFieldsIds.includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
const formField = head(formData.filter(o => o.id === cur));
|
||||
let fieldVal = formValues[cur];
|
||||
|
||||
if (formValues[cur] && formValues[cur].toISOString) {
|
||||
fieldVal = formatDateString(formValues[cur]);
|
||||
}
|
||||
|
||||
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
|
||||
if (formField && formField.name === 'fileupload') {
|
||||
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
|
||||
}
|
||||
acc.push({
|
||||
'fieldId': cur,
|
||||
'fieldValue': fieldVal
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
const doSaveDraft = useCallback((doRedirect = '') => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
files: klona(data.files),
|
||||
@@ -178,14 +318,36 @@ const DomandaEditInstructorManager = () => {
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note
|
||||
}
|
||||
};
|
||||
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
formData,
|
||||
submitData,
|
||||
(data) => updateCallback(data, doRedirect),
|
||||
errUpdateCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note
|
||||
}
|
||||
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
(data) => updateCallback(data, doRedirect),
|
||||
errUpdateCallback
|
||||
);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const updateCallback = (data, doRedirect = '') => {
|
||||
@@ -218,7 +380,8 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
|
||||
const doApprove = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'APPROVED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -229,11 +392,42 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const doReject = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'REJECTED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -244,7 +438,37 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const updateStatusCallback = (data) => {
|
||||
@@ -431,7 +655,7 @@ const DomandaEditInstructorManager = () => {
|
||||
setIsVisibleAppointmentDialog(true);
|
||||
}
|
||||
|
||||
const setValue = (name, value) => {
|
||||
const setFieldValue = (name, value) => {
|
||||
const newData = wrap(appointmentData).set(name, value).value();
|
||||
setAppointmentData(newData);
|
||||
}
|
||||
@@ -505,11 +729,153 @@ const DomandaEditInstructorManager = () => {
|
||||
// TODO
|
||||
}
|
||||
|
||||
const evaluationShouldBeBlocked = (data = {}) => {
|
||||
const evaluationBlockedForUser = (data = {}) => {
|
||||
const userData = storeGet.main.userData();
|
||||
return isAsyncRequest || userData.id !== data.assignedUserId;
|
||||
}
|
||||
|
||||
const shouldDisableNewSoccorso = () => {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const actionBtns = () => {
|
||||
return <div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE'
|
||||
|| (data.applicationStatus === 'EVALUATION' && shouldDisableNewSoccorso())
|
||||
|| evaluationBlockedForUser(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationBlockedForUser(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationBlockedForUser(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let updatedFormValues = klona(formValues);
|
||||
let context = {};
|
||||
|
||||
// eslint-disable-next-line array-callback-return
|
||||
formData.map((o) => {
|
||||
const variable = head(o.settings.filter(o => o.name === 'variable'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
context = getTokens(formula.value)
|
||||
.filter(v => !['false', 'null', 'true'].includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur] = isNil(context[cur]) ? 0 : parseCommaDecimal(context[cur]);
|
||||
return acc;
|
||||
}, context);
|
||||
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
updatedFormValues[o.id] = evaluate(mathFormula);
|
||||
} catch (e) {
|
||||
console.log('Error in math formula: "', mathFormula, '"', e.message);
|
||||
updatedFormValues[o.id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
context[variable.value[0]] = 'criteria_table' === o.name
|
||||
? pathOr(0, [o.id, 'total'], updatedFormValues)
|
||||
: pathOr(0, [o.id], updatedFormValues);
|
||||
}
|
||||
});
|
||||
|
||||
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
||||
reset(updatedFormValues);
|
||||
}
|
||||
|
||||
updateFlagsForSoccorso(data);
|
||||
}, [formValues]);
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData) {
|
||||
//reset();
|
||||
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]));
|
||||
trigger();
|
||||
}
|
||||
}, [formInitialData]);
|
||||
|
||||
useEffect(() => {
|
||||
const maxScore = pathOr(0, ['minScore'], data);
|
||||
const criteria = pathOr([], ['criteria'], data);
|
||||
@@ -523,9 +889,7 @@ const DomandaEditInstructorManager = () => {
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', entityId]
|
||||
]);
|
||||
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
|
||||
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
|
||||
['statuses', 'AWAITING']
|
||||
]);
|
||||
@@ -553,68 +917,18 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
{!isAsyncRequest && !isEmpty(data)
|
||||
? <div className="appPage__content">
|
||||
<div className="appPageSection__withBorder columns">
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('ID domanda', 'gepafin')}</span>
|
||||
<span>{data.applicationId}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Protocollo', 'gepafin')}</span>
|
||||
<span>{data.protocolNumber}</span>
|
||||
</p>
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('NDG', 'gepafin')}</span>
|
||||
<span>{data.ndg}</span>
|
||||
</p> : null}
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('Appuntamento', 'gepafin')}</span>
|
||||
<span>{data.appointmentId}</span>
|
||||
</p> : null}
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Bando', 'gepafin')}</span>
|
||||
<span>{data.callName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Referente Aziendale', 'gepafin')}</span>
|
||||
<span>{data.beneficiary}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Azienda Beneficiaria', 'gepafin')}</span>
|
||||
<span>{data.companyName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data ricezione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.submissionDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data assegnazione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.assignedAt)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Aassegnato a', 'gepafin')}</span>
|
||||
<span>{data.assignedUserName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Scadenza Valutazione', 'gepafin')}</span>
|
||||
<span>{getDateFromISOstring(data.evaluationEndDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Stato', 'gepafin')}</span>
|
||||
<span>{getBandoLabel(data.applicationStatus)}</span>
|
||||
</p>
|
||||
<ApplicationInfo data={data}/>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Scarica documenti della domanda', 'gepafin')}</h2>
|
||||
<div className="appPageSection__row autoFlow">
|
||||
<DownloadApplicationArchive applicationId={id}/>
|
||||
<DownloadSignedApplication applicationId={id}/>
|
||||
<DownloadCompanyDelegation applicationId={id}/>
|
||||
</div>
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<ApplicationDownloadFiles id={id}/>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||
<RepeaterFields
|
||||
@@ -623,12 +937,104 @@ const DomandaEditInstructorManager = () => {
|
||||
data,
|
||||
['evaluationDocument']
|
||||
)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
sourceId={data.assignedApplicationId}
|
||||
sourceName="evaluation"/>
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
{data.evaluationVersion === 'V2'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Documenti allegati', 'gepafin')}</h2>
|
||||
{!isEmpty(data.files)
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
: <p>{__('Nessun documento allegato', 'gepafin')}</p>}
|
||||
</div>
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V2'
|
||||
? <form className="appForm" onSubmit={handleSubmit(() => {
|
||||
})}>
|
||||
{formData.map(o => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
const placeholder = head(o.settings.filter(o => o.name === 'placeholder'));
|
||||
const options = head(o.settings.filter(o => o.name === 'options'));
|
||||
let tableColumns = head(o.settings.filter(o => o.name === 'table_columns'));
|
||||
if (!tableColumns) {
|
||||
tableColumns = head(o.settings.filter(o => o.name === 'criteria_table_columns'));
|
||||
}
|
||||
const step = head(o.settings.filter(o => o.name === 'step'));
|
||||
const mime = head(o.settings.filter(o => o.name === 'mime'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
let mimeValue = '';
|
||||
|
||||
if (mime) {
|
||||
mimeValue = mime.value.map(o => o.code ? o.code : o.ext);
|
||||
}
|
||||
|
||||
const validations = Object.keys(o.validators).reduce((acc, cur) => {
|
||||
if (o.validators[cur]) {
|
||||
if (['min', 'max', 'minLength', 'maxLength', 'maxSize'].includes(cur)) {
|
||||
acc[cur] = parseInt(o.validators[cur]);
|
||||
} else if ('pattern' === cur) {
|
||||
acc[cur] = new RegExp(o.validators[cur]);
|
||||
} else if ('isRequired' === cur) {
|
||||
//acc[cur] = o.validators[cur];
|
||||
acc['required'] = true;
|
||||
} else if ('custom' === cur && validationFns[o.validators[cur]]) {
|
||||
if (!acc.validate) {
|
||||
acc.validate = {};
|
||||
}
|
||||
acc.validate[o.validators[cur]] = validationFns[o.validators[cur]];
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
/*if (o.name === 'table') {
|
||||
console.log('value:', values[o.id] ? values[o.id] : '')
|
||||
}*/
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div key={o.id}>
|
||||
<div className="ql-editor">
|
||||
{renderHtmlContent(text.value)}
|
||||
</div>
|
||||
</div>
|
||||
: <FormField
|
||||
key={o.id}
|
||||
readOnly={formula && !isEmpty(formula.value)}
|
||||
type={o.name}
|
||||
fieldName={o.id}
|
||||
label={label ? label.value : ''}
|
||||
placeholder={placeholder ? placeholder.value : ''}
|
||||
control={control}
|
||||
register={register}
|
||||
errors={errors}
|
||||
defaultValue={values[o.id] ? values[o.id] : ''}
|
||||
maxFractionDigits={step ? step.value : 0}
|
||||
accept={mimeValue}
|
||||
config={validations}
|
||||
options={options ? options.value : []}
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doSaveDraft}
|
||||
sourceId={id}
|
||||
useGrouping={false}
|
||||
tableColumns={tableColumns ? tableColumns.value : {}}
|
||||
/>
|
||||
})}
|
||||
</form>
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V1'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Checklist Valutazione', 'gepafin')}</h2>
|
||||
<div className="appPageSection columns">
|
||||
<div>
|
||||
@@ -637,7 +1043,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<div className="appPageSection__checklist">
|
||||
{data.checklist.map((o, i) => <div key={o.id}>
|
||||
<Checkbox
|
||||
disabled={shouldDisableField('checklist') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('checklist') || evaluationBlockedForUser(data)}
|
||||
inputId={`checklist_${o.id}`}
|
||||
onChange={(e) => updateEvaluationValue(
|
||||
e.checked,
|
||||
@@ -653,7 +1059,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<div>
|
||||
<Editor
|
||||
value={data.note}
|
||||
readOnly={shouldDisableField('note') || evaluationShouldBeBlocked(data)}
|
||||
readOnly={shouldDisableField('note') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateEvaluationValue(
|
||||
@@ -670,7 +1076,7 @@ const DomandaEditInstructorManager = () => {
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -678,6 +1084,7 @@ const DomandaEditInstructorManager = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
: null}
|
||||
|
||||
{!isEmpty(data.amendmentDetails)
|
||||
? <div className="appPageSection">
|
||||
@@ -685,13 +1092,14 @@ const DomandaEditInstructorManager = () => {
|
||||
<ListOfFiles
|
||||
files={data.amendmentDetails}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="amendmentDetails"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
</div> : null}
|
||||
|
||||
<div className="appPageSection">
|
||||
{data.evaluationVersion === 'V1'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
|
||||
{data.criteria
|
||||
? <table className="myTable">
|
||||
@@ -708,7 +1116,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<td>
|
||||
<div className="p-inputgroup">
|
||||
<InputNumber
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Punteggio', 'gepafin')}
|
||||
keyfilter="int"
|
||||
value={o.score}
|
||||
@@ -731,7 +1139,7 @@ const DomandaEditInstructorManager = () => {
|
||||
onClick={() => displayCriterionData(o.id)}
|
||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
true,
|
||||
@@ -739,7 +1147,7 @@ const DomandaEditInstructorManager = () => {
|
||||
)}
|
||||
aria-label={__('Su', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
false,
|
||||
@@ -769,6 +1177,7 @@ const DomandaEditInstructorManager = () => {
|
||||
</tfoot>
|
||||
</table> : null}
|
||||
</div>
|
||||
: null}
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
@@ -777,85 +1186,7 @@ const DomandaEditInstructorManager = () => {
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE' || (data.applicationStatus === 'EVALUATION'
|
||||
&& (!allFilesRated || !atLeastOneChecked)) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationShouldBeBlocked(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi Domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<Dialog
|
||||
@@ -902,7 +1233,7 @@ const DomandaEditInstructorManager = () => {
|
||||
value={appointmentData.amount}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.amount) || appointmentData.amount === 0}
|
||||
onChange={(e) => setValue('amount', e.value)}/>
|
||||
onChange={(e) => setFieldValue('amount', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label
|
||||
@@ -913,7 +1244,7 @@ const DomandaEditInstructorManager = () => {
|
||||
value={appointmentData.duration}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.duration) || appointmentData.duration === 0}
|
||||
onChange={(e) => setValue('duration', e.value)}/>
|
||||
onChange={(e) => setFieldValue('duration', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.title) })}>
|
||||
@@ -922,7 +1253,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<InputText
|
||||
value={appointmentData.title}
|
||||
invalid={isEmpty(appointmentData.title)}
|
||||
onChange={(e) => setValue('title', e.target.value)}/>
|
||||
onChange={(e) => setFieldValue('title', e.target.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.text) })}>
|
||||
@@ -931,7 +1262,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<InputTextarea
|
||||
value={appointmentData.text}
|
||||
invalid={isEmpty(appointmentData.text)}
|
||||
onChange={(e) => setValue('text', e.target.value)}
|
||||
onChange={(e) => setFieldValue('text', e.target.value)}
|
||||
rows={3}
|
||||
cols={30}/>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isNil } from 'ramda';
|
||||
|
||||
// components
|
||||
import DownloadApplicationArchive from '../DownloadApplicationArchive';
|
||||
import DownloadSignedApplication from '../DownloadSignedApplication';
|
||||
import DownloadCompanyDelegation from '../DownloadCompanyDelegation';
|
||||
|
||||
const ApplicationDownloadFiles = ({ id }) => {
|
||||
return (
|
||||
!isNil(id)
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Scarica documenti della domanda', 'gepafin')}</h2>
|
||||
<div className="appPageSection__row autoFlow">
|
||||
<DownloadApplicationArchive applicationId={id}/>
|
||||
<DownloadSignedApplication applicationId={id}/>
|
||||
<DownloadCompanyDelegation applicationId={id}/>
|
||||
</div>
|
||||
</div> : null
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationDownloadFiles;
|
||||
@@ -0,0 +1,70 @@
|
||||
import React from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isNil } from 'ramda';
|
||||
|
||||
// tools
|
||||
import getDateTimeFromISOstring from '../../../../helpers/getDateTimeFromISOstring';
|
||||
import getDateFromISOstring from '../../../../helpers/getDateFromISOstring';
|
||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const ApplicationInfo = ({ data }) => {
|
||||
return (
|
||||
!isNil(data)
|
||||
? <div className="appPageSection__withBorder columns">
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('ID domanda', 'gepafin')}</span>
|
||||
<span>{data.applicationId}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Protocollo', 'gepafin')}</span>
|
||||
<span>{data.protocolNumber}</span>
|
||||
</p>
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('NDG', 'gepafin')}</span>
|
||||
<span>{data.ndg}</span>
|
||||
</p> : null}
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('Appuntamento', 'gepafin')}</span>
|
||||
<span>{data.appointmentId}</span>
|
||||
</p> : null}
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Bando', 'gepafin')}</span>
|
||||
<span>{data.callName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Referente Aziendale', 'gepafin')}</span>
|
||||
<span>{data.beneficiary}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Azienda Beneficiaria', 'gepafin')}</span>
|
||||
<span>{data.companyName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data ricezione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.submissionDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data assegnazione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.assignedAt)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Aassegnato a', 'gepafin')}</span>
|
||||
<span>{data.assignedUserName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Scadenza Valutazione', 'gepafin')}</span>
|
||||
<span>{getDateFromISOstring(data.evaluationEndDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Stato', 'gepafin')}</span>
|
||||
<span>{getBandoLabel(data.applicationStatus)}</span>
|
||||
</p>
|
||||
</div> : null
|
||||
)
|
||||
}
|
||||
|
||||
export default ApplicationInfo;
|
||||
@@ -1,9 +1,12 @@
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { is, isEmpty, isNil, sum, pathOr, head } from 'ramda';
|
||||
import { is, isEmpty, isNil, sum, pathOr, head, pluck } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { evaluate } from 'mathjs';
|
||||
import equal from 'fast-deep-equal';
|
||||
|
||||
// store
|
||||
import { storeGet, storeSet, useStore } from '../../store';
|
||||
@@ -15,8 +18,21 @@ import AppointmentService from '../../service/appointment-service';
|
||||
|
||||
// tools
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import getBandoLabel from '../../helpers/getBandoLabel';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
import {
|
||||
isCAP,
|
||||
isCodiceFiscale,
|
||||
isEmail,
|
||||
isEmailPEC,
|
||||
isIBAN,
|
||||
isMarcaDaBollo,
|
||||
isPIVA,
|
||||
isUrl, maxChecks, minChecks, nonEmptyTables
|
||||
} from '../../helpers/validators';
|
||||
import getTokens from '../../helpers/getTokens';
|
||||
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
||||
import renderWithDataVars from '../../helpers/renderWithDataVars';
|
||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
import formatDateString from '../../helpers/formatDateString';
|
||||
|
||||
// components
|
||||
import { Skeleton } from 'primereact/skeleton';
|
||||
@@ -32,12 +48,11 @@ import BlockingOverlay from '../../components/BlockingOverlay';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import DownloadApplicationArchive from './components/DownloadApplicationArchive';
|
||||
import DownloadCompanyDelegation from './components/DownloadCompanyDelegation';
|
||||
import DownloadSignedApplication from './components/DownloadSignedApplication';
|
||||
import ListOfFiles from './components/ListOfFiles';
|
||||
import RepeaterFields from './components/RepeaterFields';
|
||||
import getDateTimeFromISOstring from '../../helpers/getDateTimeFromISOstring';
|
||||
import ApplicationInfo from './components/ApplicationInfo';
|
||||
import ApplicationDownloadFiles from './components/ApplicationDownloadFiles';
|
||||
import FormField from '../../components/FormField';
|
||||
|
||||
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
@@ -67,12 +82,46 @@ const DomandaEditPreInstructor = () => {
|
||||
duration: 0,
|
||||
amount: 0
|
||||
});
|
||||
const [formData, setFormData] = useState([]);
|
||||
const [formId, setFormId] = useState(0);
|
||||
const [formInitialData, setFormInitialData] = useState(null);
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
setValue,
|
||||
trigger,
|
||||
register,
|
||||
getValues,
|
||||
watch,
|
||||
reset
|
||||
} = useForm({
|
||||
defaultValues: useMemo(() => {
|
||||
return formInitialData ? formInitialData : {}
|
||||
}, [formInitialData]),
|
||||
mode: 'onChange'
|
||||
});
|
||||
const validationFns = {
|
||||
isPIVA,
|
||||
isCodiceFiscale,
|
||||
isCAP,
|
||||
isIBAN,
|
||||
isEmail,
|
||||
isEmailPEC,
|
||||
isUrl,
|
||||
isMarcaDaBollo,
|
||||
minChecks,
|
||||
maxChecks,
|
||||
nonEmptyTables
|
||||
}
|
||||
const values = getValues();
|
||||
const formValues = watch();
|
||||
|
||||
const goToEvaluationsPage = () => {
|
||||
navigate('/domande');
|
||||
}
|
||||
|
||||
const updateFlagsForSoccorso = (data) => {
|
||||
const updateFlagsForSoccorso = useCallback((data) => {
|
||||
let nonRatedFilesLength = 0;
|
||||
|
||||
if (data.files) {
|
||||
@@ -91,6 +140,7 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
setAllFilesRated(nonRatedFilesLength === 0);
|
||||
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
if (data.checklist) {
|
||||
const checkedChecklistItems = data.checklist
|
||||
.map(el => el.valid)
|
||||
@@ -98,7 +148,20 @@ const DomandaEditPreInstructor = () => {
|
||||
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
||||
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
||||
}
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const minChecks = data.numberOfCheck;
|
||||
const formFieldsChecklist = formData
|
||||
.filter(o => head(o.settings.filter(s => s.name === 'isChecklistItem' && s.value)))
|
||||
.map(o => o.id);
|
||||
|
||||
if (formFieldsChecklist.length >= minChecks) {
|
||||
const valuesTotal = formFieldsChecklist.map(v => formValues[v]);
|
||||
const valuesFirst = valuesTotal.toSpliced(minChecks);
|
||||
setAtLeastOneChecked(valuesTotal.filter(v => v === true).length === valuesTotal.length);
|
||||
setAllChecksChecked(valuesFirst.filter(v => v === true).length === valuesFirst.length)
|
||||
}
|
||||
}
|
||||
}, [formValues]);
|
||||
|
||||
const doNewSoccorso = () => {
|
||||
if (connectedSoccorsoId !== 0) {
|
||||
@@ -108,24 +171,75 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setData(getFormattedData(data.data));
|
||||
setMotivation(data.data.motivation);
|
||||
updateFlagsForSoccorso(data.data);
|
||||
const getVersion = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data.evaluationVersion === 'V1') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
} else if (resp.data.evaluationVersion === 'V2') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationV2ByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetCallback = (data) => {
|
||||
const errGetVersion = (resp) => {
|
||||
if (toast.current && data.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: data.message
|
||||
detail: resp.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(data);
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setData(getFormattedData(resp.data));
|
||||
setMotivation(resp.data.motivation);
|
||||
updateFlagsForSoccorso(resp.data);
|
||||
|
||||
if (resp.data.evaluationVersion === 'V2') {
|
||||
setFormData(resp.data.applicationEvaluationFormResponse.content);
|
||||
setFormId(resp.data.applicationEvaluationFormResponse.id);
|
||||
let formDataInitial = {};
|
||||
|
||||
if (resp.data.applicationEvaluationFormResponse.formFields) {
|
||||
const submitData = resp.data.applicationEvaluationFormResponse.formFields.map((o) => ({
|
||||
fieldId: o.fieldId,
|
||||
fieldValue: o.fieldValue
|
||||
}));
|
||||
formDataInitial = submitData.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formDataInitial);
|
||||
}
|
||||
|
||||
reset();
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetCallback = (resp) => {
|
||||
if (toast.current && resp.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: resp.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
@@ -167,8 +281,34 @@ const DomandaEditPreInstructor = () => {
|
||||
updateFlagsForSoccorso(newData);
|
||||
}
|
||||
|
||||
const getTransformedSubmitData = () => {
|
||||
const formValues = getValues();
|
||||
const usedFieldsIds = pluck('id', formData);
|
||||
return Object.keys(formValues)
|
||||
.filter(v => usedFieldsIds.includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
const formField = head(formData.filter(o => o.id === cur));
|
||||
let fieldVal = formValues[cur];
|
||||
|
||||
if (formValues[cur] && formValues[cur].toISOString) {
|
||||
fieldVal = formatDateString(formValues[cur]);
|
||||
}
|
||||
|
||||
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
|
||||
if (formField && formField.name === 'fileupload') {
|
||||
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
|
||||
}
|
||||
acc.push({
|
||||
'fieldId': cur,
|
||||
'fieldValue': fieldVal
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
const doSaveDraft = useCallback((doRedirect = '') => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
files: klona(data.files),
|
||||
@@ -179,14 +319,36 @@ const DomandaEditPreInstructor = () => {
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note
|
||||
}
|
||||
};
|
||||
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
formData,
|
||||
submitData,
|
||||
(data) => updateCallback(data, doRedirect),
|
||||
errUpdateCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note
|
||||
}
|
||||
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
(data) => updateCallback(data, doRedirect),
|
||||
errUpdateCallback
|
||||
);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const updateCallback = (data, doRedirect = '') => {
|
||||
@@ -219,7 +381,8 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
|
||||
const doApprove = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'APPROVED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -230,11 +393,42 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const doReject = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'REJECTED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -245,7 +439,37 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const updateStatusCallback = (data) => {
|
||||
@@ -432,7 +656,7 @@ const DomandaEditPreInstructor = () => {
|
||||
setIsVisibleAppointmentDialog(true);
|
||||
}
|
||||
|
||||
const setValue = (name, value) => {
|
||||
const setFieldValue = (name, value) => {
|
||||
const newData = wrap(appointmentData).set(name, value).value();
|
||||
setAppointmentData(newData);
|
||||
}
|
||||
@@ -506,11 +730,153 @@ const DomandaEditPreInstructor = () => {
|
||||
// TODO
|
||||
}
|
||||
|
||||
const evaluationShouldBeBlocked = (data = {}) => {
|
||||
const evaluationBlockedForUser = (data = {}) => {
|
||||
const userData = storeGet.main.userData()
|
||||
return isAsyncRequest || userData.id !== data.assignedUserId;
|
||||
}
|
||||
|
||||
const shouldDisableNewSoccorso = () => {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const actionBtns = () => {
|
||||
return <div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE'
|
||||
|| (data.applicationStatus === 'EVALUATION' && shouldDisableNewSoccorso())
|
||||
|| evaluationBlockedForUser(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationBlockedForUser(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationBlockedForUser(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let updatedFormValues = klona(formValues);
|
||||
let context = {};
|
||||
|
||||
// eslint-disable-next-line array-callback-return
|
||||
formData.map((o) => {
|
||||
const variable = head(o.settings.filter(o => o.name === 'variable'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
context = getTokens(formula.value)
|
||||
.filter(v => !['false', 'null', 'true'].includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur] = isNil(context[cur]) ? 0 : parseCommaDecimal(context[cur]);
|
||||
return acc;
|
||||
}, context);
|
||||
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
updatedFormValues[o.id] = evaluate(mathFormula);
|
||||
} catch (e) {
|
||||
console.log('Error in math formula: "', mathFormula, '"', e.message);
|
||||
updatedFormValues[o.id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
context[variable.value[0]] = 'criteria_table' === o.name
|
||||
? pathOr(0, [o.id, 'total'], updatedFormValues)
|
||||
: pathOr(0, [o.id], updatedFormValues);
|
||||
}
|
||||
});
|
||||
|
||||
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
||||
reset(updatedFormValues);
|
||||
}
|
||||
|
||||
updateFlagsForSoccorso(data);
|
||||
}, [formValues]);
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData) {
|
||||
//reset();
|
||||
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]));
|
||||
trigger();
|
||||
}
|
||||
}, [formInitialData]);
|
||||
|
||||
useEffect(() => {
|
||||
const maxScore = pathOr(0, ['minScore'], data);
|
||||
const criteria = pathOr([], ['criteria'], data);
|
||||
@@ -524,9 +890,7 @@ const DomandaEditPreInstructor = () => {
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', entityId]
|
||||
]);
|
||||
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
|
||||
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
|
||||
['statuses', 'AWAITING']
|
||||
]);
|
||||
@@ -555,68 +919,18 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
{!isAsyncRequest && !isEmpty(data)
|
||||
? <div className="appPage__content">
|
||||
<div className="appPageSection__withBorder columns">
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('ID domanda', 'gepafin')}</span>
|
||||
<span>{data.applicationId}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Protocollo', 'gepafin')}</span>
|
||||
<span>{data.protocolNumber}</span>
|
||||
</p>
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('NDG', 'gepafin')}</span>
|
||||
<span>{data.ndg}</span>
|
||||
</p> : null}
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <p className="appPageSection__pMeta">
|
||||
<span>{__('Appuntamento', 'gepafin')}</span>
|
||||
<span>{data.appointmentId}</span>
|
||||
</p> : null}
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Bando', 'gepafin')}</span>
|
||||
<span>{data.callName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Referente Aziendale', 'gepafin')}</span>
|
||||
<span>{data.beneficiary}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Azienda Beneficiaria', 'gepafin')}</span>
|
||||
<span>{data.companyName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data ricezione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.submissionDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Data assegnazione', 'gepafin')}</span>
|
||||
<span>{getDateTimeFromISOstring(data.assignedAt)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Aassegnato a', 'gepafin')}</span>
|
||||
<span>{data.assignedUserName}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Scadenza Valutazione', 'gepafin')}</span>
|
||||
<span>{getDateFromISOstring(data.evaluationEndDate)}</span>
|
||||
</p>
|
||||
<p className="appPageSection__pMeta">
|
||||
<span>{__('Stato', 'gepafin')}</span>
|
||||
<span>{getBandoLabel(data.applicationStatus)}</span>
|
||||
</p>
|
||||
<ApplicationInfo data={data}/>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Scarica documenti della domanda', 'gepafin')}</h2>
|
||||
<div className="appPageSection__row autoFlow">
|
||||
<DownloadApplicationArchive applicationId={id}/>
|
||||
<DownloadSignedApplication applicationId={id}/>
|
||||
<DownloadCompanyDelegation applicationId={id}/>
|
||||
</div>
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<ApplicationDownloadFiles id={id}/>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||
<RepeaterFields
|
||||
@@ -625,12 +939,104 @@ const DomandaEditPreInstructor = () => {
|
||||
data,
|
||||
['evaluationDocument']
|
||||
)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
sourceId={data.assignedApplicationId}
|
||||
sourceName="evaluation"/>
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
{data.evaluationVersion === 'V2'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Documenti allegati', 'gepafin')}</h2>
|
||||
{!isEmpty(data.files)
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
: <p>{__('Nessun documento allegato', 'gepafin')}</p>}
|
||||
</div>
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V2'
|
||||
? <form className="appForm" onSubmit={handleSubmit(() => {
|
||||
})}>
|
||||
{formData.map(o => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
const placeholder = head(o.settings.filter(o => o.name === 'placeholder'));
|
||||
const options = head(o.settings.filter(o => o.name === 'options'));
|
||||
let tableColumns = head(o.settings.filter(o => o.name === 'table_columns'));
|
||||
if (!tableColumns) {
|
||||
tableColumns = head(o.settings.filter(o => o.name === 'criteria_table_columns'));
|
||||
}
|
||||
const step = head(o.settings.filter(o => o.name === 'step'));
|
||||
const mime = head(o.settings.filter(o => o.name === 'mime'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
let mimeValue = '';
|
||||
|
||||
if (mime) {
|
||||
mimeValue = mime.value.map(o => o.code ? o.code : o.ext);
|
||||
}
|
||||
|
||||
const validations = Object.keys(o.validators).reduce((acc, cur) => {
|
||||
if (o.validators[cur]) {
|
||||
if (['min', 'max', 'minLength', 'maxLength', 'maxSize'].includes(cur)) {
|
||||
acc[cur] = parseInt(o.validators[cur]);
|
||||
} else if ('pattern' === cur) {
|
||||
acc[cur] = new RegExp(o.validators[cur]);
|
||||
} else if ('isRequired' === cur) {
|
||||
//acc[cur] = o.validators[cur];
|
||||
acc['required'] = true;
|
||||
} else if ('custom' === cur && validationFns[o.validators[cur]]) {
|
||||
if (!acc.validate) {
|
||||
acc.validate = {};
|
||||
}
|
||||
acc.validate[o.validators[cur]] = validationFns[o.validators[cur]];
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
/*if (o.name === 'table') {
|
||||
console.log('value:', values[o.id] ? values[o.id] : '')
|
||||
}*/
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div key={o.id}>
|
||||
<div className="ql-editor">
|
||||
{renderHtmlContent(text.value)}
|
||||
</div>
|
||||
</div>
|
||||
: <FormField
|
||||
key={o.id}
|
||||
readOnly={formula && !isEmpty(formula.value)}
|
||||
type={o.name}
|
||||
fieldName={o.id}
|
||||
label={label ? label.value : ''}
|
||||
placeholder={placeholder ? placeholder.value : ''}
|
||||
control={control}
|
||||
register={register}
|
||||
errors={errors}
|
||||
defaultValue={values[o.id] ? values[o.id] : ''}
|
||||
maxFractionDigits={step ? step.value : 0}
|
||||
accept={mimeValue}
|
||||
config={validations}
|
||||
options={options ? options.value : []}
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doSaveDraft}
|
||||
sourceId={id}
|
||||
useGrouping={false}
|
||||
tableColumns={tableColumns ? tableColumns.value : {}}
|
||||
/>
|
||||
})}
|
||||
</form>
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V1'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Checklist Valutazione', 'gepafin')}</h2>
|
||||
<div className="appPageSection columns">
|
||||
<div>
|
||||
@@ -639,7 +1045,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<div className="appPageSection__checklist">
|
||||
{data.checklist.map((o, i) => <div key={o.id}>
|
||||
<Checkbox
|
||||
disabled={shouldDisableField('checklist') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('checklist') || evaluationBlockedForUser(data)}
|
||||
inputId={`checklist_${o.id}`}
|
||||
onChange={(e) => updateEvaluationValue(
|
||||
e.checked,
|
||||
@@ -655,7 +1061,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<div>
|
||||
<Editor
|
||||
value={data.note}
|
||||
readOnly={shouldDisableField('note') || evaluationShouldBeBlocked(data)}
|
||||
readOnly={shouldDisableField('note') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateEvaluationValue(
|
||||
@@ -672,7 +1078,7 @@ const DomandaEditPreInstructor = () => {
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -680,6 +1086,7 @@ const DomandaEditPreInstructor = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
: null}
|
||||
|
||||
{!isEmpty(data.amendmentDetails)
|
||||
? <div className="appPageSection">
|
||||
@@ -687,13 +1094,14 @@ const DomandaEditPreInstructor = () => {
|
||||
<ListOfFiles
|
||||
files={data.amendmentDetails}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="amendmentDetails"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
</div> : null}
|
||||
|
||||
<div className="appPageSection">
|
||||
{data.evaluationVersion === 'V1'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
|
||||
{data.criteria
|
||||
? <table className="myTable">
|
||||
@@ -710,7 +1118,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<td>
|
||||
<div className="p-inputgroup">
|
||||
<InputNumber
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Punteggio', 'gepafin')}
|
||||
keyfilter="int"
|
||||
value={o.score}
|
||||
@@ -733,7 +1141,7 @@ const DomandaEditPreInstructor = () => {
|
||||
onClick={() => displayCriterionData(o.id)}
|
||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
true,
|
||||
@@ -741,7 +1149,7 @@ const DomandaEditPreInstructor = () => {
|
||||
)}
|
||||
aria-label={__('Su', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
false,
|
||||
@@ -771,6 +1179,7 @@ const DomandaEditPreInstructor = () => {
|
||||
</tfoot>
|
||||
</table> : null}
|
||||
</div>
|
||||
: null}
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
@@ -779,85 +1188,7 @@ const DomandaEditPreInstructor = () => {
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE' || (data.applicationStatus === 'EVALUATION'
|
||||
&& (!allFilesRated || !atLeastOneChecked)) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationShouldBeBlocked(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<Dialog
|
||||
@@ -904,7 +1235,7 @@ const DomandaEditPreInstructor = () => {
|
||||
value={appointmentData.amount}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.amount) || appointmentData.amount === 0}
|
||||
onChange={(e) => setValue('amount', e.value)}/>
|
||||
onChange={(e) => setFieldValue('amount', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label
|
||||
@@ -915,7 +1246,7 @@ const DomandaEditPreInstructor = () => {
|
||||
value={appointmentData.duration}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.duration) || appointmentData.duration === 0}
|
||||
onChange={(e) => setValue('duration', e.value)}/>
|
||||
onChange={(e) => setFieldValue('duration', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.title) })}>
|
||||
@@ -924,7 +1255,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<InputText
|
||||
value={appointmentData.title}
|
||||
invalid={isEmpty(appointmentData.title)}
|
||||
onChange={(e) => setValue('title', e.target.value)}/>
|
||||
onChange={(e) => setFieldValue('title', e.target.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.text) })}>
|
||||
@@ -933,7 +1264,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<InputTextarea
|
||||
value={appointmentData.text}
|
||||
invalid={isEmpty(appointmentData.text)}
|
||||
onChange={(e) => setValue('text', e.target.value)}
|
||||
onChange={(e) => setFieldValue('text', e.target.value)}
|
||||
rows={3}
|
||||
cols={30}/>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty, pathOr } from 'ramda';
|
||||
import { isEmpty } from 'ramda';
|
||||
|
||||
// store
|
||||
import { storeSet } from '../../store';
|
||||
|
||||
@@ -36,7 +36,7 @@ const Profile = () => {
|
||||
const onSubmit = (formData) => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
|
||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
|
||||
const updateCallback = (data) => {
|
||||
@@ -109,6 +109,7 @@ const Profile = () => {
|
||||
<FormField
|
||||
type="textinput"
|
||||
fieldName="email"
|
||||
disabled={true}
|
||||
label={__('Email', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
|
||||
@@ -36,7 +36,7 @@ const ProfileBeneficiario = () => {
|
||||
const onSubmit = (formData) => {
|
||||
storeSet.main.setAsyncRequest();
|
||||
|
||||
UserService.updateUser(userData.id, formData, updateCallback, updateError);
|
||||
UserService.updateUserSelf(userData.id, formData, updateCallback, updateError);
|
||||
};
|
||||
|
||||
const updateCallback = (data) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
@@ -22,9 +22,9 @@ const SoccorsoIstruttorioPreInstructor = () => {
|
||||
|
||||
const errGetStats = () => {}
|
||||
|
||||
const getStatValue = (key, fallback = '') => {
|
||||
const getStatValue = useCallback((key, fallback = '') => {
|
||||
return pathOr(fallback, [key], mainStats);
|
||||
}
|
||||
}, [mainStats]);
|
||||
|
||||
useEffect(() => {
|
||||
DashboardService.getAmendmentsStats(getStats, errGetStats);
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { is, isEmpty, uniq } from 'ramda';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../../../store';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
|
||||
// tools
|
||||
import getNumberWithCurrency from '../../../../helpers/getNumberWithCurrency';
|
||||
|
||||
// components
|
||||
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
|
||||
const BeneficiarioUltimeDomandeTable = () => {
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
const [items, setItems] = useState(null);
|
||||
// eslint-disable-next-line
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
// eslint-disable-next-line
|
||||
const [statuses, setStatuses] = useState([]);
|
||||
const perPage = 5;
|
||||
|
||||
const getPaginationQuery = (status = 'DRAFT', curPage = 1) => {
|
||||
return {
|
||||
"globalFilters": {
|
||||
//"year": 0,
|
||||
"page": curPage,
|
||||
//"search": "",
|
||||
"limit": perPage,
|
||||
},
|
||||
//"daysRange": 0,
|
||||
"status": status
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEmpty(chosenCompanyId) && chosenCompanyId !== 0 && !localAsyncRequest) {
|
||||
const bodyParams = getPaginationQuery(
|
||||
['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT'],
|
||||
1
|
||||
);
|
||||
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.getApplicationsPaginated(bodyParams, getApplCallback, errGetApplCallback, [
|
||||
['companyId', chosenCompanyId],
|
||||
['statuses', ['SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'SUBMIT']] // 'NDG', 'ADMISSIBLE', 'APPOINTMENT'
|
||||
]);
|
||||
}
|
||||
}, [chosenCompanyId]);
|
||||
|
||||
const getApplCallback = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data && is(Array, resp.data.body)) {
|
||||
setItems(getFormattedBandiData(resp.data.body));
|
||||
setStatuses(uniq(items.map(o => o.status)))
|
||||
initFilters();
|
||||
}
|
||||
}
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errGetApplCallback = () => {
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const getFormattedBandiData = (data) => {
|
||||
return [...(data || [])].map((d) => {
|
||||
d.callEndDate = new Date(d.callEndDate);
|
||||
d.modifiedDate = new Date(d.modifiedDate);
|
||||
d.submissionDate = new Date(d.submissionDate);
|
||||
|
||||
return d;
|
||||
});
|
||||
};
|
||||
|
||||
const formatDate = (value) => {
|
||||
return value.toLocaleDateString('it-IT', {
|
||||
year: 'numeric'
|
||||
});
|
||||
};
|
||||
|
||||
const initFilters = () => {
|
||||
setFilters({
|
||||
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
|
||||
callTitle: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }]
|
||||
},
|
||||
companyName: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.STARTS_WITH }]
|
||||
},
|
||||
modifiedDate: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
|
||||
},
|
||||
callEndDate: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const dateSubmissionBodyTemplate = (rowData) => {
|
||||
return formatDate(rowData.submissionDate);
|
||||
};
|
||||
|
||||
const importoBodyTemplate = (rowData) => {
|
||||
return getNumberWithCurrency(rowData.amountRequested);
|
||||
};
|
||||
|
||||
const statusBodyTemplate = (rowData) => {
|
||||
return <ProperBandoLabel status={rowData.status}/>;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
<DataTable value={items} showGridlines rows={5} loading={localAsyncRequest} dataKey="id"
|
||||
stripedRows
|
||||
emptyMessage={translationStrings.emptyMessage}>
|
||||
<Column field="callTitle" header={__('Bando', 'gepafin')}
|
||||
style={{ minWidth: '8rem' }}/>
|
||||
<Column header={__('Anno', 'gepafin')} dataType="date"
|
||||
style={{ minWidth: '8rem' }}
|
||||
body={dateSubmissionBodyTemplate}/>
|
||||
<Column field="amountRequested"
|
||||
header={__('Importo finanziato', 'gepafin')}
|
||||
style={{ minWidth: '7rem' }}
|
||||
body={importoBodyTemplate}/>
|
||||
<Column field="status" header={__('Stato progetto', 'gepafin')}
|
||||
style={{ minWidth: '7rem' }} body={statusBodyTemplate}/>
|
||||
</DataTable>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BeneficiarioUltimeDomandeTable;
|
||||
112
src/pages/StatsBeneficiary/index.js
Normal file
112
src/pages/StatsBeneficiary/index.js
Normal file
@@ -0,0 +1,112 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isEmpty, pathOr } from 'ramda';
|
||||
import NumberFlow from '@number-flow/react';
|
||||
|
||||
// store
|
||||
import { useStore } from '../../store';
|
||||
|
||||
// components
|
||||
import DashboardService from '../../service/dashboard-service';
|
||||
import ChartDomandePerStato from '../../components/ChartDomandePerStato';
|
||||
import ChartRichiesteVsApprovate from '../../components/ChartRichiesteVsApprovate';
|
||||
import BeneficiarioUltimeDomandeTable from './components/BeneficiarioUltimeDomandeTable';
|
||||
|
||||
const StatsBeneficiary = () => {
|
||||
const [mainStats, setMainStats] = useState({});
|
||||
const [chartStats, setChartStats] = useState({});
|
||||
const chosenCompanyId = useStore().main.chosenCompanyId();
|
||||
|
||||
const getStats = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
setMainStats(resp.data.applicationWidget);
|
||||
setChartStats(resp.data.applicationWidgetBars);
|
||||
}
|
||||
}
|
||||
|
||||
const errGetStats = () => {}
|
||||
|
||||
const getStatValue = useCallback((key, fallback = '') => {
|
||||
return pathOr(fallback, [key], mainStats);
|
||||
}, [mainStats]);
|
||||
|
||||
useEffect(() => {
|
||||
DashboardService.getBeneficiaryStatsPage(chosenCompanyId, getStats, errGetStats);
|
||||
}, [chosenCompanyId]);
|
||||
|
||||
return(
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
<h1>{__('Statistiche', 'gepafin')}</h1>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection statsBigBadges">
|
||||
<h2>{__('Riepilogo', 'gepafin')}</h2>
|
||||
<div className="statsBigBadges__grid doubleStatsItems">
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Domande presentate', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('submittedApplication', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Tasso di successo', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('waitingForResponseAmendments', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
suffix={` ${__('%', 'gepafin')}`}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Domande approvate', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('approvedApplication', 0)}
|
||||
format={{ notation: 'compact' }}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
<div className="statsBigBadges__gridItemDoubleStatsBeneficiary">
|
||||
<span>{__('Importo totale finanziato', 'gepafin')}</span>
|
||||
<span><NumberFlow
|
||||
value={getStatValue('averageResponseDays', 0)}
|
||||
format={{
|
||||
notation: 'compact',
|
||||
compactDisplay: 'short',
|
||||
roundingMode: 'trunc',
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
currencyDisplay: 'symbol'
|
||||
}}
|
||||
locales="it-IT"/></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
{chartStats && !isEmpty(chartStats)
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Statistiche di sistema', 'gepafin')}</h2>
|
||||
<div className="appPageSection columns">
|
||||
<ChartRichiesteVsApprovate
|
||||
title={__('Importi Richiesti VS Approvati', 'gepafin')}
|
||||
data={chartStats.requestedVsApprovedAmount}/>
|
||||
<ChartDomandePerStato
|
||||
title={__('Domande per stato', 'gepafin')}
|
||||
data={chartStats.applicationPerStatus}/>
|
||||
</div>
|
||||
</div> : null}
|
||||
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Ultime richieste di finanziamento', 'gepafin')}</h2>
|
||||
<BeneficiarioUltimeDomandeTable/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default StatsBeneficiary;
|
||||
@@ -50,6 +50,7 @@ import SoccorsoAddInstructorManager from './pages/SoccorsoAddInstructorManager';
|
||||
import SoccorsoEditInstructorManager from './pages/SoccorsoEditInstructorManager';
|
||||
import SoccorsoIstruttorioInstructorManager from './pages/SoccorsoIstruttorioInstructorManager';
|
||||
import SoccorsoIstruttorioMioInstructorManager from './pages/SoccorsoIstruttorioMioInstructorManager';
|
||||
import StatsBeneficiary from './pages/StatsBeneficiary';
|
||||
|
||||
const routes = ({ role, chosenCompanyId }) => {
|
||||
|
||||
@@ -236,6 +237,12 @@ const routes = ({ role, chosenCompanyId }) => {
|
||||
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
|
||||
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
|
||||
</DefaultLayout>}/>
|
||||
<Route path="/stats" element={<DefaultLayout>
|
||||
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
|
||||
{'ROLE_BENEFICIARY' === role ? <StatsBeneficiary/> : null}
|
||||
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
|
||||
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
|
||||
</DefaultLayout>}/>
|
||||
</Route>
|
||||
<Route exact path="/reset-password" element={<ResetPassword/>}/>
|
||||
<Route exact path="/login" element={<Login/>}/>
|
||||
|
||||
@@ -8,7 +8,21 @@ export default class ApplicationEvaluationService {
|
||||
NetworkService.get(`${API_BASE_URL}/applicationEvaluation/application`, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static getEvaluationV2ByApplId = (callback, errCallback, queryParams) => {
|
||||
NetworkService.get(`${API_BASE_URL}/applicationEvaluation/v2`, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static getEvaluationVersionByApplId = (id, callback, errCallback, queryParams) => {
|
||||
NetworkService.get(`${API_BASE_URL}/applicationEvaluation/application/${id}/version`, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static updateEvaluation = (assignedApplicationId, body, callback, errCallback, queryParams) => {
|
||||
NetworkService.put(`${API_BASE_URL}/applicationEvaluation/${assignedApplicationId}`, body, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static updateEvaluationV2 = (assignedApplicationId, formId, body, callback, errCallback, queryParams = []) => {
|
||||
NetworkService.put(`${API_BASE_URL}/applicationEvaluation/v2/assignedApplication/${assignedApplicationId}`, body, callback, errCallback, [
|
||||
['evaluationFormId', formId]
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ export default class ApplicationService {
|
||||
NetworkService.get(`${API_BASE_URL}/application`, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static getApplicationsPaginated = (body, callback, errCallback, queryParams) => {
|
||||
NetworkService.post(`${API_BASE_URL}/application/pagination`, body, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static getApplication = (id, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/application/${id}`, callback, errCallback);
|
||||
};
|
||||
|
||||
@@ -32,6 +32,10 @@ export default class BandoService {
|
||||
NetworkService.put(`${API_BASE_URL}/call/step2/${id}`, body, callback, errCallback);
|
||||
};
|
||||
|
||||
static updateBandoStep2V2 = (id, body, callback, errCallback) => {
|
||||
NetworkService.put(`${API_BASE_URL}/call/step2-v2/${id}`, body, callback, errCallback);
|
||||
};
|
||||
|
||||
static updateBandoStatus = (id, callback, errCallback, queryParams) => {
|
||||
NetworkService.put(`${API_BASE_URL}/call/${id}/status`, {}, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
@@ -23,4 +23,11 @@ export default class DashboardService {
|
||||
static getBeneficiaryStatsForCompany = (id, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/company/${id}`, callback, errCallback);
|
||||
};
|
||||
static getBeneficiaryStatsPage = (id, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/statistic/company/${id}`, callback, errCallback);
|
||||
};
|
||||
|
||||
static getInstructorAmendmentsStats = (callback, errCallback, queryParams) => {
|
||||
NetworkService.get(`${API_BASE_URL}/dashboard/instructor/amendment`, callback, errCallback, queryParams);
|
||||
};
|
||||
}
|
||||
|
||||
26
src/service/evaluation-forms-service.js
Normal file
26
src/service/evaluation-forms-service.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { NetworkService } from './network-service';
|
||||
|
||||
const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
|
||||
|
||||
export default class EvaluationFormsService {
|
||||
|
||||
static getFormForCall = (id, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/evaluationForm/call/${id}`, callback, errCallback);
|
||||
};
|
||||
|
||||
static createFormForCall = (id, body, callback, errCallback) => {
|
||||
NetworkService.post(`${API_BASE_URL}/evaluationForm/call/${id}`, body, callback, errCallback);
|
||||
};
|
||||
|
||||
static updateForm = (id, body, callback, errCallback, queryParams) => {
|
||||
NetworkService.put(`${API_BASE_URL}/evaluationForm/${id}`, body, callback, errCallback, queryParams);
|
||||
};
|
||||
|
||||
static getFormById = (id, callback, errCallback) => {
|
||||
NetworkService.get(`${API_BASE_URL}/evaluationForm/${id}`, callback, errCallback);
|
||||
};
|
||||
|
||||
static deleteForm = (id, callback, errCallback) => {
|
||||
NetworkService.delete(`${API_BASE_URL}/evaluationForm/${id}`, {}, callback, errCallback);
|
||||
};
|
||||
}
|
||||
@@ -16,6 +16,10 @@ export default class UserService {
|
||||
NetworkService.put(`${API_BASE_URL}/user/${id}`, body, callback, errCallback);
|
||||
};
|
||||
|
||||
static updateUserSelf = (id, body, callback, errCallback) => {
|
||||
NetworkService.put(`${API_BASE_URL}/user/${id}/update-details`, body, callback, errCallback);
|
||||
};
|
||||
|
||||
static createUser = (body, callback, errCallback) => {
|
||||
NetworkService.post(`${API_BASE_URL}/user`, body, callback, errCallback);
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ const initialStore = {
|
||||
formElements: [],
|
||||
elementItems: [],
|
||||
activeElement: '',
|
||||
selectedElement: '',
|
||||
draggingElementId: 0,
|
||||
bandoCriteria: [],
|
||||
// flow
|
||||
|
||||
@@ -185,6 +185,10 @@ export const elementItems = [
|
||||
{
|
||||
name: "label",
|
||||
value: "Casella di Spunta"
|
||||
},
|
||||
{
|
||||
name: "isChecklistItem",
|
||||
value: false
|
||||
}
|
||||
],
|
||||
validators: {
|
||||
@@ -459,5 +463,25 @@ export const elementItems = [
|
||||
validators: {
|
||||
custom: 'nonEmptyTables'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
sortOrder: 22,
|
||||
name: 'switch',
|
||||
label: 'Casella di spunta "Checklist"',
|
||||
description: 'Per selezioni binarie, accettazioni, conferme',
|
||||
settings: [
|
||||
{
|
||||
name: "label",
|
||||
value: "Casella di Spunta"
|
||||
},
|
||||
{
|
||||
name: "isChecklistItem",
|
||||
value: true
|
||||
}
|
||||
],
|
||||
validators: {
|
||||
isRequired: false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user