- saving progress;
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user