Merge pull request #38 from Kitzanos/feature/49-confidi-users

CONFIDI user functionality
This commit is contained in:
Vitalii Kiiko
2025-03-07 09:06:04 +01:00
committed by GitHub
11 changed files with 458 additions and 44 deletions

View File

@@ -32,21 +32,21 @@ const AppSidebar = () => {
icon: 'pi pi-file',
href: '/imieibandi',
id: 3,
enable: intersection(permissions, ['APPLY_CALLS']).length
enable: intersection(permissions, ['APPLY_CALLS', 'APPLY_CONFIDI_CALLS']).length
},
{
label: __('Bandi disponibili', 'gepafin'),
icon: 'pi pi-bookmark',
href: '/bandi',
id: 4,
enable: intersection(permissions, ['VIEW_CALLS']).length
enable: intersection(permissions, ['VIEW_CALLS', 'VIEW_CONFIDI_CALLS']).length
},
{
label: __('Bandi osservati', 'gepafin'),
icon: 'pi pi-star',
href: '/bandi-osservati',
id: 5,
enable: intersection(permissions, ['VIEW_CALLS']).length
enable: intersection(permissions, ['VIEW_CALLS', 'VIEW_CONFIDI_CALLS']).length
},
{
label: __('Gestione domande', 'gepafin'),
@@ -81,7 +81,7 @@ const AppSidebar = () => {
icon: 'pi pi-briefcase',
href: '/domande',
id: 10,
enable: intersection(permissions, ['APPLY_CALLS']).length
enable: intersection(permissions, ['APPLY_CALLS', 'APPLY_CONFIDI_CALLS']).length
},
{
label: __('Archivio domande', 'gepafin'),
@@ -136,14 +136,14 @@ const AppSidebar = () => {
icon: 'pi pi-chart-bar',
href: '/stats',
id: 15,
enable: intersection(permissions, ['APPLY_CALLS']).length
enable: intersection(permissions, ['APPLY_CALLS', 'APPLY_CONFIDI_CALLS']).length
},
{
label: __('Documenti', 'gepafin'),
icon: 'pi pi-folder-open',
href: '/documenti',
id: 16,
enable: intersection(permissions, ['APPLY_CALLS']).length
enable: intersection(permissions, ['APPLY_CALLS', 'APPLY_CONFIDI_CALLS']).length
},
{
label: __('Log di Sistema', 'gepafin'),

View File

@@ -14,6 +14,7 @@ import { storeSet, storeGet, useStore } from '../../store';
// api
import ApplicationService from '../../service/application-service';
import CompanyDocumentsService from '../../service/company-documents-service';
// tools
import {
@@ -33,6 +34,7 @@ import renderWithDataVars from '../../helpers/renderWithDataVars';
import getTokens from '../../helpers/getTokens';
import formatDateString from '../../helpers/formatDateString';
import isDateTimeInPast from '../../helpers/isDateTimeInPast';
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
// components
import { Skeleton } from 'primereact/skeleton';
@@ -46,8 +48,8 @@ import { Dialog } from 'primereact/dialog';
import FileuploadApplicationSignedPdf from '../../components/FileuploadApplicationSignedPdf';
import { defaultMaxFileSize } from '../../configData';
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
import CompanyDocumentsService from '../../service/company-documents-service';
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
const BandoApplication = () => {
const chosenCompanyId = useStore().main.chosenCompanyId();
@@ -652,12 +654,6 @@ const BandoApplication = () => {
['companyId', chosenCompanyId]
]);
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, getDocsCallback, errDocsGetCallbacks);
/*CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, (resp) => getDocsCallback(resp, 'COMPANY_DOCUMENT'), errDocsGetCallbacks, [
['documentType', 'COMPANY_DOCUMENT']
]);
CompanyDocumentsService.getCompanyDocuments(chosenCompanyId, (resp) => getDocsCallback(resp, 'PERSONAL_DOCUMENT'), errDocsGetCallbacks, [
['documentType', 'PERSONAL_DOCUMENT']
]);*/
}
}, [id, chosenCompanyId]);
@@ -690,7 +686,10 @@ const BandoApplication = () => {
setVisibleConfirmation(false);
}}>
<p>
{__('Grazie, la tua domanda è stata inviata correttamente. Entro 24 ore riceverai una pec con data, ora e numero di protocollo.', 'gepafin')}
{APP_HUB_ID === 't7jh5wfg9QXylNaTZkPoE'
? __('Grazie, la tua domanda è stata inviata correttamente. Entro 24 ore riceverai una email con data, ora e numero di protocollo.', 'gepafin')
: __('Grazie, la tua domanda è stata inviata correttamente. Entro 24 ore riceverai una pec con data, ora e numero di protocollo.', 'gepafin')
}
</p>
</Dialog>
@@ -750,9 +749,9 @@ const BandoApplication = () => {
return acc;
}, {});
if (o.name === 'fileselect') {
/*if (o.name === 'fileselect') {
console.log('options::', options)
}
}*/
return ['paragraph'].includes(o.name) && text
? <div key={o.id}>

View File

@@ -118,9 +118,12 @@ const Login = () => {
/*if ('t7jh5wfg9QXylNaTZkPoE' === APP_HUB_ID) {
setIsMaintenance(true);
}*/
hotkeys('command+x,ctrl+x', function(event, handler){
hotkeys('command+x,ctrl+x', function(){
window.location.replace('/loginadmin')
});
hotkeys('command+shift+x,ctrl+shift+x', function(){
window.location.replace('/confidi')
});
}, []);
return (

View File

@@ -16,6 +16,7 @@ import FormField from '../../components/FormField';
import LogoIcon from '../../icons/LogoIcon';
import { Button } from 'primereact/button';
import { Messages } from 'primereact/messages';
import hotkeys from 'hotkeys-js';
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
@@ -31,7 +32,7 @@ const LoginAdmin = () => {
} = useForm({ mode: 'onChange' });
const gotToResetPassword = () => {
navigate('/reset-password');
navigate('/reset-password-admin');
}
const onSubmit = (formData) => {
@@ -78,12 +79,18 @@ const LoginAdmin = () => {
}
}, [token]);
useEffect(() => {
hotkeys('command+shift+x,ctrl+shift+x', function(){
window.location.replace('/confidi')
});
}, []);
return (
<div className={classNames(['appPage', 'appPageLogin'])}>
<div className="appPageLogin__wrapper">
<LogoIcon/>
<h1>{__('Accedi o Registrati', 'gepafin')}</h1>
<h1>{__('Accedi', 'gepafin')}</h1>
<Messages ref={errorMsgs}/>

View File

@@ -0,0 +1,133 @@
import React, { useRef, useState, useEffect } from 'react';
import { __, sprintf } from '@wordpress/i18n';
import { useForm } from 'react-hook-form';
import { classNames } from 'primereact/utils';
import { isEmpty } from 'ramda';
import { useNavigate } from 'react-router-dom';
// tools
import AuthenticationService from '../../service/authentication-service';
// store
import { storeSet, useStore } from '../../store';
// components
import FormField from '../../components/FormField';
import LogoIcon from '../../icons/LogoIcon';
import { Button } from 'primereact/button';
import { Messages } from 'primereact/messages';
import hotkeys from 'hotkeys-js';
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
const LoginConfidi = () => {
const navigate = useNavigate();
const token = useStore().main.token();
const [loading, setLoading] = useState(false);
const errorMsgs = useRef(null);
const {
control,
handleSubmit,
formState: { errors },
} = useForm({ mode: 'onChange' });
const gotToResetPassword = () => {
navigate('/reset-password');
}
const onSubmit = (formData) => {
errorMsgs.current.clear();
setLoading(true);
const request = {
...formData,
hubUuid: APP_HUB_ID,
rememberMe: true
}
AuthenticationService.login(request, loginCallback, loginError);
};
const loginCallback = (data) => {
if (data.status === 'SUCCESS') {
storeSet.main.setAuthData({
token: data.data.token,
userData: data.data.user
});
} else {
errorMsgs.current.show([
{ sticky: true, severity: 'error', summary: '',
detail: data.message,
closable: true }
]);
}
setLoading(false);
}
const loginError = (err) => {
errorMsgs.current.show([
{ sticky: true, severity: 'error', summary: '',
detail: sprintf(__('%s', 'gepafin'), err.message),
closable: true }
]);
setLoading(false);
}
useEffect(() => {
if (!isEmpty(token)) {
setLoading(true);
window.location.replace('/')
}
}, [token]);
useEffect(() => {
hotkeys('command+x,ctrl+x', function(){
window.location.replace('/loginadmin')
});
}, []);
return (
<div className={classNames(['appPage', 'appPageLogin'])}>
<div className="appPageLogin__wrapper">
<LogoIcon/>
<h1>{__('Accedi', 'gepafin')}</h1>
<Messages ref={errorMsgs}/>
<div className="appPage__spacer"></div>
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
<FormField
type="textinput"
fieldName="email"
label={__('Email', 'gepafin')}
control={control}
errors={errors}
config={{ required: __('È obbligatorio', 'gepafin') }}
placeholder="sample@example.com"
/>
<FormField
type="textinput"
inputtype="password"
fieldName="password"
label={__('Password', 'gepafin')}
control={control}
errors={errors}
config={{ required: __('È obbligatorio', 'gepafin') }}
/>
<Button
label={__('Accedi', 'gepafin')}
disabled={loading}/>
<Button
label={__('Password dimenticata?', 'gepafin')}
link onClick={gotToResetPassword}/>
</form>
</div>
</div>
)
}
export default LoginConfidi;

View File

@@ -36,8 +36,8 @@ const ResetPassword = () => {
setValue
} = useForm({ mode: 'onChange' });
const gotToLoginAdmin = () => {
navigate('/loginadmin');
const gotToLogin = () => {
navigate('/confidi');
}
const onSubmit = (formData) => {
@@ -110,7 +110,6 @@ const ResetPassword = () => {
}, [token]);
useEffect(() => {
console.log(resetPassToken, resetPassEmail);
reset();
setValue('token', resetPassToken);
setValue('email', resetPassEmail);
@@ -191,7 +190,7 @@ const ResetPassword = () => {
<Button
label={__('Accedi', 'gepafin')}
link onClick={gotToLoginAdmin}/>
link onClick={gotToLogin}/>
</form>
</div>
</div>

View File

@@ -0,0 +1,200 @@
import React, { useRef, useState, useEffect } from 'react';
import { __, sprintf } from '@wordpress/i18n';
import { useForm } from 'react-hook-form';
import { classNames } from 'primereact/utils';
import { isEmpty } from 'ramda';
import { useNavigate, useSearchParams } from 'react-router-dom';
// tools
import AuthenticationService from '../../service/authentication-service';
// store
import { useStore } from '../../store';
// components
import FormField from '../../components/FormField';
import LogoIcon from '../../icons/LogoIcon';
import { Button } from 'primereact/button';
import { Messages } from 'primereact/messages';
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
const ResetPasswordAdmin = () => {
const navigate = useNavigate();
const token = useStore().main.token();
const [loading, setLoading] = useState(false);
const [resetPassToken, setResetPassToken] = useState('');
const [resetPassEmail, setResetPassEmail] = useState('');
const errorMsgs = useRef(null);
let [searchParams] = useSearchParams();
const {
control,
handleSubmit,
formState: { errors },
reset,
register,
setValue
} = useForm({ mode: 'onChange' });
const gotToLogin = () => {
navigate('/loginadmin');
}
const onSubmit = (formData) => {
errorMsgs.current.clear();
setLoading(true);
const request = {
...formData,
hubUuid: APP_HUB_ID
}
if (request.token && !isEmpty(request.token)) {
AuthenticationService.resetPassword(request, getCallbackReset, errCallback);
} else {
AuthenticationService.forgotPassword(request, getCallback, errCallback);
}
};
const getCallbackReset = (data) => {
if (data.status === 'SUCCESS') {
errorMsgs.current.show([
{
sticky: true, severity: 'success', summary: '',
detail: data.message,
closable: true
}
]);
} else {
errorMsgs.current.show([
{
sticky: true, severity: 'error', summary: '',
detail: data.message,
closable: true
}
]);
}
setLoading(false);
}
const getCallback = (data) => {
if (data.status === 'SUCCESS') {
setResetPassToken(data.data)
} else {
errorMsgs.current.show([
{
sticky: true, severity: 'error', summary: '',
detail: data.message,
closable: true
}
]);
}
setLoading(false);
}
const errCallback = (err) => {
errorMsgs.current.show([
{
sticky: true, severity: 'error', summary: '',
detail: sprintf(__('%s', 'gepafin'), err.message),
closable: true
}
]);
setLoading(false);
}
useEffect(() => {
if (!isEmpty(token)) {
setLoading(true);
window.location.replace('/')
}
}, [token]);
useEffect(() => {
reset();
setValue('token', resetPassToken);
setValue('email', resetPassEmail);
}, [resetPassToken, resetPassEmail]);
useEffect(() => {
const token = searchParams.get('token');
const email = searchParams.get('email');
setResetPassToken(token);
setResetPassEmail(email);
}, [searchParams]);
return (
<div className={classNames(['appPage', 'appPageLogin'])}>
<div className="appPageLogin__wrapper">
<LogoIcon/>
<h1>{__('Password dimenticata', 'gepafin')}</h1>
<Messages ref={errorMsgs}/>
<div className="appPage__spacer"></div>
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
<FormField
type="textinput"
fieldName="email"
label={__('Email', 'gepafin')}
control={control}
errors={errors}
config={{ required: __('È obbligatorio', 'gepafin') }}
placeholder="sample@example.com"
/>
{resetPassToken && !isEmpty(resetPassToken)
? <input
type="hidden"
name="token"
{...register('token', {
required: true
})}
/> : null}
{resetPassToken && !isEmpty(resetPassToken)
? <FormField
type="password"
fieldName="newPassword"
label={__('Password', 'gepafin')}
control={control}
errors={errors}
config={{
required: __('È obbligatorio', 'gepafin'),
validate: {
passEqual: (value, values) => values.confirmPassword === value
}
}}
/> : null}
{resetPassToken && !isEmpty(resetPassToken)
? <FormField
type="password"
inputtype="password"
fieldName="confirmPassword"
label={__('Conferma password', 'gepafin')}
control={control}
errors={errors}
config={{
required: __('È obbligatorio', 'gepafin'),
validate: {
passEqual: (value, values) => values.newPassword === value
}
}}
/> : null}
<Button
label={__('Invia', 'gepafin')}
disabled={loading}/>
<Button
label={__('Accedi', 'gepafin')}
link onClick={gotToLogin}/>
</form>
</div>
</div>
)
}
export default ResetPasswordAdmin;

View File

@@ -54,7 +54,9 @@ const AllUsersTable = () => {
const getFormattedData = (data) => {
return data
.filter(o => ['ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.role.roleType));
.filter(o => [
'ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER', 'ROLE_CONFIDI'
].includes(o.role.roleType));
};
const clearFilter = () => {

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { __ } from '@wordpress/i18n';
import { isEmpty, isNil } from 'ramda';
import { head, isEmpty, isNil } from 'ramda';
import { klona } from 'klona';
// store
@@ -11,7 +11,7 @@ import UserService from '../../service/user-service';
// tools
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import { isEmail } from '../../helpers/validators';
import { isCodiceFiscale, isEmail, isPIVA } from '../../helpers/validators';
// components
import AllUsersTable from './components/AllUsersTable';
@@ -34,7 +34,8 @@ const Users = () => {
phoneNumber: '',
password: '',
confPassword: '',
roleId: 0
roleId: 0,
codiceFiscale: ''
});
const [roles, setRoles] = useState([]);
const toast = useRef(null);
@@ -56,18 +57,27 @@ const Users = () => {
phoneNumber: '',
password: '',
confPassword: '',
roleId: 0
roleId: 0,
codiceFiscale: ''
});
}
const saveEditDialog = () => {
const emptyValues = Object.values(newUserData).filter(v => isEmpty(v));
const isConfidi = isConfidiRoleChosen();
const emptyValues = Object.keys(newUserData)
.filter(v => v !== 'phoneNumber')
.filter(v => isConfidi ? v : v !== 'codiceFiscale')
.filter(v => isInvalidField(newUserData, v));
if (isEmpty(emptyValues) && newUserData.password === newUserData.confPassword && !loading) {
setLoading(true);
const body = {
let body = klona({
...newUserData,
hubUuid: APP_HUB_ID
});
if (!isConfidi) {
delete body.codiceFiscale;
}
UserService.createUser(body, createUserCallback, errCreateUserCallback);
@@ -108,23 +118,33 @@ const Users = () => {
setNewUserData(userData);
}
const footerEditDialog = () => {
const footerEditDialog = useCallback(() => {
const isConfidi = isConfidiRoleChosen();
const errorValues = Object.keys(newUserData)
.filter(v => v !== 'phoneNumber')
.filter(v => isConfidi ? v : v !== 'codiceFiscale')
.filter(v => isInvalidField(newUserData, v));
return <div>
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideEditDialog} outlined/>
<Button
type="button"
disabled={isEmpty(newUserData) || loading}
disabled={!isEmpty(errorValues) || loading}
label={__('Salva', 'gepafin')} onClick={saveEditDialog}/>
</div>
}
}, [newUserData]);
const getRolesCallback = (data) => {
if (data.status === 'SUCCESS') {
const roles = data.data
.filter(o => ['ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.roleType))
.filter(o => [
'ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER', 'ROLE_CONFIDI'
].includes(o.roleType))
.map(o => ({
name: o.roleName,
value: o.id
value: o.id,
id: o.id,
roleType: o.roleType
}));
setRoles(roles);
}
@@ -136,7 +156,14 @@ const Users = () => {
storeSet.main.unsetAsyncRequest();
}
const isInvalidField = (data, key) => isEmpty(data[key]) || isNil(data[key])
const isInvalidField = (data, key) => key === 'codiceFiscale'
? !isCodiceFiscale(data[key]) && !isPIVA(data[key])
: isEmpty(data[key]) || isNil(data[key]);
const isConfidiRoleChosen = useCallback(() => {
const chosen = head(roles.filter(o => o.id === newUserData.roleId));
return chosen ? chosen.roleType === 'ROLE_CONFIDI' : false;
}, [roles, newUserData])
useEffect(() => {
if (isVisibleEditDialog) {
@@ -201,13 +228,11 @@ const Users = () => {
onChange={(e) => onChangeEditItem(e.target.value, 'email')}/>
</div>
<div className="appForm__field">
<label
className={classNames({ 'p-error': isInvalidField(newUserData, 'phoneNumber') })}>
<label>
{__('Telefono', 'gepafin')}
</label>
<InputText value={newUserData.phoneNumber}
keyfilter="int"
invalid={isInvalidField(newUserData, 'phoneNumber')}
onChange={(e) => onChangeEditItem(e.target.value, 'phoneNumber')}/>
</div>
</div>
@@ -244,6 +269,16 @@ const Users = () => {
optionLabel="name"
optionValue="value"/>
</div>
{isConfidiRoleChosen()
? <div className="appForm__field">
<label
className={classNames({ 'p-error': isInvalidField(newUserData, 'codiceFiscale') })}>
{__('Codice Fiscale', 'gepafin')}*
</label>
<InputText value={newUserData.codiceFiscale}
invalid={isInvalidField(newUserData, 'codiceFiscale')}
onChange={(e) => onChangeEditItem(e.target.value, 'codiceFiscale')}/>
</div> : null}
<div className="appPage__spacer"></div>
</Dialog>
</div>

View File

@@ -52,6 +52,8 @@ import SoccorsoIstruttorioInstructorManager from './pages/SoccorsoIstruttorioIns
import SoccorsoIstruttorioMioInstructorManager from './pages/SoccorsoIstruttorioMioInstructorManager';
import StatsBeneficiary from './pages/StatsBeneficiary';
import DocumentsBeneficiary from './pages/DocumentsBeneficiary';
import LoginConfidi from './pages/LoginConfidi';
import ResetPasswordAdmin from './pages/ResetPasswordAdmin';
const routes = ({ role, chosenCompanyId }) => {
@@ -61,199 +63,233 @@ const routes = ({ role, chosenCompanyId }) => {
<Route path="/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Dashboard/> : null}
{'ROLE_BENEFICIARY' === role ? <DashboardBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <DashboardBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <DashboardPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DashboardInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/bandi" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Bandi/> : null}
{'ROLE_BENEFICIARY' === role ? <BandiBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <BandiBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <BandiPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <BandiPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoEdit/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoViewBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <BandoViewBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <BandoViewPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <BandoViewPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoView/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/preview-evaluation" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoView/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/forms" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoForms/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/forms/:formId" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoFormsEdit/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/forms/:formId/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoFormsPreview/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/flow" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoFlowEdit/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi-osservati" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <BandiPreferredBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <BandiPreferredBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/domande" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Domande/> : null}
{'ROLE_BENEFICIARY' === role ? <DomandeBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <DomandeBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <DomandePreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DomandeInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/domande/:id/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoApplicationPreview/> : null}
{'ROLE_BENEFICIARY' === role ? <SoccorsoEditBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <SoccorsoEditBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <DomandaEditPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DomandaEditPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/domande/:id/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoApplicationPreview/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoApplicationPreview/> : null}
{'ROLE_CONFIDI' === role ? <BandoApplicationPreview/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <BandoApplicationPreview/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <BandoApplicationPreview/> : null}
</DefaultLayout>}/>
<Route path="/domande-archivio" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <DomandeArchive/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <DomandeArchivePreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DomandeArchive/> : null}
</DefaultLayout>}/>
<Route path="/domande-archivio/:id/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoApplicationPreview/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <BandoApplicationPreview/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <BandoApplicationPreview/> : null}
</DefaultLayout>}/>
<Route path="/domande/:id/aggiungi-soccorso" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <SoccorsoAddPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/domande/:id/soccorso/:amendmentId" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <SoccorsoEditPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoEditPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/soccorso-istruttorio/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <SoccorsoIstruttorioPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoIstruttorioInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/mie-domande" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DomandeMieInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/mie-domande/:id/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DomandaEditInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/mie-domande/:id/aggiungi-soccorso" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoAddInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/mie-domande/:id/soccorso/:amendmentId" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoEditInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/mio-soccorso-istruttorio/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoIstruttorioMioInstructorManager/> : null}
</DefaultLayout>}/>
<Route path="/imieibandi" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <Applications/> : null}
{'ROLE_CONFIDI' === role ? <Applications/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/imieibandi/:id/" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoApplication/> : null}
{'ROLE_CONFIDI' === role ? <BandoApplication/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/profilo" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Profile/> : null}
{'ROLE_BENEFICIARY' === role ? <ProfileBeneficiario/> : null}
{'ROLE_CONFIDI' === role ? <ProfileBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <Profile/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <Profile/> : null}
</DefaultLayout>}/>
<Route path="/profilo-aziendale" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role && chosenCompanyId > 0 ? <ProfileCompany/> : <PageNotFound/>}
{'ROLE_CONFIDI' === role && chosenCompanyId > 0 ? <ProfileCompany/> : <PageNotFound/>}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/agguingi-azienda" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <AddCompany/> : null}
{'ROLE_CONFIDI' === role ? <AddCompany/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/utenti" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Users/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/utenti/:id" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <UserActivity/> : null}
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
{'ROLE_CONFIDI' === role ? <PageNotFound/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/stats" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <StatsBeneficiary/> : null}
{'ROLE_CONFIDI' === role ? <StatsBeneficiary/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/documenti" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === role ? <DocumentsBeneficiary/> : null}
{'ROLE_CONFIDI' === role ? <DocumentsBeneficiary/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
</Route>
<Route exact path="/reset-password" element={<ResetPassword/>}/>
<Route exact path="/reset-password-admin" element={<ResetPasswordAdmin/>}/>
<Route exact path="/login" element={<Login/>}/>
<Route exact path="/loginAdmin" element={<LoginAdmin/>}/>
<Route exact path="/loginadmin" element={<LoginAdmin/>}/>
<Route exact path="/confidi" element={<LoginConfidi/>}/>
<Route exact path="/registration" element={<Registration/>}/>
<Route path="*" element={<PageNotFound/>}/>
</Routes>)

View File

@@ -9,7 +9,7 @@ export class NetworkService {
} else if (status === 403) {
storeSet.main.token('');
const { pathname } = window.location;
if (!['/login', '/loginadmin', '/reset-password', '/registration'].includes(pathname)) {
if (!['/login', '/registration', '/loginadmin', '/reset-password-admin', '/confidi', '/reset-password'].includes(pathname)) {
window.location.replace('/login');
}
}