|
|
|
|
@@ -4,6 +4,9 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|
|
|
|
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,31 +18,6 @@ import AppointmentService from '../../service/appointment-service';
|
|
|
|
|
|
|
|
|
|
// tools
|
|
|
|
|
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
|
|
|
|
import getBandoLabel from '../../helpers/getBandoLabel';
|
|
|
|
|
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
|
|
|
|
|
|
|
|
|
// components
|
|
|
|
|
import { Skeleton } from 'primereact/skeleton';
|
|
|
|
|
import { Button } from 'primereact/button';
|
|
|
|
|
import { Tag } from 'primereact/tag';
|
|
|
|
|
import { Checkbox } from 'primereact/checkbox';
|
|
|
|
|
import { Editor } from 'primereact/editor';
|
|
|
|
|
import { InputNumber } from 'primereact/inputnumber';
|
|
|
|
|
import { Toast } from 'primereact/toast';
|
|
|
|
|
import { Dialog } from 'primereact/dialog';
|
|
|
|
|
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 { useForm } from 'react-hook-form';
|
|
|
|
|
import {
|
|
|
|
|
isCAP,
|
|
|
|
|
isCodiceFiscale,
|
|
|
|
|
@@ -54,9 +32,25 @@ import formatDateString from '../../helpers/formatDateString';
|
|
|
|
|
import getTokens from '../../helpers/getTokens';
|
|
|
|
|
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
|
|
|
|
import renderWithDataVars from '../../helpers/renderWithDataVars';
|
|
|
|
|
import { evaluate } from 'mathjs';
|
|
|
|
|
import equal from 'fast-deep-equal';
|
|
|
|
|
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
|
|
|
|
|
|
|
|
|
// components
|
|
|
|
|
import { Skeleton } from 'primereact/skeleton';
|
|
|
|
|
import { Button } from 'primereact/button';
|
|
|
|
|
import { Tag } from 'primereact/tag';
|
|
|
|
|
import { Checkbox } from 'primereact/checkbox';
|
|
|
|
|
import { Editor } from 'primereact/editor';
|
|
|
|
|
import { InputNumber } from 'primereact/inputnumber';
|
|
|
|
|
import { Toast } from 'primereact/toast';
|
|
|
|
|
import { Dialog } from 'primereact/dialog';
|
|
|
|
|
import HelpIcon from '../../icons/HelpIcon';
|
|
|
|
|
import { classNames } from 'primereact/utils';
|
|
|
|
|
import { InputTextarea } from 'primereact/inputtextarea';
|
|
|
|
|
import { InputText } from 'primereact/inputtext';
|
|
|
|
|
import ListOfFiles from '../DomandaEditPreInstructor/components/ListOfFiles';
|
|
|
|
|
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
|
|
|
|
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;
|
|
|
|
|
@@ -126,7 +120,7 @@ const DomandaEditInstructorManager = () => {
|
|
|
|
|
navigate('/mie-domande');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const updateFlagsForSoccorso = (data) => {
|
|
|
|
|
const updateFlagsForSoccorso = useCallback((data) => {
|
|
|
|
|
let nonRatedFilesLength = 0;
|
|
|
|
|
|
|
|
|
|
if (data.files) {
|
|
|
|
|
@@ -145,14 +139,28 @@ const DomandaEditInstructorManager = () => {
|
|
|
|
|
|
|
|
|
|
setAllFilesRated(nonRatedFilesLength === 0);
|
|
|
|
|
|
|
|
|
|
if (data.checklist) {
|
|
|
|
|
const checkedChecklistItems = data.checklist
|
|
|
|
|
.map(el => el.valid)
|
|
|
|
|
.filter(v => v);
|
|
|
|
|
setAtLeastOneChecked(checkedChecklistItems.length > 0);
|
|
|
|
|
setAllChecksChecked(checkedChecklistItems.length === data.checklist.length)
|
|
|
|
|
if (data.evaluationVersion === 'V1') {
|
|
|
|
|
if (data.checklist) {
|
|
|
|
|
const checkedChecklistItems = data.checklist
|
|
|
|
|
.map(el => el.valid)
|
|
|
|
|
.filter(v => v);
|
|
|
|
|
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) {
|
|
|
|
|
@@ -191,24 +199,43 @@ const DomandaEditInstructorManager = () => {
|
|
|
|
|
storeSet.main.unsetAsyncRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getCallback = (data) => {
|
|
|
|
|
if (data.status === 'SUCCESS') {
|
|
|
|
|
setData(getFormattedData(data.data));
|
|
|
|
|
setMotivation(data.data.motivation);
|
|
|
|
|
updateFlagsForSoccorso(data.data);
|
|
|
|
|
const getCallback = (resp) => {
|
|
|
|
|
if (resp.status === 'SUCCESS') {
|
|
|
|
|
setData(getFormattedData(resp.data));
|
|
|
|
|
setMotivation(resp.data.motivation);
|
|
|
|
|
updateFlagsForSoccorso(resp.data);
|
|
|
|
|
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 = (data) => {
|
|
|
|
|
if (toast.current && data.message) {
|
|
|
|
|
const errGetCallback = (resp) => {
|
|
|
|
|
if (toast.current && resp.message) {
|
|
|
|
|
toast.current.show({
|
|
|
|
|
severity: 'error',
|
|
|
|
|
summary: '',
|
|
|
|
|
detail: data.message
|
|
|
|
|
detail: resp.message
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
set404FromErrorResponse(data);
|
|
|
|
|
set404FromErrorResponse(resp);
|
|
|
|
|
storeSet.main.unsetAsyncRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -834,6 +861,8 @@ const DomandaEditInstructorManager = () => {
|
|
|
|
|
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
|
|
|
|
reset(updatedFormValues);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateFlagsForSoccorso(data);
|
|
|
|
|
}, [formValues]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|