Merge pull request #24 from Kitzanos/feature/91-instructor-manager-role

Feature/91 instructor manager role
This commit is contained in:
Vitalii Kiiko
2024-12-20 17:11:13 +01:00
committed by GitHub
17 changed files with 386 additions and 116 deletions

View File

@@ -29,6 +29,9 @@ const getBandoLabel = (status) => {
case 'ADMISSIBLE':
return __('Ammisibile', 'gepafin');
case 'RESPONSE_RECEIVED':
return __('Riposta ricevuta', 'gepafin');
case 'SOCCORSO':
return __('Soccorso', 'gepafin');

View File

@@ -27,6 +27,9 @@ const getBandoSeverity = (status) => {
case 'ADMISSIBLE':
return 'info';
case 'RESPONSE_RECEIVED':
return 'warning';
case 'SOCCORSO':
return 'warning';

View File

@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
import { head } from 'ramda';
// store
import { storeGet, useStore } from '../../store';
import { useStore } from '../../store';
// components
import MyLatestSubmissionsTable from '../DashboardBeneficiario/components/MyLatestSubmissionsTable';

View File

@@ -42,7 +42,7 @@ const DraftApplicationsTable = () => {
if (data.status === 'SUCCESS') {
if (is(Array, data.data)) {
setItems(getFormattedBandiData(data.data));
setStatuses(uniq(items.map(o => o.status)))
setStatuses(uniq(data.data.map(o => o.status)))
initFilters();
}
}

View File

@@ -19,6 +19,7 @@ const RepeaterFields = ({
updateCallbackFn = () => {
},
defaultValue = [],
shouldDisable = false
}) => {
const [chosen, setChosen] = useState('');
const {
@@ -92,6 +93,7 @@ const RepeaterFields = ({
<div className="fieldsRepeater__heading p-panel p-panel-header">
<span onClick={() => setNewChosen(o.fieldId)}>{o.nameValue}</span>
<Button icon="pi pi-times"
disabled={shouldDisable}
outlined
severity="danger"
className="actionBtn"
@@ -102,6 +104,7 @@ const RepeaterFields = ({
<div className="fieldsRepeater__fields p-panel-content" data-hide={chosen !== o.fieldId}>
<FormField
type="textinput"
disabled={shouldDisable}
fieldName={`items.${index}.nameValue`}
label={__('Titolo del file', 'gepafin')}
control={control}
@@ -111,7 +114,7 @@ const RepeaterFields = ({
/>
<FormField
type="fileupload"
disabled={isEmpty(o.nameValue)}
disabled={isEmpty(o.nameValue) || shouldDisable}
setDataFn={setValue}
saveFormCallback={doUpdateAfterFileUploaded}
fieldName={`items.${index}.fileValue`}
@@ -135,7 +138,7 @@ const RepeaterFields = ({
className="fieldsRepeater__addNew"
outlined
type="button"
disabled={watchFields && watchFields.filter(o => isEmpty(o.nameValue) || isEmpty(o.fileValue)).length > 0}
disabled={watchFields && watchFields.filter(o => isEmpty(o.nameValue) || isEmpty(o.fileValue)).length > 0 || shouldDisable}
onClick={addNew}
label={__('Aggiungi nuovo file', 'gepafin')}
/>

View File

@@ -226,6 +226,7 @@ const DomandaEditPreInstructor = () => {
motivation
}
setIsVisibleCompleteDialog(false);
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
}
@@ -239,11 +240,13 @@ const DomandaEditPreInstructor = () => {
motivation
}
setIsVisibleCompleteDialog(false);
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
}
const updateStatusCallback = (data) => {
if (data.status === 'SUCCESS') {
setData(getFormattedData(data.data));
if (toast.current) {
toast.current.show({
severity: 'success',
@@ -607,6 +610,7 @@ const DomandaEditPreInstructor = () => {
data,
['evaluationDocument']
)}
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus)}
sourceId={data.assignedApplicationId}
sourceName="evaluation"/>
</div>
@@ -762,7 +766,8 @@ const DomandaEditPreInstructor = () => {
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
? <Button
type="button"
disabled={!data.id || data.status === 'CLOSE' || !allFilesRated || !atLeastOneChecked}
disabled={!data.id || data.status === 'CLOSE' || (data.applicationStatus === 'EVALUATION'
&& (!allFilesRated || !atLeastOneChecked))}
onClick={doNewSoccorso}
outlined
label={<>
@@ -811,8 +816,9 @@ const DomandaEditPreInstructor = () => {
{data.id
? <Button
type="button"
disabled={!isAdmissible
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus))}
disabled={!isAdmissible || ['APPROVED'].includes(data.applicationStatus)}
/*disabled={!isAdmissible
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus))}*/
onClick={initiateApproving}
label={__('Approva Domanda', 'gepafin')}
icon="pi pi-check" iconPos="right"/> : null}

View File

@@ -6,6 +6,13 @@ import { Link, useLocation } from 'react-router-dom';
// api
import ApplicationService from '../../../../service/application-service';
// tools
import getBandoLabel from '../../../../helpers/getBandoLabel';
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
// translation
import translationStrings from '../../../../translationStringsForComponents';
// components
import { FilterMatchMode, FilterOperator } from 'primereact/api';
import { DataTable } from 'primereact/datatable';
@@ -13,14 +20,15 @@ import { Column } from 'primereact/column';
import { Button } from 'primereact/button';
import { Calendar } from 'primereact/calendar';
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
import translationStrings from '../../../../translationStringsForComponents';
import { Dropdown } from 'primereact/dropdown';
import { Tag } from 'primereact/tag';
const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
const [items, setItems] = useState(null);
const [filters, setFilters] = useState(null);
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
const [, setStatuses] = useState([]);
const [statuses, setStatuses] = useState([]);
const location = useLocation();
useEffect(() => {
@@ -82,7 +90,8 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
callEndDate: {
operator: FilterOperator.AND,
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
}
},
status: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] },
});
};
@@ -99,9 +108,12 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
return formatDate(rowData.submissionDate);
};
/*const dateEndBodyTemplate = (rowData) => {
return formatDate(rowData.callEndDate);
};*/
const statusFilterTemplate = (options) => {
return <Dropdown value={options.value} options={statuses}
onChange={(e) => options.filterCallback(e.value, options.index)}
itemTemplate={statusItemTemplate} placeholder={translationStrings.selectOneLabel} className="p-column-filter"
showClear/>;
};
const dateFilterTemplate = (options) => {
return <Calendar value={options.value} onChange={(e) => options.filterCallback(e.value, options.index)}
@@ -112,9 +124,13 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
return <ProperBandoLabel status={rowData.status}/>;
};
const statusItemTemplate = (option) => {
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)}/>;
};
const actionsBodyTemplate = (rowData) => {
return <div className="appPageSection__tableActions lessGap">
{openDialogFn && rowData.status === 'SUBMIT'
{openDialogFn && ['SUBMIT', 'EVALUATION', 'SOCCORSO'].includes(rowData.status)
? <Button severity="info"
onClick={() => openDialogFn(rowData.id)}
label={__('Assegnare', 'gepafin')}
@@ -162,7 +178,9 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
style={{ minWidth: '8rem' }}
body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/>*/}
<Column field="status" header={__('Stato', 'gepafin')}
style={{ minWidth: '8rem' }} body={statusBodyTemplate}/>
style={{ minWidth: '8rem' }} body={statusBodyTemplate}
filter
filterElement={statusFilterTemplate}/>
<Column header={__('Azioni', 'gepafin')}
body={actionsBodyTemplate}/>
</DataTable>

View File

@@ -24,7 +24,7 @@ import DraftApplicationsTable from '../Dashboard/components/DraftApplicationsTab
const Domande = () => {
const [loading, setLoading] = useState(false);
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
const [roleId, setRoleId] = useState(0);
const [roleIds, setRoleIds] = useState([]);
const [users, setUsers] = useState([]);
const [chosenUser, setChosenUser] = useState(0);
const [chosenApplication, setChosenApplication] = useState(0);
@@ -34,10 +34,8 @@ const Domande = () => {
const getRolesCallback = (data) => {
if (data.status === 'SUCCESS') {
const roles = data.data
.filter(o => ['ROLE_PRE_INSTRUCTOR'].includes(o.roleType));
if (roles.length) {
setRoleId(roles[0].id);
}
.filter(o => ['ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.roleType));
setRoleIds(roles.map(o => o.id));
}
setLoading(false);
}
@@ -126,11 +124,11 @@ const Domande = () => {
}
useEffect(() => {
if (roleId !== 0) {
if (roleIds.length > 0) {
setLoading(true);
UserService.getUsers(getUsersCallback, errGetUsersCallback, [['roleId', roleId]])
UserService.getUsers(getUsersCallback, errGetUsersCallback, [['roleIds', roleIds]])
}
}, [roleId]);
}, [roleIds]);
useEffect(() => {
if (isVisibleEditDialog) {

View File

@@ -4,7 +4,7 @@ import { is, isEmpty, uniq } from 'ramda';
import { Link } from 'react-router-dom';
// store
import { useStore, storeGet } from '../../../../store';
import { useStore } from '../../../../store';
// api
import ApplicationService from '../../../../service/application-service';

View File

@@ -0,0 +1,184 @@
import React, { useEffect, useRef, useState } from 'react';
import { __ } from '@wordpress/i18n';
import { isEmpty } from 'ramda';
// store
import { storeSet } from '../../store';
// tools
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
import uniqid from '../../helpers/uniqid';
// api
import AssignedApplicationService from '../../service/assigned-application-service';
import UserService from '../../service/user-service';
// components
import PreInstructorDomandeTable from '../DashboardPreInstructor/components/PreInstructorDomandeTable';
import AllDomandeTable from '../Domande/components/AllDomandeTable';
import { classNames } from 'primereact/utils';
import { Dropdown } from 'primereact/dropdown';
import { Dialog } from 'primereact/dialog';
import { Button } from 'primereact/button';
const DomandeInstructorManager = () => {
const [loading, setLoading] = useState(false);
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
const [roleIds, setRoleIds] = useState(0);
const [users, setUsers] = useState([]);
const [chosenUser, setChosenUser] = useState(0);
const [chosenApplication, setChosenApplication] = useState(0);
const [updaterString, setUpdaterString] = useState('');
const toast = useRef(null);
const getRolesCallback = (data) => {
if (data.status === 'SUCCESS') {
const roles = data.data
.filter(o => ['ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.roleType));
setRoleIds(roles.map(o => o.id));
}
setLoading(false);
}
const errGetRolesCallback = (data) => {
set404FromErrorResponse(data);
setLoading(false);
}
const getUsersCallback = (data) => {
if (data.status === 'SUCCESS') {
const users = data.data
.map(o => ({
name: `${o.firstName} ${o.lastName} (${o.email})`,
value: o.id
}));
setUsers(users);
}
setLoading(false);
}
const errGetUsersCallback = (data) => {
set404FromErrorResponse(data);
setLoading(false);
}
const headerEditDialog = () => {
return <span>{__('Assegni la domanda', 'gepafin')}</span>
}
const hideEditDialog = () => {
setIsVisibleEditDialog(false);
setChosenUser(0);
setChosenApplication(0);
}
const footerEditDialog = () => {
return <div>
<Button type="button" label={__('Anulla', 'gepafin')} onClick={hideEditDialog} outlined/>
<Button
type="button"
disabled={loading}
label={__('Invia', 'gepafin')} onClick={saveEditDialog}/>
</div>
}
const openAssignDialog = (applId) => {
setChosenApplication(applId)
setIsVisibleEditDialog(true);
}
const saveEditDialog = () => {
if (chosenUser !== 0 && chosenApplication !== 0) {
storeSet.main.setAsyncRequest();
AssignedApplicationService.assignApplication(chosenApplication, assignApplCallback, errAssignApplCallback, [
['userId', chosenUser]
]);
hideEditDialog();
}
}
const assignApplCallback = (data) => {
if (data.status === 'SUCCESS') {
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: data.message
});
}
setUpdaterString(uniqid());
}
storeSet.main.unsetAsyncRequest();
}
const errAssignApplCallback = (data) => {
if (toast.current && data.message) {
toast.current.show({
severity: 'error',
summary: '',
detail: data.message
});
}
set404FromErrorResponse(data);
storeSet.main.unsetAsyncRequest();
}
useEffect(() => {
if (roleIds.length > 0) {
setLoading(true);
UserService.getUsers(getUsersCallback, errGetUsersCallback, [['roleIds', roleIds]])
}
}, [roleIds]);
useEffect(() => {
if (isVisibleEditDialog) {
setLoading(true);
UserService.getRoles(getRolesCallback, errGetRolesCallback)
}
}, [isVisibleEditDialog]);
return(
<div className="appPage">
<div className="appPage__pageHeader">
<h1>{__('Domande da valutare', 'gepafin')}</h1>
</div>
<div className="appPage__spacer"></div>
<div className="appPageSection">
<PreInstructorDomandeTable/>
</div>
<div className="appPage__spacer"></div>
<div className="appPageSection">
<h2>{__('Domande pubblicate', 'gepafin')}</h2>
<AllDomandeTable openDialogFn={openAssignDialog} updaterString={updaterString}/>
</div>
<Dialog
visible={isVisibleEditDialog}
modal
header={headerEditDialog}
footer={footerEditDialog}
style={{ maxWidth: '600px', width: '100%' }}
onHide={hideEditDialog}>
<div className="appForm__field">
<label
className={classNames({ 'p-error': isEmpty(chosenUser) || chosenUser === 0 || chosenApplication === 0 })}>
{__('Istruttore', 'gepafin')}*
</label>
<Dropdown
value={chosenUser}
invalid={isEmpty(chosenUser) || chosenUser === 0 || chosenApplication === 0}
onChange={(e) => setChosenUser(e.value)}
options={users}
optionLabel="name"
optionValue="value"/>
</div>
</Dialog>
</div>
)
}
export default DomandeInstructorManager;

View File

@@ -8,7 +8,7 @@ const DomandePreInstructor = () => {
return(
<div className="appPage">
<div className="appPage__pageHeader">
<h1>{__('Archivio domande', 'gepafin')}</h1>
<h1>{__('Domande da valutare', 'gepafin')}</h1>
</div>
<div className="appPage__spacer"></div>

View File

@@ -4,6 +4,7 @@ import { useNavigate, useParams } from 'react-router-dom';
import { is, isEmpty } from 'ramda';
import { useForm } from 'react-hook-form';
import { klona } from 'klona';
import { wrap } from 'object-path-immutable';
// store
import { storeSet, useStore } from '../../store';
@@ -25,11 +26,9 @@ import { Toast } from 'primereact/toast';
import { Dialog } from 'primereact/dialog';
import FormField from '../../components/FormField';
import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/SoccorsoComunications';
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
import { wrap } from 'object-path-immutable';
import { Editor } from 'primereact/editor';
const DomandaBeneficiario = () => {
const SoccorsoEditBeneficiario = () => {
const isAsyncRequest = useStore().main.isAsyncRequest();
const { id } = useParams();
const navigate = useNavigate();
@@ -117,7 +116,7 @@ const DomandaBeneficiario = () => {
const onSubmit = () => {
};
const doUpdateAmendment = () => {
const doUpdateAmendment = (doClose = false) => {
trigger();
let formValues = klona(getValues());
const newFormValues = Object.keys(formValues)
@@ -146,29 +145,47 @@ const DomandaBeneficiario = () => {
const amendmentId = data.id;
storeSet.main.setAsyncRequest();
AmendmentsService.updateSoccorso(amendmentId, submitData, updateAmendmentCallback, errUpdateAmendmentCallback);
AmendmentsService.updateSoccorso(
amendmentId,
submitData,
(resp) => updateAmendmentCallback(resp, doClose),
errUpdateAmendmentCallback
);
}
const updateAmendmentCallback = (data) => {
const doUpdateAmendmentAndCompleteTask = () => {
doUpdateAmendment(true);
}
const updateAmendmentCallback = (data, doClose = false) => {
if (data.status === 'SUCCESS') {
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: data.message
});
}
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
if (cur.fieldValue) {
acc[cur.fieldId] = cur.fieldValue;
setData(getFormattedData(data.data));
if (doClose) {
AmendmentsService.updateStatusSoccorso(data.data.id, updateAmendmentCallback, errUpdateAmendmentCallback, [
['status', 'RESPONSE_RECEIVED']
]);
} else {
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: data.message
});
}
return acc;
}, {});
formDataInitial = {
...formDataInitial,
amendmentDocuments: data.data.amendmentDocuments
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
if (cur.fieldValue) {
acc[cur.fieldId] = cur.fieldValue;
}
return acc;
}, {});
formDataInitial = {
...formDataInitial,
amendmentDocuments: data.data.amendmentDocuments
}
setFormInitialData(formDataInitial);
}
setFormInitialData(formDataInitial);
}
storeSet.main.unsetAsyncRequest();
}
@@ -330,7 +347,7 @@ const DomandaBeneficiario = () => {
? data.formFields.map((o, i) => {
return <FormField
key={o.fieldId}
disabled={data.status === 'CLOSE'}
disabled={data.status !== 'AWAITING'}
type="fileupload"
setDataFn={setValue}
saveFormCallback={doUpdateAmendment}
@@ -361,10 +378,11 @@ const DomandaBeneficiario = () => {
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
<div className="appPageSection">
<h3>{__('Notes', 'gepafin')}</h3>
<div style={{ marginBottom: '30px', width: '100%' }}>
<div style={{ marginBottom: '30px', width: '100%', position: 'relative' }}>
<BlockingOverlay shouldDisplay={data.status !== 'AWAITING'}/>
<Editor
value={data.amendmentNotes}
readOnly={data.status === 'CLOSE'}
readOnly={data.status !== 'AWAITING'}
placeholder={__('Digita qui il messagio', 'gepafin')}
headerTemplate={header}
onTextChange={(e) => updateNewAmendmentData(
@@ -376,7 +394,7 @@ const DomandaBeneficiario = () => {
</div>
<FormField
type="fileupload"
disabled={data.status === 'CLOSE'}
disabled={data.status !== 'AWAITING'}
setDataFn={setValue}
saveFormCallback={doUpdateAmendment}
fieldName="amendmentDocuments"
@@ -405,30 +423,30 @@ const DomandaBeneficiario = () => {
{data.id
? <Button
type="button"
disabled={isAsyncRequest}
onClick={() => setIsVisibleEmailDialog(true)}
label={__('Invia documenti via PEC', 'gepafin')}
icon="pi pi-envelope" iconPos="right"/> : null}
disabled={isAsyncRequest || data.status !== 'AWAITING'}
onClick={doUpdateAmendmentAndCompleteTask}
label={__('Invia documenti', 'gepafin')}
icon="pi pi-save" iconPos="right"/> : null}
{data.id
? <Button
type="button"
disabled={isAsyncRequest}
onClick={doUpdateAmendment}
label={__('Salva', 'gepafin')}
outlined
disabled={isAsyncRequest || data.status !== 'AWAITING'}
onClick={() => doUpdateAmendment()}
label={__('Salva bozza', 'gepafin')}
icon="pi pi-save" iconPos="right"/> : null}
<Button
type="button"
outlined
onClick={goToArchivePage}
disabled={isAsyncRequest}
label={__('Chiudi', 'gepafin')}
label={__('Indietro', 'gepafin')}
icon="pi pi-times" iconPos="right"/>
</div>
</div>
</div>
<Dialog
header={__('Invia documenti via PEC', 'gepafin')}
header={__('Invia documenti', 'gepafin')}
visible={isVisibleEmailDialog}
style={{ width: '50vw' }}
onHide={() => {
@@ -444,4 +462,4 @@ const DomandaBeneficiario = () => {
}
export default DomandaBeneficiario;
export default SoccorsoEditBeneficiario;

View File

@@ -28,7 +28,6 @@ import FormField from '../../components/FormField';
import { Editor } from 'primereact/editor';
import { InputNumber } from 'primereact/inputnumber';
import SoccorsoComunications from './components/SoccorsoComunications';
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
const SoccorsoEditPreInstructor = () => {
@@ -41,6 +40,7 @@ const SoccorsoEditPreInstructor = () => {
const [extendedTime, setExtendedTime] = useState(3);
const [isLoadingExtendingTime, setIsLoadingExtendingTime] = useState(false);
const [isLoadingReminding, setIsLoadingReminding] = useState(false);
const [internalNote, setInternalNote] = useState('');
const toast = useRef(null);
const [formInitialData, setFormInitialData] = useState({});
const {
@@ -125,7 +125,7 @@ const SoccorsoEditPreInstructor = () => {
const onSubmit = () => {
};
const doUpdateAmendment = () => {
const doUpdateAmendment = (doClose = false) => {
trigger();
let formValues = klona(getValues());
const newFormValues = Object.keys(formValues)
@@ -148,33 +148,49 @@ const SoccorsoEditPreInstructor = () => {
const submitData = {
applicationFormFields: newFormValues,
amendmentDocuments: newAmendDocs
amendmentDocuments: newAmendDocs,
amendmentNotes: data.amendmentNotes
}
storeSet.main.setAsyncRequest();
AmendmentsService.updateSoccorso(amendmentId, submitData, updateAmendmentCallback, errUpdateAmendmentCallback);
AmendmentsService.updateSoccorso(
amendmentId,
submitData,
(resp) => updateAmendmentCallback(resp, doClose),
errUpdateAmendmentCallback
);
}
const updateAmendmentCallback = (data) => {
const updateAmendmentCallback = (data, doClose = false) => {
if (data.status === 'SUCCESS') {
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: data.message
});
}
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
if (cur.fieldValue) {
acc[cur.fieldId] = cur.fieldValue;
setData(getFormattedData(data.data));
console.log('internalNote', internalNote)
if (doClose) {
const submitData = {
internalNote
}
return acc;
}, formInitialData);
formDataInitial = {
...formDataInitial,
amendmentDocuments: data.data.amendmentDocuments
storeSet.main.setAsyncRequest();
AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
} else {
if (toast.current) {
toast.current.show({
severity: 'success',
summary: '',
detail: data.message
});
}
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
if (cur.fieldValue) {
acc[cur.fieldId] = cur.fieldValue;
}
return acc;
}, formInitialData);
formDataInitial = {
...formDataInitial,
amendmentDocuments: data.data.amendmentDocuments
}
setFormInitialData(formDataInitial);
}
setFormInitialData(formDataInitial);
}
storeSet.main.unsetAsyncRequest();
}
@@ -214,11 +230,7 @@ const SoccorsoEditPreInstructor = () => {
}
const doCloseAmendment = () => {
const submitData = {
internalNote: data.internalNote
}
storeSet.main.setAsyncRequest();
AmendmentsService.closeSoccorso(amendmentId, submitData, closeAmendmentCallback, errCloseAmendmentCallback);
doUpdateAmendment(true);
}
const closeAmendmentCallback = (data) => {
@@ -434,7 +446,7 @@ const SoccorsoEditPreInstructor = () => {
{data.formFields.map((o, i) => {
return <FormField
key={o.fieldId}
disabled={data.status === 'CLOSE'}
disabled={data.status === 'CLOSE' || data.status === 'AWAITING'}
type="fileupload"
setDataFn={setValue}
saveFormCallback={doUpdateAmendment}
@@ -456,16 +468,24 @@ const SoccorsoEditPreInstructor = () => {
<div className="appPageSection">
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
<div className="appPageSection">
{data.amendmentNotes
? <>
<h3>{__('Notes', 'gepafin')}</h3>
<div className="ql-editor" style={{ marginBottom: '30px', width: '100%' }}>
{renderHtmlContent(data.amendmentNotes)}
</div>
</> : null}
<h3>{__('Notes', 'gepafin')}</h3>
<div style={{ marginBottom: '30px', width: '100%', position: 'relative' }}>
<BlockingOverlay shouldDisplay={data.status === 'CLOSE' || data.status === 'AWAITING'}/>
<Editor
value={data.amendmentNotes}
readOnly={data.status === 'CLOSE' || data.status === 'AWAITING'}
placeholder={__('Digita qui il messagio', 'gepafin')}
headerTemplate={header}
onTextChange={(e) => updateNewAmendmentData(
e.htmlValue,
'amendmentNotes'
)}
style={{ height: 80 * 3, width: '100%' }}
/>
</div>
<FormField
type="fileupload"
disabled={data.status === 'CLOSE'}
disabled={data.status === 'CLOSE' || data.status === 'AWAITING'}
setDataFn={setValue}
saveFormCallback={doUpdateAmendment}
fieldName="amendmentDocuments"
@@ -490,12 +510,6 @@ const SoccorsoEditPreInstructor = () => {
<div className="appPageSection">
<div className="appPageSection__actions">
{/*<Button
type="button"
disabled={isAsyncRequest}
onClick={doUpdateAmendment}
label={__('Salva', 'gepafin')}
icon="pi pi-save" iconPos="right"/>*/}
<Button
type="button"
onClick={sendReminder}
@@ -512,12 +526,12 @@ const SoccorsoEditPreInstructor = () => {
label={__('Estendi Scadenza', 'gepafin')}
icon="pi pi-stopwatch"
/>
{/*<Button
<Button
type="button"
onClick={doUpdateAmendment}
disabled={isAsyncRequest || data.status === 'CLOSE'}
onClick={() => doUpdateAmendment()}
disabled={isAsyncRequest || data.status === 'CLOSE' || data.status === 'AWAITING'}
label={__('Salva bozza', 'gepafin')}
icon="pi pi-save" iconPos="right"/>*/}
icon="pi pi-save" iconPos="right"/>
<Button
type="button"
onClick={openCloseAmendmentDialog}
@@ -562,14 +576,11 @@ const SoccorsoEditPreInstructor = () => {
<div style={{ position: 'relative' }}>
<BlockingOverlay shouldDisplay={data.status === 'CLOSE'}/>
<Editor
value={data.internalNote}
value={internalNote}
readOnly={data.status === 'CLOSE'}
placeholder={__('Digita qui il messagio', 'gepafin')}
headerTemplate={header}
onTextChange={(e) => updateNewAmendmentData(
e.htmlValue,
['internalNote']
)}
onTextChange={(e) => setInternalNote(e.htmlValue)}
style={{ height: 80 * 3, width: '100%' }}
/>
</div>

View File

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

View File

@@ -121,7 +121,7 @@ const Users = () => {
const getRolesCallback = (data) => {
if (data.status === 'SUCCESS') {
const roles = data.data
.filter(o => ['ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR'].includes(o.roleType))
.filter(o => ['ROLE_SUPER_ADMIN', 'ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.roleType))
.map(o => ({
name: o.roleName,
value: o.id

View File

@@ -34,9 +34,10 @@ import SoccorsoIstruttorioPreInstructor from './pages/SoccorsoIstruttorioPreInst
import SoccorsoEditPreInstructor from './pages/SoccorsoEditPreInstructor';
import SoccorsoAddPreInstructor from './pages/SoccorsoAddPreInstructor';
import DomandeBeneficiario from './pages/DomandeBeneficiario';
import DomandaBeneficiario from './pages/DomandaBeneficiario';
import SoccorsoEditBeneficiario from './pages/SoccorsoEditBeneficiario';
import BandoApplicationPreview from './pages/BandoApplicationPreview';
import BandiPreferredBeneficiario from './pages/BandiPreferredBeneficiario';
import DomandeInstructorManager from './pages/DomandeInstructorManager';
const routes = ({ role, chosenCompanyId }) => {
@@ -47,106 +48,127 @@ const routes = ({ role, chosenCompanyId }) => {
{'ROLE_SUPER_ADMIN' === role ? <Dashboard/> : null}
{'ROLE_BENEFICIARY' === role ? <DashboardBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <DashboardPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <DashboardPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/bandi" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <Bandi/> : null}
{'ROLE_BENEFICIARY' === role ? <BandiBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoEdit/> : null}
{'ROLE_BENEFICIARY' === role ? <BandoViewBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
<Route path="/bandi/:id/preview" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <BandoView/> : null}
{'ROLE_BENEFICIARY' === 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_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_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_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_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_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_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_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 ? <DomandaBeneficiario/> : null}
{'ROLE_BENEFICIARY' === role ? <SoccorsoEditBeneficiario/> : null}
{'ROLE_PRE_INSTRUCTOR' === role ? <DomandaEditPreInstructor/> : 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_PRE_INSTRUCTOR' === role ? <SoccorsoAddPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoAddPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/domande/:id/soccorso/:amendmentId" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === 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_PRE_INSTRUCTOR' === role ? <SoccorsoIstruttorioPreInstructor/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <SoccorsoIstruttorioPreInstructor/> : null}
</DefaultLayout>}/>
<Route path="/imieibandi" element={<DefaultLayout>
{'ROLE_SUPER_ADMIN' === role ? <PageNotFound/> : null}
{'ROLE_BENEFICIARY' === 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_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_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_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_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_PRE_INSTRUCTOR' === role ? <PageNotFound/> : null}
{'ROLE_INSTRUCTOR_MANAGER' === role ? <PageNotFound/> : null}
</DefaultLayout>}/>
</Route>
<Route exact path="/reset-password" element={<ResetPassword/>}/>

View File

@@ -28,6 +28,10 @@ export default class AmendmentsService {
NetworkService.put(`${API_BASE_URL}/amendments/${id}`, body, callback, errCallback, queryParams);
};
static updateStatusSoccorso = (id, callback, errCallback, queryParams) => {
NetworkService.put(`${API_BASE_URL}/amendments/${id}/status`, {}, callback, errCallback, queryParams);
};
static extendSoccorso = (id, days, callback, errCallback, queryParams) => {
NetworkService.put(`${API_BASE_URL}/amendments/${id}/extendExpiration`, {}, callback, errCallback, [
['extendedDays', days]