- added amendment stats;

- improved displaying messages during application validation;
This commit is contained in:
Vitalii Kiiko
2025-01-22 16:08:00 +01:00
parent 57995e9646
commit 578c45b764
7 changed files with 128 additions and 39 deletions

View File

@@ -165,13 +165,25 @@ const BandoApplication = () => {
const validateApplicationCallback = (data) => { const validateApplicationCallback = (data) => {
if (data.status === 'SUCCESS') { if (data.status === 'SUCCESS') {
if (data.data.status) { if (data.data.status) {
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'? setApplicationStatus(data.data.status);
} }
} }
storeSet.main.unsetAsyncRequest(); storeSet.main.unsetAsyncRequest();
} }
const errValidateApplicationCallback = (data) => { const errValidateApplicationCallback = (data) => {
if (data.status === 'VALIDATION_ERROR') {
if (formMsgs.current) {
formMsgs.current.show([
{
id: '99',
sticky: true, severity: 'error', summary: '',
detail: data.data.join(' '),
closable: true
}
]);
}
} else {
if (toast.current) { if (toast.current) {
toast.current.show({ toast.current.show({
severity: 'error', severity: 'error',
@@ -179,6 +191,7 @@ const BandoApplication = () => {
detail: data.message detail: data.message
}); });
} }
}
storeSet.main.unsetAsyncRequest(); storeSet.main.unsetAsyncRequest();
} }
@@ -260,7 +273,7 @@ const BandoApplication = () => {
{ {
id: '99', id: '99',
sticky: true, severity: 'error', summary: '', sticky: true, severity: 'error', summary: '',
detail: data.data.join(', '), detail: data.data.join(' '),
closable: true closable: true
} }
]); ]);
@@ -420,7 +433,9 @@ const BandoApplication = () => {
icon="pi pi-arrow-right" icon="pi pi-arrow-right"
iconPos="right"/> : null} iconPos="right"/> : null}
<Button <Button
type="button"
disabled={'SUBMIT' === applicationStatus || isExpired} disabled={'SUBMIT' === applicationStatus || isExpired}
onClick={onValidate}
label={__('Convalidare', 'gepafin')} label={__('Convalidare', 'gepafin')}
icon="pi pi-check" icon="pi pi-check"
iconPos="right"/> iconPos="right"/>
@@ -678,7 +693,7 @@ const BandoApplication = () => {
iconPos="right"/> iconPos="right"/>
</div> : null} </div> : null}
{'DRAFT' !== applicationStatus {'AWAITING' === applicationStatus
? <div className="appPageSection"> ? <div className="appPageSection">
<div className="appForm__field"> <div className="appForm__field">
<label htmlFor="signedPdfFile"> <label htmlFor="signedPdfFile">
@@ -701,7 +716,7 @@ const BandoApplication = () => {
</div> </div>
: null} : null}
{'DRAFT' !== applicationStatus {['AWAITING', 'READY'].includes(applicationStatus)
? <div className="appPageSection"> ? <div className="appPageSection">
<Button <Button
type="button" type="button"

View File

@@ -162,18 +162,18 @@ const BandoFlowEdit = () => {
const shoudDisableSaving = useCallback(() => { const shoudDisableSaving = useCallback(() => {
const nonEmptyFlowItems = flowStructure.flowData.filter(o => isEmpty(o.chosenField)).filter(o => !isEmpty(o.chosenValue)); const nonEmptyFlowItems = flowStructure.flowData.filter(o => isEmpty(o.chosenField)).filter(o => !isEmpty(o.chosenValue));
/*if (flowForms.length > 2) { /*if (forms.length > 2) {
console.log('disable BTN:', nonEmptyFlowItems.length !== flowForms.length - 2, isEmpty(flowEdges), 'PUBLISH' === bandoStatus, console.log('disable BTN:', nonEmptyFlowItems.length !== forms.length - 2, isEmpty(flowStructure.flowEdges), 'PUBLISH' === bandoStatus,
isEmpty(initialForm), isEmpty(finalForm)); isEmpty(flowStructure.initialForm), isEmpty(flowStructure.finalForm));
} else { } else {
console.log('disable BTN:', nonEmptyFlowItems.length !== 1, isEmpty(flowEdges), 'PUBLISH' === bandoStatus, console.log('disable BTN (2 forms):', isEmpty(flowStructure.flowEdges), 'PUBLISH' === bandoStatus,
isEmpty(initialForm), isEmpty(finalForm)); isEmpty(flowStructure.initialForm), isEmpty(flowStructure.finalForm));
}*/ }*/
return forms.length > 2 return forms.length > 2
? nonEmptyFlowItems.length !== forms.length - 2 || isEmpty(flowStructure.flowEdges) || 'PUBLISH' === bandoStatus ? nonEmptyFlowItems.length !== forms.length - 2 || isEmpty(flowStructure.flowEdges) || 'PUBLISH' === bandoStatus
|| isEmpty(flowStructure.initialForm) || isEmpty(flowStructure.finalForm) || isEmpty(flowStructure.initialForm) || isEmpty(flowStructure.finalForm)
: nonEmptyFlowItems.length !== 1 || isEmpty(flowStructure.flowEdges) || 'PUBLISH' === bandoStatus : isEmpty(flowStructure.flowEdges) || 'PUBLISH' === bandoStatus
|| isEmpty(flowStructure.initialForm) || isEmpty(flowStructure.finalForm); || isEmpty(flowStructure.initialForm) || isEmpty(flowStructure.finalForm);
}, [flowStructure, forms]); }, [flowStructure, forms]);

View File

@@ -817,13 +817,12 @@ const DomandaEditPreInstructor = () => {
onClick={doCreateAppointment} onClick={doCreateAppointment}
label={__('Crea l\'appuntamento', 'gepafin')} label={__('Crea l\'appuntamento', 'gepafin')}
/> : null} /> : null}
{APP_EVALUATION_FLOW_ID === '1' <Button
? <Button
type="button" type="button"
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)} disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
onClick={doMakeAdmisible} onClick={doMakeAdmisible}
label={__('Ammissibile formalmente', 'gepafin')} label={__('Ammissibile formalmente', 'gepafin')}
/> : null} />
{data.id {data.id
? <Button ? <Button
type="button" type="button"

View File

@@ -819,13 +819,12 @@ const DomandaEditPreInstructor = () => {
onClick={doCreateAppointment} onClick={doCreateAppointment}
label={__('Crea l\'appuntamento', 'gepafin')} label={__('Crea l\'appuntamento', 'gepafin')}
/> : null} /> : null}
{APP_EVALUATION_FLOW_ID === '1' <Button
? <Button
type="button" type="button"
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)} disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
onClick={doMakeAdmisible} onClick={doMakeAdmisible}
label={__('Ammissibile formalmente', 'gepafin')} label={__('Ammissibile formalmente', 'gepafin')}
/> : null} />
{data.id {data.id
? <Button ? <Button
type="button" type="button"

View File

@@ -200,7 +200,7 @@ const Domande = () => {
<span><NumberFlow <span><NumberFlow
value={getStatValue('evaluationAverageTime', 0)} value={getStatValue('evaluationAverageTime', 0)}
format={{ notation: 'compact' }} format={{ notation: 'compact' }}
suffix={` ${__('minuti', 'gepafin')}`} suffix={` ${__('giorni', 'gepafin')}`}
locales="it-IT"/></span> locales="it-IT"/></span>
</div> </div>
<div className="statsBigBadges__gridItem"> <div className="statsBigBadges__gridItem">

View File

@@ -1,10 +1,31 @@
import React from 'react'; import React, { useEffect, useState } from 'react';
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
// components // components
import PreInstructorSoccorsiTable from './components/PreInstructorSoccorsiTable'; import PreInstructorSoccorsiTable from './components/PreInstructorSoccorsiTable';
import DashboardService from '../../service/dashboard-service';
import { pathOr } from 'ramda';
import NumberFlow from '@number-flow/react';
const SoccorsoIstruttorioPreInstructor = () => { const SoccorsoIstruttorioPreInstructor = () => {
const [mainStats, setMainStats] = useState({});
const getStats = (data) => {
if (data.status === 'SUCCESS') {
setMainStats(data.data);
}
}
const errGetStats = () => {}
const getStatValue = (key, fallback = '') => {
return pathOr(fallback, [key], mainStats);
}
useEffect(() => {
DashboardService.getAmendmentsStats(getStats, errGetStats);
}, []);
return( return(
<div className="appPage"> <div className="appPage">
<div className="appPage__pageHeader"> <div className="appPage__pageHeader">
@@ -16,6 +37,57 @@ const SoccorsoIstruttorioPreInstructor = () => {
<div className="appPageSection"> <div className="appPageSection">
<PreInstructorSoccorsiTable/> <PreInstructorSoccorsiTable/>
</div> </div>
<div className="appPage__spacer"></div>
<div className="appPageSection statsBigBadges">
<h2>{__('Riepilogo', 'gepafin')}</h2>
<div className="statsBigBadges__grid applStats">
<div className="statsBigBadges__gridItem">
<span>{__('Totale richieste', 'gepafin')}</span>
<span><NumberFlow
value={getStatValue('totalAmendments', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/></span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('In attesa risposta', 'gepafin')}</span>
<span><NumberFlow
value={getStatValue('waitingForResponseAmendments', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/></span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Risposte ricevute', 'gepafin')}</span>
<span><NumberFlow
value={getStatValue('responseReceivedAmendments', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/></span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Tempo medio di risposta', 'gepafin')}</span>
<span><NumberFlow
value={getStatValue('averageResponseDays', 0)}
format={{ notation: 'compact' }}
suffix={` ${__('giorni', 'gepafin')}`}
locales="it-IT"/></span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Scadute', 'gepafin')}</span>
<span><NumberFlow
value={getStatValue('expiredAmendments', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/></span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Richieste in scadenza (48h)', 'gepafin')}</span>
<span><NumberFlow
value={getStatValue('expiringRequestsIn48Hours', 0)}
format={{ notation: 'compact' }}
locales="en-US"/></span>
</div>
</div>
</div>
</div> </div>
) )
} }

View File

@@ -12,6 +12,10 @@ export default class DashboardService {
NetworkService.get(`${API_BASE_URL}/dashboard/application`, callback, errCallback); NetworkService.get(`${API_BASE_URL}/dashboard/application`, callback, errCallback);
}; };
static getAmendmentsStats = (callback, errCallback) => {
NetworkService.get(`${API_BASE_URL}/dashboard/amendment`, callback, errCallback);
};
static getBeneficiaryStatsForCompany = (id, callback, errCallback) => { static getBeneficiaryStatsForCompany = (id, callback, errCallback) => {
NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/company/${id}`, callback, errCallback); NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/company/${id}`, callback, errCallback);
}; };