diff --git a/src/pages/DomandeInstructorManager/index.js b/src/pages/DomandeInstructorManager/index.js index b593398..fc68cec 100644 --- a/src/pages/DomandeInstructorManager/index.js +++ b/src/pages/DomandeInstructorManager/index.js @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react'; import { __ } from '@wordpress/i18n'; -import { isEmpty } from 'ramda'; +import { isEmpty, pathOr } from 'ramda'; // store import { storeSet } from '../../store'; @@ -20,6 +20,8 @@ import { classNames } from 'primereact/utils'; import { Dropdown } from 'primereact/dropdown'; import { Dialog } from 'primereact/dialog'; import { Button } from 'primereact/button'; +import DashboardService from '../../service/dashboard-service'; +import NumberFlow from '@number-flow/react'; const DomandeInstructorManager = () => { const [loading, setLoading] = useState(false); @@ -30,6 +32,7 @@ const DomandeInstructorManager = () => { const [chosenApplication, setChosenApplication] = useState(0); const [updaterString, setUpdaterString] = useState(''); const toast = useRef(null); + const [mainStats, setMainStats] = useState({}); const getRolesCallback = (data) => { if (data.status === 'SUCCESS') { @@ -123,6 +126,22 @@ const DomandeInstructorManager = () => { storeSet.main.unsetAsyncRequest(); } + const getStats = (data) => { + if (data.status === 'SUCCESS') { + setMainStats(data.data); + } + } + + const errGetStats = () => {} + + const getStatValue = (key, fallback = '') => { + return pathOr(fallback, [key], mainStats); + } + + useEffect(() => { + DashboardService.getEvaluationsStats(getStats, errGetStats); + }, []); + useEffect(() => { if (roleIds.length > 0) { setLoading(true); @@ -151,6 +170,57 @@ const DomandeInstructorManager = () => {
+
+

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

+
+
+ {__('Totale domande', 'gepafin')} + +
+
+ {__('In soccorso', 'gepafin')} + +
+
+ {__('In valutazione', 'gepafin')} + +
+
+ {__('Completate', 'gepafin')} + +
+
+ {__('Tempo medio di valutazione', 'gepafin')} + +
+
+ {__('Domande in scadenza (48h)', 'gepafin')} + +
+
+
+ +
+

{__('Domande pubblicate', 'gepafin')}

diff --git a/src/pages/DomandePreInstructor/index.js b/src/pages/DomandePreInstructor/index.js index 1a24b3d..00abd73 100644 --- a/src/pages/DomandePreInstructor/index.js +++ b/src/pages/DomandePreInstructor/index.js @@ -1,10 +1,31 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { __ } from '@wordpress/i18n'; // components import PreInstructorDomandeTable from '../DashboardPreInstructor/components/PreInstructorDomandeTable'; +import { pathOr } from 'ramda'; +import DashboardService from '../../service/dashboard-service'; +import NumberFlow from '@number-flow/react'; const DomandePreInstructor = () => { + 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.getEvaluationsStats(getStats, errGetStats); + }, []); + return(
@@ -16,6 +37,57 @@ const DomandePreInstructor = () => {
+ +
+ +
+

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

+
+
+ {__('Totale domande', 'gepafin')} + +
+
+ {__('In soccorso', 'gepafin')} + +
+
+ {__('In valutazione', 'gepafin')} + +
+
+ {__('Completate', 'gepafin')} + +
+
+ {__('Tempo medio di valutazione', 'gepafin')} + +
+
+ {__('Domande in scadenza (48h)', 'gepafin')} + +
+
+
) } diff --git a/src/service/dashboard-service.js b/src/service/dashboard-service.js index 6951e9c..093db59 100644 --- a/src/service/dashboard-service.js +++ b/src/service/dashboard-service.js @@ -16,6 +16,10 @@ export default class DashboardService { NetworkService.get(`${API_BASE_URL}/dashboard/amendment`, callback, errCallback); }; + static getEvaluationsStats = (callback, errCallback) => { + NetworkService.get(`${API_BASE_URL}/dashboard/evaluation`, callback, errCallback); + }; + static getBeneficiaryStatsForCompany = (id, callback, errCallback) => { NetworkService.get(`${API_BASE_URL}/dashboard/beneficiary/company/${id}`, callback, errCallback); };