diff --git a/.env b/.env index 9ef0c84..ef5dcea 100644 --- a/.env +++ b/.env @@ -4,4 +4,5 @@ REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit REACT_APP_LOGO_FILENAME=gepafin-logo.svg REACT_APP_FAVICON_FILENAME=gepafin-favicon.ico REACT_APP_HUB_ID=p4lk3bcx1RStqTaIVVbXs -REACT_APP_EVALUATION_FLOW_ID=1 \ No newline at end of file +REACT_APP_EVALUATION_FLOW_ID=1 +REACT_APP_LOCAL_DEVELOPMENT=1 \ No newline at end of file diff --git a/package.json b/package.json index 145700c..3331909 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@date-fns/tz": "1.2.0", "@emailjs/browser": "4.4.1", "@emotion/styled": "11.13.5", - "@number-flow/react": "0.4.1", + "@number-flow/react": "0.4.2", "@sentry/browser": "^8.41.0", "@tanstack/react-table": "^8.20.5", "@wordpress/i18n": "5.13.0", diff --git a/src/assets/scss/components/appPage.scss b/src/assets/scss/components/appPage.scss index 8f40ad9..da0721a 100644 --- a/src/assets/scss/components/appPage.scss +++ b/src/assets/scss/components/appPage.scss @@ -342,6 +342,10 @@ .appPageSection__row { display: flex; gap: 1rem; + + &.autoFlow { + flex-wrap: wrap; + } } .appPageSection__pMeta { diff --git a/src/assets/scss/components/misc.scss b/src/assets/scss/components/misc.scss index ca53588..b809ae8 100644 --- a/src/assets/scss/components/misc.scss +++ b/src/assets/scss/components/misc.scss @@ -12,6 +12,10 @@ .p-button:not(.p-button-outlined, .p-button-secondary, .p-confirm-popup-reject, .p-button-link, .p-column-filter-add-button, .p-column-filter-remove-button) span { color: var(--menuitem-active-color); } +.p-button.p-button-success.p-button-icon-only[disabled], +.p-button.p-button-danger.p-button-icon-only[disabled] { + filter: unset; +} .p-column-filter-remove-button { span { margin: 0 5px; diff --git a/src/components/ErrorBoundary/index.js b/src/components/ErrorBoundary/index.js new file mode 100644 index 0000000..6521776 --- /dev/null +++ b/src/components/ErrorBoundary/index.js @@ -0,0 +1,31 @@ +import React, { Component } from 'react'; +import logMsgWithSentry from '../../helpers/logMsgWithSentry'; + +class ErrorBoundary extends Component { + constructor(props) { + super(props); + + this.state = { + builderError: false + }; + } + + static getDerivedStateFromError(error) { + try { + logMsgWithSentry('', 0, {}, error); + } catch (err) { + console.log(err); + } + return { builderError: true }; + } + + render() { + if (this.state.builderError) { + return
Error
; + } + + return this.props.children; + } +} + +export default ErrorBoundary; \ No newline at end of file diff --git a/src/components/ProtectedRoute/index.js b/src/components/ProtectedRoute/index.js index f50b3f8..a5620f8 100644 --- a/src/components/ProtectedRoute/index.js +++ b/src/components/ProtectedRoute/index.js @@ -3,6 +3,7 @@ import { Navigate, Outlet } from 'react-router-dom'; // tools import AuthenticationService from '../../service/authentication-service'; +import ErrorBoundary from '../ErrorBoundary'; const ProtectedRoute = () => { @@ -22,7 +23,7 @@ const ProtectedRoute = () => { return (); }*/ - return ; + return ; } export default ProtectedRoute; \ No newline at end of file diff --git a/src/configData.js b/src/configData.js index 81eadc2..c8827e7 100644 --- a/src/configData.js +++ b/src/configData.js @@ -44,4 +44,111 @@ export const dynamicDataOptions = { ], textinput: dynamicDataForTextinput, textarea: dynamicDataForTextinput -} \ No newline at end of file +} + +export const protocolType = [ + { + 'id': 1, + 'name': 'PROTOCOLLO IN ENTRATA' + }, + { + 'id': 2, + 'name': 'PROTOCOLLO IN USCITA' + }, + { + 'id': 3, + 'name': 'DOCUMENTO INTERNO' + }, + { + 'id': 1003, + 'name': 'PROTOCOLLO INTERNO ' + } +]; + +export const classificationType = [ + { + 'idClassificazione': 101, + 'name': 'BILANCIO', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 102, + 'name': 'DICHHIARAZIONE DEI REDDITI', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 103, + 'name': 'SITUAZIONE CONTABILE', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 104, + 'name': 'PROSPETTO CONTO ECONOMICO', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 105, + 'name': 'CENTRALE DEI RISCHI', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 106, + 'name': 'RELAZIONE AZIENDALE ILLUSTRATIVA (MOD R1C, R1I, R1R, R1R A SECONDO DEI ', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 107, + 'name': 'DOCUMENTO IDENTITA\'', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 108, + 'name': 'MODELLO SP1', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 109, + 'name': 'PRIVACY', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 110, + 'name': 'DOCUMENTAZIONE CHE ATTESTA POSSIBILITA\' DI RILASCIARE GAA FAVORE', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 111, + 'name': 'MODELLO AR1 D.LG 231/2007', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 112, + 'name': 'DOCUMENTO IDENTITA\' FIRMATORIO DICHHIARAZIONE SOSTITUTIVA', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 113, + 'name': 'PRIVACY FIRMATARIO DICHHIARAZIONE SOSTITUTIVA', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 114, + 'name': 'NULLAOSTA ANTIMAFIA', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 201, + 'name': 'LETTERA ESITO DELIBERA', + 'idTipoprotocollo': 2 + }, + { + 'idClassificazione': 202, + 'name': 'LETTERA DI GARANZIA', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 203, + 'name': 'GENERICO', + 'idTipoprotocollo': 3 + } +]; \ No newline at end of file diff --git a/src/helpers/formatDateString.js b/src/helpers/formatDateString.js index 9c08c55..9690a1b 100644 --- a/src/helpers/formatDateString.js +++ b/src/helpers/formatDateString.js @@ -4,7 +4,6 @@ * @return {string} */ const formatDateString = (date) => { - console.log('date', date); const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); diff --git a/src/helpers/getBandoLabel.js b/src/helpers/getBandoLabel.js index c48db88..9c8af0f 100644 --- a/src/helpers/getBandoLabel.js +++ b/src/helpers/getBandoLabel.js @@ -20,6 +20,15 @@ const getBandoLabel = (status) => { case 'READY': return __('Pronto', 'gepafin'); + case 'NDG': + return __('NDG', 'gepafin'); + + case 'APPOINTMENT': + return __('Appuntamento', 'gepafin'); + + case 'ADMISSIBLE': + return __('Ammisibile', 'gepafin'); + case 'SOCCORSO': return __('Soccorso', 'gepafin'); diff --git a/src/helpers/getBandoSeverity.js b/src/helpers/getBandoSeverity.js index 9cb6b89..9b9d16c 100644 --- a/src/helpers/getBandoSeverity.js +++ b/src/helpers/getBandoSeverity.js @@ -18,6 +18,15 @@ const getBandoSeverity = (status) => { case 'READY': return 'info'; + case 'NDG': + return 'info'; + + case 'APPOINTMENT': + return 'info'; + + case 'ADMISSIBLE': + return 'info'; + case 'SOCCORSO': return 'warning'; diff --git a/src/helpers/logMsgWithSentry.js b/src/helpers/logMsgWithSentry.js new file mode 100644 index 0000000..5dee179 --- /dev/null +++ b/src/helpers/logMsgWithSentry.js @@ -0,0 +1,31 @@ +import * as Sentry from '@sentry/browser'; + +const LOCAL_DEVELOPMENT = process.env.REACT_APP_LOCAL_DEVELOPMENT; + +const logMsgWithSentry = (endpoint = '', status = 0, resp = {}, error = null) => { + try { + if (LOCAL_DEVELOPMENT !== '1') { + Sentry.init({ + dsn: 'https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392', + environment: process.env.NODE_ENV || 'development' + }); + + if (!error) { + const newError = new Error(`Status ${status}`); + Sentry.captureException(`Error in endpoint: ${endpoint}`, { + level: 'error', + extra: { + originalError: newError, + details: resp + } + }); + } else { + Sentry.captureException(error); + } + } + } catch (err) { + console.log(err); + } +} + +export default logMsgWithSentry; \ No newline at end of file diff --git a/src/helpers/validators.js b/src/helpers/validators.js index 3a05435..388f318 100644 --- a/src/helpers/validators.js +++ b/src/helpers/validators.js @@ -4,6 +4,7 @@ import CodiceFiscale from 'codice-fiscale-js'; export const isPIVA = (v) => { const regexp = new RegExp(/^[0-9]{11}$/); + //console.log('isPIVA', !isEmpty(match(regexp, String(v)))) return !isEmpty(match(regexp, String(v))); } @@ -11,6 +12,7 @@ export const isPIVA = (v) => { export const isCodiceFiscale = (v) => { //const regexp = new RegExp(/^(?:[A-Z][AEIOU][AEIOUX]|[AEIOU]X{2}|[B-DF-HJ-NP-TV-Z]{2}[A-Z]){2}(?:[\dLMNP-V]{2}(?:[A-EHLMPR-T](?:[04LQ][1-9MNP-V]|[15MR][\dLMNP-V]|[26NS][0-8LMNP-U])|[DHPS][37PT][0L]|[ACELMRT][37PT][01LM]|[AC-EHLMPR-T][26NS][9V])|(?:[02468LNQSU][048LQU]|[13579MPRTV][26NS])B[26NS][9V])(?:[A-MZ][1-9MNP-V][\dLMNP-V]{2}|[A-M][0L](?:[1-9MNP-V][\dLMNP-V]|[0L][1-9MNP-V]))[A-Z]$/, 'i') //return !isEmpty(match(regexp, v)); + //console.log('isCodiceFiscale', CodiceFiscale.check(v)) return CodiceFiscale.check(v); } diff --git a/src/pages/AddCompany/index.js b/src/pages/AddCompany/index.js index 57d6d83..9a80617 100644 --- a/src/pages/AddCompany/index.js +++ b/src/pages/AddCompany/index.js @@ -19,9 +19,11 @@ import BlockingOverlay from '../../components/BlockingOverlay'; import CompanyService from '../../service/company-service'; // tools -import { isPIVA, isEmail, isEmailPEC } from '../../helpers/validators'; +import { isPIVA, isEmail, isEmailPEC, isCodiceFiscale } from '../../helpers/validators'; import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; +//const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID; + const AddCompany = () => { const navigate = useNavigate(); const isAsyncRequest = useStore().main.isAsyncRequest(); @@ -33,12 +35,14 @@ const AddCompany = () => { handleSubmit, formState: { errors }, setValue, - watch + watch, + trigger } = useForm({ defaultValues: {}, mode: 'onChange' }); const isPiva = watch('vatNumber'); + //const isPiva = watch('vatNumber'); const setEmptyValues = () => { const formData = { @@ -116,7 +120,7 @@ const AddCompany = () => { pec, email: pec, city: comune, - codiceFiscale: cf, + codiceFiscale: cf ? cf : piva, address: indirizzo, vatNumber: piva, companyName: denominazione @@ -127,6 +131,7 @@ const AddCompany = () => { } else { setEmptyValues(); } + trigger(); storeSet.main.unsetAsyncRequest(); } @@ -136,6 +141,11 @@ const AddCompany = () => { storeSet.main.unsetAsyncRequest(); } + /*const shouldDisableFiscalCode = () => { + const formData = getValues(); + return !formData.type || formData.type && formData.type === 'giuridica'; + }*/ + useEffect(() => { setInputPiva(isPiva); }, [isPiva]); @@ -174,6 +184,23 @@ const AddCompany = () => { /> + {/*{APP_EVALUATION_FLOW_ID === '2' + ?
+ +
: null}*/} +
{ label={__('P.IVA', 'gepafin')} control={control} errors={errors} - config={{ required: __('È obbligatorio', 'gepafin') }} + config={{ + required: __('È obbligatorio', 'gepafin'), + validate: { + isPIVA + } + }} /> isCodiceFiscale(value) || isPIVA(value) + } + }} /> + {/*{APP_EVALUATION_FLOW_ID === '1' + ? + : }*/}
diff --git a/src/pages/Applications/index.js b/src/pages/Applications/index.js index 08b1012..ad3393f 100644 --- a/src/pages/Applications/index.js +++ b/src/pages/Applications/index.js @@ -5,6 +5,7 @@ import { useNavigate } from 'react-router-dom'; // components import MyLatestSubmissionsTable from '../DashboardBeneficiario/components/MyLatestSubmissionsTable'; import { Button } from 'primereact/button'; +import ErrorBoundary from '../../components/ErrorBoundary'; const Applications = () => { const navigate = useNavigate(); @@ -22,7 +23,7 @@ const Applications = () => {
- +
diff --git a/src/pages/BandiBeneficiario/index.js b/src/pages/BandiBeneficiario/index.js index be925d3..5a191be 100644 --- a/src/pages/BandiBeneficiario/index.js +++ b/src/pages/BandiBeneficiario/index.js @@ -8,6 +8,7 @@ import { useStore } from '../../store'; // components import AllBandiAccordion from './components/AllBandiAccordion'; +import ErrorBoundary from '../../components/ErrorBoundary'; const BandiBeneficiario = () => { const chosenCompanyId = useStore().main.chosenCompanyId(); @@ -34,7 +35,7 @@ const BandiBeneficiario = () => { : null}
- +
) diff --git a/src/pages/DashboardBeneficiario/index.js b/src/pages/DashboardBeneficiario/index.js index 66ac510..cc12f6e 100644 --- a/src/pages/DashboardBeneficiario/index.js +++ b/src/pages/DashboardBeneficiario/index.js @@ -14,6 +14,7 @@ import DashboardService from '../../service/dashboard-service'; import LatestBandiTable from './components/LatestBandiTable'; import MyLatestSubmissionsTable from './components/MyLatestSubmissionsTable'; import { Button } from 'primereact/button'; +import ErrorBoundary from '../../components/ErrorBoundary'; const DashboardBeneficiario = () => { const navigate = useNavigate(); @@ -85,7 +86,7 @@ const DashboardBeneficiario = () => {

{__('Domande in lavorazione', 'gepafin')}

- +
@@ -105,7 +106,7 @@ const DashboardBeneficiario = () => {

{__('Bandi disponibili', 'gepafin')}

- +
diff --git a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js index 537fa3c..33dcab7 100644 --- a/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js +++ b/src/pages/DashboardPreInstructor/components/PreInstructorDomandeTable/index.js @@ -54,7 +54,7 @@ const PreInstructorDomandeTable = () => { const getFormattedData = (data) => { return data.map((d) => { - d.callEndDate = is(String, d.callEndDate) ? new Date(d.callEndDate) : (d.callEndDate ? d.callEndDate : ''); + d.evaluationEndDate = is(String, d.evaluationEndDate) ? new Date(d.evaluationEndDate) : (d.evaluationEndDate ? d.evaluationEndDate : ''); d.submissionDate = is(String, d.submissionDate) ? new Date(d.submissionDate) : (d.submissionDate ? d.submissionDate : ''); return d; }); @@ -87,7 +87,7 @@ const PreInstructorDomandeTable = () => { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] }, - callEndDate : { + evaluationEndDate: { operator: FilterOperator.AND, constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }] } @@ -107,7 +107,7 @@ const PreInstructorDomandeTable = () => { }; const dateEndBodyTemplate = (rowData) => { - return formatDate(rowData.callEndDate); + return formatDate(rowData.evaluationEndDate); }; const dateFilterTemplate = (options) => { @@ -144,6 +144,15 @@ const PreInstructorDomandeTable = () => { + + + { - {
{data.id ?
-

- {__('ID domanda', 'gepafin')} - {data.applicationId} -

-

- {__('Bando', 'gepafin')} - {data.callName} -

-

- {__('Beneficiario', 'gepafin')} - {data.beneficiaryName} -

-

- {__('Inizio', 'gepafin')} - {getDateFromISOstring(data.startDate)} -

-

- {__('Scadenza', 'gepafin')} - {getDateFromISOstring(data.expirationDate)} -

-

- {__('Stato', 'gepafin')} - {getBandoLabel(data.status)} -

-
: null} +

+ {__('ID domanda', 'gepafin')} + {data.applicationId} +

+

+ {__('Bando', 'gepafin')} + {data.callName} +

+

+ {__('Beneficiario', 'gepafin')} + {data.beneficiaryName} +

+

+ {__('Azienda', 'gepafin')} + +

+

+ {__('Inizio', 'gepafin')} + {getDateFromISOstring(data.startDate)} +

+

+ {__('Scadenza', 'gepafin')} + {getDateFromISOstring(data.expirationDate)} +

+

+ {__('Stato', 'gepafin')} + {getBandoLabel(data.status)} +

+
: null} {dataAppl.id ?

- {__('ID domanda', 'gepafin')} + {__('ID domanda', 'gepafin')} {dataAppl.id}

@@ -289,6 +293,7 @@ const DomandaBeneficiario = () => { errors={errors} defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []} accept={[]} + source="AMENDMENT" sourceId={data.applicationId} multiple={true} /> diff --git a/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js b/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js index e0124e5..936e2bc 100644 --- a/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js +++ b/src/pages/DomandaEditPreInstructor/components/ArchiveDocument/index.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { __ } from '@wordpress/i18n'; import { isEmpty } from 'ramda'; import { wrap } from 'object-path-immutable'; @@ -9,24 +9,37 @@ import { Dialog } from 'primereact/dialog'; import { InputTextarea } from 'primereact/inputtextarea'; import { Dropdown } from 'primereact/dropdown'; import { classNames } from 'primereact/utils'; +import { InputSwitch } from 'primereact/inputswitch'; +import { InputText } from 'primereact/inputtext'; -const ArchiveDocument = ({ ndg = '', fileId = 0 }) => { +import { classificationType, protocolType } from '../../../../configData'; +import AppointmentService from '../../../../service/appointment-service'; +import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse'; +import { storeSet } from '../../../../store'; +import { Toast } from 'primereact/toast'; + +const ArchiveDocument = ({ applicationId, ndg = '', fileId = 0 }) => { const [loading, setLoading] = useState(false); const [isVisibleDialog, setIsVisibleDialog] = useState(false); const [modalData, setModalData] = useState({}); + const [types, setTypes] = useState([]); const [categories, setCategories] = useState([]); + const toast = useRef(null); const openArchivationModal = () => { setIsVisibleDialog(true); setModalData({ - description: '', - categoryId: 0, + descrizione: '', + idTipoProtocollo: 0, + idClassificazione: 0, + flagDaFirmare: false, + email: '', fileId }); } const headerDialog = () => { - return {__('Archive document', 'gepafin')}; + return {__('Archiviazione del documento', 'gepafin')}; } const hideDialog = () => { @@ -50,57 +63,141 @@ const ArchiveDocument = ({ ndg = '', fileId = 0 }) => { } const submitData = () => { - console.log('submitData', modalData); - //setLoading(true); + if ( + modalData.idTipoProtocollo !== 0 && modalData.idClassificazione !== 0 + && !isEmpty(modalData.descrizione) && !isEmpty(modalData.email) + ) { + setLoading(true); + const submitData = { + 'input': { + 'idTipoProtocollo': modalData.idTipoProtocollo, + 'idClassificazione': modalData.idClassificazione, + 'flagDaFirmare': modalData.flagDaFirmare, + 'descrizione': modalData.descrizione, + 'attributes': { + 'ndg': ndg, + 'email': modalData.email + } + } + } + + AppointmentService.archiveDocument(applicationId, fileId, submitData, submitCallback, errSubmitCallback) + } + } + + const submitCallback = (data) => { + if (data.status === 'SUCCESS') { + console.log(data.data); + } + setLoading(false); + } + + const errSubmitCallback = (data) => { + if (toast.current && data.message) { + toast.current.show({ + severity: 'error', + summary: '', + detail: data.message + }); + } + set404FromErrorResponse(data); + setLoading(false); } useEffect(() => { - setCategories([ - {value: 1, label: 'Type 1'}, - {value: 2, label: 'Type 2'}, - ]) + const newModalData = { + ...modalData, + idClassificazione: 0 + }; + setModalData(newModalData); + setCategories(classificationType + .filter(o => o.idTipoprotocollo === modalData.idTipoProtocollo) + .map(o => ({ value: o.idClassificazione, label: o.name }))); + }, [modalData.idTipoProtocollo]) + + useEffect(() => { + setTypes(protocolType.map(o => ({ value: o.id, label: o.name }))); }, []); - return ( - <> - {!isEmpty(ndg) - ?

+ + {o.fileDetail && o.fileDetail.length > 1 + ?
    + {o.fileDetail.map((k) =>
  • + {k.name} +
    + +
    +
  • )} +
+ : null} + )} + + ) +} + +export default ListOfFiles; diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js index c5ef10f..0995089 100644 --- a/src/pages/DomandaEditPreInstructor/index.js +++ b/src/pages/DomandaEditPreInstructor/index.js @@ -32,6 +32,11 @@ import ArchiveDocument from './components/ArchiveDocument'; 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 AppointmentService from '../../service/appointment-service'; +import ListOfFiles from './components/ListOfFiles'; const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID; @@ -51,6 +56,9 @@ const DomandaEditPreInstructor = () => { const [operationType, setOperationType] = useState(''); const [motivation, setMotivation] = useState(''); const [isVisibleAppointmentDialog, setIsVisibleAppointmentDialog] = useState(false); + const [allFilesRated, setAllFilesRated] = useState(false); + const [atLeastOneChecked, setAtLeastOneChecked] = useState(false); + const [allChecksChecked, setAllChecksChecked] = useState(false); const [appointmentData, setAppointmentData] = useState({ title: '', text: '', @@ -62,6 +70,22 @@ const DomandaEditPreInstructor = () => { navigate('/domande'); } + const updateFlagsForSoccorso = (data) => { + if (data.files) { + const nonRatedFiles = data.files + .map(el => el.valid) + .filter(v => isNil(v)); + setAllFilesRated(nonRatedFiles.length === 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) + } + } + const doNewSoccorso = () => { if (connectedSoccorsoId !== 0) { doSaveDraft(`/domande/${id}/soccorso/${connectedSoccorsoId}`) @@ -74,6 +98,7 @@ const DomandaEditPreInstructor = () => { if (data.status === 'SUCCESS') { setData(getFormattedData(data.data)); setMotivation(data.data.motivation); + updateFlagsForSoccorso(data.data); } storeSet.main.unsetAsyncRequest(); } @@ -116,15 +141,16 @@ const DomandaEditPreInstructor = () => { const header = renderHeader(); - const updateEvaluationValue = (value, path, maxValue) => { + const updateEvaluationValue = (value, path, maxValue = null) => { let finalValue = value; if (maxValue || maxValue === 0) { finalValue = value > maxValue ? maxValue : value; } - const newData = wrap(data).set(path.split('.'), finalValue).value(); + const newData = wrap(data).set(path, finalValue).value(); setData(newData); + updateFlagsForSoccorso(newData); } const doSaveDraft = (doRedirect = '') => { @@ -134,6 +160,7 @@ const DomandaEditPreInstructor = () => { files: klona(data.files), note: data.note } + ApplicationEvaluationService.updateEvaluation( data.assignedApplicationId, formData, @@ -241,9 +268,11 @@ const DomandaEditPreInstructor = () => { switch (item.fieldName) { case 'fileupload' : content =
    - {item.fieldValue.map(o =>
  • - {o.filePath ? {o.name} : null} -
  • )} + {item.fieldValue + ? item.fieldValue.map(o =>
  • + {o.filePath ? {o.name} : null} +
  • ) + : null}
; break; case 'table' : @@ -255,9 +284,11 @@ const DomandaEditPreInstructor = () => { - {item.fieldValue.map((o, i) => - {Object.values(o).map(v => {v})} - )} + {item.fieldValue + ? item.fieldValue.map((o, i) => + {Object.values(o).map(v => {v})} + ) + : null} ; break; @@ -336,7 +367,30 @@ const DomandaEditPreInstructor = () => { } const doCheckNDG = () => { - // TODO + storeSet.main.setAsyncRequest(); + doSaveDraft(); + setTimeout(() => { + AppointmentService.getNdg(id, getNdgCallback, errGetNdgCallback); + }, 100); + } + + const getNdgCallback = (data) => { + if (data.status === 'SUCCESS') { + console.log('data', data.data); + } + storeSet.main.unsetAsyncRequest(); + } + + const errGetNdgCallback = (data) => { + if (toast.current && data.message) { + toast.current.show({ + severity: 'error', + summary: '', + detail: data.message + }); + } + set404FromErrorResponse(data); + storeSet.main.unsetAsyncRequest(); } const doCreateAppointment = () => { @@ -376,7 +430,7 @@ const DomandaEditPreInstructor = () => { const doCreateAppointmentRequest = () => { if ( !isEmpty(appointmentData.title) && !isEmpty(appointmentData.text) && !isEmpty(appointmentData.amount) - && !isEmpty(appointmentData.duration) && appointmentData.duration !== 0 && appointmentData.amount !== 0 + && !isEmpty(appointmentData.duration) && appointmentData.duration !== 0 && appointmentData.amount !== 0 ) { console.log(appointmentData); //setLoading(true); @@ -436,6 +490,18 @@ const DomandaEditPreInstructor = () => { {__('ID domanda', 'gepafin')} {data.applicationId}

+

+ {__('Protocollo', 'gepafin')} + {data.protocolNumber} +

+

+ {__('NDG', 'gepafin')} + {data.ndg} +

+

+ {__('Appuntamento', 'gepafin')} + {data.appointmentId} +

{__('Bando', 'gepafin')} {data.callName} @@ -444,13 +510,21 @@ const DomandaEditPreInstructor = () => { {__('Beneficiario', 'gepafin')} {data.beneficiary}

+

+ {__('Azienda', 'gepafin')} + {data.companyName} +

{__('Data ricezione', 'gepafin')} {getDateFromISOstring(data.submissionDate)}

+

+ {__('Data assegnazione', 'gepafin')} + {getDateFromISOstring(data.assignedAt)} +

{__('Scadenza Valutazione', 'gepafin')} - {getDateFromISOstring(data.callEndDate)} + {getDateFromISOstring(data.evaluationEndDate)}

{__('Stato', 'gepafin')} @@ -458,7 +532,64 @@ const DomandaEditPreInstructor = () => {

-
+
+

{__('Scarica documenti della domanda', 'gepafin')}

+
+ + + +
+
+ +
+

{__('Checklist Valutazione', 'gepafin')}

+
+
+ +

{__('Lista', 'gepafin')}

+
+
+ {data.checklist.map((o, i) =>
+ updateEvaluationValue( + e.checked, + ['checklist', i, 'valid'] + )} + checked={o.valid}> + +
)} +
+
+ +

{__('Note', 'gepafin')}

+
+ updateEvaluationValue( + e.htmlValue, + ['note'] + )} + style={{ height: 80 * 3, width: '100%' }} + /> +
+
+
+

{__('Documenti allegati', 'gepafin')}

+ +
+
+

{__('Punteggi di valutazione', 'gepafin')}

@@ -484,8 +615,8 @@ const DomandaEditPreInstructor = () => { max={o.maxScore} onChange={(e) => updateEvaluationValue( e.value, - `criteria.${i}.score`, - o.maxScore + ['criteria', i, 'score'], + o.criteria )}/> / {o.maxScore} @@ -504,7 +635,7 @@ const DomandaEditPreInstructor = () => { severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'} onClick={() => updateEvaluationValue( true, - `criteria.${i}.valid` + ['criteria', i, 'valid'] )} aria-label={__('Su', 'gepafin')}/>
@@ -539,104 +670,6 @@ const DomandaEditPreInstructor = () => { : null} -
-

{__('Checklist Valutazione', 'gepafin')}

-
-
- -

{__('Lista', 'gepafin')}

-
-
- {data.checklist.map((o, i) =>
- updateEvaluationValue( - e.checked, - `checklist.${i}.valid` - )} - checked={o.valid}> - -
)} -
-
- -

{__('Note', 'gepafin')}

-
- updateEvaluationValue( - e.htmlValue, - 'note' - )} - style={{ height: 80 * 3, width: '100%' }} - /> -
-
-
-

{__('Documenti allegati', 'gepafin')}

-
    - {data.files.map((o, i) =>
  1. -
    - {o.label} -
    - {o.fileDetail && o.fileDetail.length === 1 - ?
    -
    - {o.fileDetail && o.fileDetail.length > 1 - ?
      - {o.fileDetail.map((k, i) =>
    • - {k.name} -
      - -
      -
    • )} -
    - : null} -
  2. )} -
-
-
-
-
@@ -647,36 +680,36 @@ const DomandaEditPreInstructor = () => {
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus) ?