- saving progress;

This commit is contained in:
Vitalii Kiiko
2025-01-15 16:15:43 +01:00
parent 5d740c1069
commit f4aef02941
5 changed files with 89 additions and 33 deletions

View File

@@ -22,7 +22,10 @@ const ChartDomandePerBando = ({ title, data = [] }) => {
<div className="chartCard__tooltip"> <div className="chartCard__tooltip">
<p className="chartCard__tooltipTitle">{label}</p> <p className="chartCard__tooltipTitle">{label}</p>
<p className="chartCard__tooltipText"> <p className="chartCard__tooltipText">
{__('Domande', 'gepafin')}: {payload[0].value} {__('In bozza', 'gepafin')}: {payload[0].value}
</p>
<p className="chartCard__tooltipText">
{__('Inviate', 'gepafin')}: {payload[1].value}
</p> </p>
</div> </div>
); );
@@ -50,7 +53,8 @@ const ChartDomandePerBando = ({ title, data = [] }) => {
<YAxis/> <YAxis/>
<Tooltip content={<CustomTooltip/>}/> <Tooltip content={<CustomTooltip/>}/>
<Legend/> <Legend/>
<Bar dataKey="numberOfApplications" fill="#EEC137" name={__('Quantità delle domande', 'gepafin')}/> <Bar dataKey="numberOfDraftApplications" fill="#8884d8" name={__('Domande in bozza', 'gepafin')}/>
<Bar dataKey="numberOfSubmitedApplications" fill="#EEC137" name={__('Domande inviate', 'gepafin')}/>
</BarChart> </BarChart>
</ResponsiveContainer> </ResponsiveContainer>
</div> : null} </div> : null}

View File

@@ -38,7 +38,7 @@ const ChartStatoDomande = ({ title, data = [] }) => {
label={({ percent }) => `${(percent * 100).toFixed(0)}%`} label={({ percent }) => `${(percent * 100).toFixed(0)}%`}
outerRadius={120} outerRadius={120}
fill="#8884d8" fill="#8884d8"
dataKey="numberOfApplications" dataKey="numberOfSubmitedApplications"
nameKey="status" nameKey="status"
> >
{data.map((entry, index) => ( {data.map((entry, index) => (

View File

@@ -15,6 +15,7 @@ import getDateFromISOstring from '../../helpers/getDateFromISOstring';
import { Button } from 'primereact/button'; import { Button } from 'primereact/button';
import { Toast } from 'primereact/toast'; import { Toast } from 'primereact/toast';
import { Dropdown } from 'primereact/dropdown'; import { Dropdown } from 'primereact/dropdown';
import UserActionService from '../../service/user-action-service';
const UserActivity = () => { const UserActivity = () => {
@@ -25,6 +26,8 @@ const UserActivity = () => {
const [user, setUser] = useState({}); const [user, setUser] = useState({});
const [roles, setRoles] = useState([]); const [roles, setRoles] = useState([]);
const [chosenRole, setChosenRole] = useState(0); const [chosenRole, setChosenRole] = useState(0);
const [actionsContext, setActionsContext] = useState([]);
const [userActions, setUserActions] = useState({});
const goBack = () => { const goBack = () => {
navigate(`/utenti`); navigate(`/utenti`);
@@ -56,13 +59,13 @@ const UserActivity = () => {
} }
const getStatValue = (key, fallback = 0) => { const getStatValue = (key, fallback = 0) => {
return pathOr(fallback, [key], {}); return pathOr(fallback, [key], userActions);
} }
const handleRoleUpdate = () => { const handleRoleUpdate = () => {
if (user.role?.id !== chosenRole) { if (user.role?.id !== chosenRole) {
setLoading(true); setLoading(true);
UserService.updateUser(user.id, {roleId: chosenRole}, updateRoleCallback, errUpdateRoleCallback) UserService.updateUser(user.id, { roleId: chosenRole }, updateRoleCallback, errUpdateRoleCallback)
} }
} }
@@ -78,11 +81,37 @@ const UserActivity = () => {
setLoading(false); setLoading(false);
} }
const getActionsContextCallback = (resp) => {
if (resp.status === 'SUCCESS') {
setActionsContext(resp.data)
}
setLoading(false);
}
const errGetActionsContextCallback = (resp) => {
set404FromErrorResponse(resp);
setLoading(false);
}
const getUserActionsCallback = (resp) => {
if (resp.status === 'SUCCESS') {
setUserActions(resp.data)
}
setLoading(false);
}
const errGetUserActionsCallback = (resp) => {
set404FromErrorResponse(resp);
setLoading(false);
}
useEffect(() => { useEffect(() => {
if (id && !isEmpty(id)) { if (id && !isEmpty(id)) {
setLoading(true); setLoading(true);
UserService.getUser(id, getUserCallback, errGetUserCallback); UserService.getUser(id, getUserCallback, errGetUserCallback);
UserService.getRoles(getRolesCallback, errGetRolesCallback); UserService.getRoles(getRolesCallback, errGetRolesCallback);
UserActionService.getActionContext(id, getActionsContextCallback, errGetActionsContextCallback);
UserActionService.getUserActions(id, getUserActionsCallback, errGetUserActionsCallback);
} }
}, [id]) }, [id])
@@ -143,7 +172,10 @@ const UserActivity = () => {
disabled={isEmpty(roles) || loading} disabled={isEmpty(roles) || loading}
value={chosenRole} value={chosenRole}
onChange={(e) => setChosenRole(e.value)} onChange={(e) => setChosenRole(e.value)}
options={roles.filter(o => [3, 5].includes(o.id)).map(o => ({ label: o.roleName, value: o.id }))} options={roles.filter(o => [3, 5].includes(o.id)).map(o => ({
label: o.roleName,
value: o.id
}))}
optionLabel="label" optionLabel="label"
placeholder={__('Seleziona ruolo', 'gepafin')}/> placeholder={__('Seleziona ruolo', 'gepafin')}/>
<Button <Button
@@ -159,33 +191,39 @@ const UserActivity = () => {
<div className="appPage__spacer"></div> <div className="appPage__spacer"></div>
{/*<div className="appPageSection"> {!isEmpty(userActions)
? <div className="appPageSection">
<h2>{__('Statistiche attività', 'gepafin')}</h2> <h2>{__('Statistiche attività', 'gepafin')}</h2>
<div className="statsBigBadges__grid grid-small"> <div className="statsBigBadges__grid grid-small">
<div className="statsBigBadges__gridItem"> <div className="statsBigBadges__gridItem">
<span>{__('Login totali', 'gepafin')}</span> <span>{__('Login totali', 'gepafin')}</span>
<span>{<NumberFlow <span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)} value={getStatValue('numberOfLoginAttempts', 0)}
format={{ notation: 'compact' }} format={{ notation: 'compact' }}
locales="it-IT"/>}</span> locales="it-IT"/>}</span>
</div> </div>
<div className="statsBigBadges__gridItem"> <div className="statsBigBadges__gridItem">
<span>{__('Bandi gestiti', 'gepafin')}</span> <span>{__('Bandi gestiti', 'gepafin')}</span>
<span>{<NumberFlow <span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)} value={getStatValue('applicationsProcessed', 0)}
format={{ notation: 'compact' }} format={{ notation: 'compact' }}
locales="it-IT"/>}</span> locales="it-IT"/>}</span>
</div> </div>
<div className="statsBigBadges__gridItem"> {/*<div className="statsBigBadges__gridItem">
<span>{__('Domande processate', 'gepafin')}</span> <span>{__('Domande processate', 'gepafin')}</span>
<span>{<NumberFlow <span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)} value={getStatValue('numberOfActiveCalls', 0)}
format={{ notation: 'compact' }} format={{ notation: 'compact' }}
locales="it-IT"/>}</span> locales="it-IT"/>}</span>
</div>
</div>
</div>*/} </div>*/}
</div> </div>
</div> : null}
{!isEmpty(userActions)
? <div className="appPageSection">
<h2>{__('Statistiche attività', 'gepafin')}</h2>
</div> : null}
</div>
) )
} }

View File

@@ -4,9 +4,9 @@ const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
export default class NotificationService { export default class NotificationService {
static getNotifications = (id, callback, errCallback, queryParams) => { /*static getNotifications = (id, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams); NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams);
}; };*/
static getNotificationsByCompanyId = (id, companyId, callback, errCallback, queryParams) => { static getNotificationsByCompanyId = (id, companyId, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/notification/user/${id}/company/${companyId}/notifications`, callback, errCallback, queryParams); NetworkService.get(`${API_BASE_URL}/notification/user/${id}/company/${companyId}/notifications`, callback, errCallback, queryParams);

View File

@@ -0,0 +1,14 @@
import { NetworkService } from './network-service';
const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
export default class UserActionService {
static getActionContext = (id, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/userAction/user/${id}/action-context`, callback, errCallback, queryParams);
};
static getUserActions = (id, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/userAction/user/${id}`, callback, errCallback, queryParams);
};
}