- progress;
This commit is contained in:
@@ -113,9 +113,14 @@ const AllBandiAccordion = () => {
|
||||
<div className="p-3">
|
||||
{renderHtmlContent(data.descriptionShort)}
|
||||
<p>{__('Scadenza', 'gepafin')}: {getDateFromISOstring(data.dates[1])}</p>
|
||||
<Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{!data.confidi
|
||||
? <Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{__('Partecipa', 'gepafin')}
|
||||
</Button>
|
||||
</Button> : null}
|
||||
{data.confidi
|
||||
? <Button onClick={() => goToBandoPage(data.id)} severity="info">
|
||||
{__('Mostra', 'gepafin')}
|
||||
</Button> : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -379,6 +379,13 @@ const BandoViewBeneficiario = () => {
|
||||
</>
|
||||
: null}
|
||||
|
||||
{data.confidi
|
||||
? <>
|
||||
<Message severity="error"
|
||||
text={__('Non sei abilitato a partecipare a questo Bando', 'gepafin')}/>
|
||||
</>
|
||||
: null}
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Download Documenti', 'gepafin')}</h2>
|
||||
<div className="appPageSection__actions">
|
||||
@@ -391,13 +398,14 @@ const BandoViewBeneficiario = () => {
|
||||
icon="pi pi-download" iconPos="right"/>*/}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={data.confidi}
|
||||
outlined
|
||||
onClick={scaricaModulistica}
|
||||
label={__('Scarica Bando Completo e Modulistica', 'gepafin')}
|
||||
icon="pi pi-download" iconPos="right"/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={isAsyncRequest || chosenCompanyId === 0}
|
||||
disabled={isAsyncRequest || chosenCompanyId === 0 || data.confidi}
|
||||
onClick={submitApplication}
|
||||
label={__('Presenta Domanda', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect} from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { uniq } from 'ramda';
|
||||
import { Link } from 'react-router-dom';
|
||||
@@ -130,14 +130,19 @@ const LatestBandiTable = () => {
|
||||
};
|
||||
|
||||
const actionsBodyTemplate = (rowData) => {
|
||||
return <Link to={`/bandi/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Partecipa', 'gepafin')} icon="pi pi-arrow-right" size="small" iconPos="right" />
|
||||
</Link>
|
||||
return rowData.confidi
|
||||
? <Link to={`/bandi/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right"/>
|
||||
</Link>
|
||||
: <Link to={`/bandi/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Partecipa', 'gepafin')} icon="pi pi-arrow-right" size="small"
|
||||
iconPos="right"/>
|
||||
</Link>
|
||||
}
|
||||
|
||||
const header = renderHeader();
|
||||
|
||||
return(
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
<DataTable value={items} paginator showGridlines rows={10} loading={loading} dataKey="id"
|
||||
filters={filters}
|
||||
|
||||
@@ -157,7 +157,7 @@ const MyLatestSubmissionsTable = () => {
|
||||
{'DRAFT' === rowData.status
|
||||
? <Button severity="info" label={__('Modifica', 'gepafin')} icon="pi pi-pencil" size="small"
|
||||
iconPos="right"/>
|
||||
: <Button severity="info" label={__('View', 'gepafin')} icon="pi pi-eye" size="small"
|
||||
: <Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small"
|
||||
iconPos="right"/>}
|
||||
</Link>
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import { Calendar } from 'primereact/calendar';
|
||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
|
||||
|
||||
const AllDomandeTable = () => {
|
||||
const AllDomandeTable = ({ openDialogFn }) => {
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
@@ -125,9 +125,10 @@ const AllDomandeTable = () => {
|
||||
};
|
||||
|
||||
const actionsBodyTemplate = (rowData) => {
|
||||
return <Link to={`/bandi/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Modifica', 'gepafin')} icon="pi pi-pencil" size="small" iconPos="right" />
|
||||
</Link>
|
||||
return <Button severity="info"
|
||||
onClick={() => openDialogFn(rowData.id)}
|
||||
label={__('Assign', 'gepafin')}
|
||||
icon="pi pi-pencil" size="small" iconPos="right" />
|
||||
}
|
||||
|
||||
const header = renderHeader();
|
||||
|
||||
@@ -1,11 +1,127 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
// api
|
||||
import UserService from '../../service/user-service';
|
||||
|
||||
// store
|
||||
import { storeSet } from '../../store';
|
||||
|
||||
// tools
|
||||
import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
|
||||
// components
|
||||
import AllDomandeTable from './components/AllDomandeTable';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { Button } from 'primereact/button';
|
||||
import { classNames } from 'primereact/utils';
|
||||
import { isEmpty, isNil } from 'ramda';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import AssignedApplicationService from '../../service/assigned-application-service';
|
||||
|
||||
const Domande = () => {
|
||||
return(
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
|
||||
const [roleId, setRoleId] = useState(0);
|
||||
const [users, setUsers] = useState([]);
|
||||
const [chosenUser, setChosenUser] = useState(0);
|
||||
const [chosenApplication, setChosenApplication] = useState(0);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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>{__('Assign application', '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') {
|
||||
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errAssignApplCallback = (data) => {
|
||||
set404FromErrorResponse(data);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (roleId !== 0) {
|
||||
setLoading(true);
|
||||
UserService.getUsers(getUsersCallback, errGetUsersCallback, [['roleId', roleId]])
|
||||
}
|
||||
}, [roleId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isVisibleEditDialog) {
|
||||
setLoading(true);
|
||||
UserService.getRoles(getRolesCallback, errGetRolesCallback)
|
||||
}
|
||||
}, [isVisibleEditDialog]);
|
||||
|
||||
return (
|
||||
<div className="appPage">
|
||||
<div className="appPage__pageHeader">
|
||||
<h1>{__('Gestione domande', 'gepafin')}</h1>
|
||||
@@ -14,8 +130,30 @@ const Domande = () => {
|
||||
<div className="appPage__spacer"></div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<AllDomandeTable/>
|
||||
<AllDomandeTable openDialogFn={openAssignDialog}/>
|
||||
</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 })}>
|
||||
{__('Pre-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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ const Users = () => {
|
||||
name: o.roleName,
|
||||
value: o.id
|
||||
}));
|
||||
setRoles(roles)
|
||||
setRoles(roles);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -160,7 +160,7 @@ const Users = () => {
|
||||
label={__('Crea nuovo')} icon="pi pi-plus" iconPos="right"/>
|
||||
</div>
|
||||
|
||||
<AllUsersTable doRefresh={true}/>
|
||||
<AllUsersTable/>
|
||||
|
||||
<Dialog
|
||||
visible={isVisibleEditDialog}
|
||||
|
||||
10
src/service/assigned-application-service.js
Normal file
10
src/service/assigned-application-service.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NetworkService } from './network-service';
|
||||
|
||||
const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
|
||||
|
||||
export default class AssignedApplicationService {
|
||||
|
||||
static assignApplication = (id, callback, errCallback, queryParams) => {
|
||||
NetworkService.post(`${API_BASE_URL}/assignedApplication/application/${id}`, {}, callback, errCallback, queryParams);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user