- 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">
<p className="chartCard__tooltipTitle">{label}</p>
<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>
</div>
);
@@ -50,7 +53,8 @@ const ChartDomandePerBando = ({ title, data = [] }) => {
<YAxis/>
<Tooltip content={<CustomTooltip/>}/>
<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>
</ResponsiveContainer>
</div> : null}

View File

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

View File

@@ -15,6 +15,7 @@ import getDateFromISOstring from '../../helpers/getDateFromISOstring';
import { Button } from 'primereact/button';
import { Toast } from 'primereact/toast';
import { Dropdown } from 'primereact/dropdown';
import UserActionService from '../../service/user-action-service';
const UserActivity = () => {
@@ -25,6 +26,8 @@ const UserActivity = () => {
const [user, setUser] = useState({});
const [roles, setRoles] = useState([]);
const [chosenRole, setChosenRole] = useState(0);
const [actionsContext, setActionsContext] = useState([]);
const [userActions, setUserActions] = useState({});
const goBack = () => {
navigate(`/utenti`);
@@ -56,13 +59,13 @@ const UserActivity = () => {
}
const getStatValue = (key, fallback = 0) => {
return pathOr(fallback, [key], {});
return pathOr(fallback, [key], userActions);
}
const handleRoleUpdate = () => {
if (user.role?.id !== chosenRole) {
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);
}
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(() => {
if (id && !isEmpty(id)) {
setLoading(true);
UserService.getUser(id, getUserCallback, errGetUserCallback);
UserService.getRoles(getRolesCallback, errGetRolesCallback);
UserActionService.getActionContext(id, getActionsContextCallback, errGetActionsContextCallback);
UserActionService.getUserActions(id, getUserActionsCallback, errGetUserActionsCallback);
}
}, [id])
@@ -143,7 +172,10 @@ const UserActivity = () => {
disabled={isEmpty(roles) || loading}
value={chosenRole}
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"
placeholder={__('Seleziona ruolo', 'gepafin')}/>
<Button
@@ -159,32 +191,38 @@ const UserActivity = () => {
<div className="appPage__spacer"></div>
{/*<div className="appPageSection">
<h2>{__('Statistiche attività', 'gepafin')}</h2>
<div className="statsBigBadges__grid grid-small">
<div className="statsBigBadges__gridItem">
<span>{__('Login totali', 'gepafin')}</span>
<span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/>}</span>
{!isEmpty(userActions)
? <div className="appPageSection">
<h2>{__('Statistiche attività', 'gepafin')}</h2>
<div className="statsBigBadges__grid grid-small">
<div className="statsBigBadges__gridItem">
<span>{__('Login totali', 'gepafin')}</span>
<span>{<NumberFlow
value={getStatValue('numberOfLoginAttempts', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/>}</span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Bandi gestiti', 'gepafin')}</span>
<span>{<NumberFlow
value={getStatValue('applicationsProcessed', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/>}</span>
</div>
{/*<div className="statsBigBadges__gridItem">
<span>{__('Domande processate', 'gepafin')}</span>
<span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/>}</span>
</div>*/}
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Bandi gestiti', 'gepafin')}</span>
<span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/>}</span>
</div>
<div className="statsBigBadges__gridItem">
<span>{__('Domande processate', 'gepafin')}</span>
<span>{<NumberFlow
value={getStatValue('numberOfActiveCalls', 0)}
format={{ notation: 'compact' }}
locales="it-IT"/>}</span>
</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 {
static getNotifications = (id, callback, errCallback, queryParams) => {
/*static getNotifications = (id, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams);
};
};*/
static getNotificationsByCompanyId = (id, companyId, 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);
};
}