- added 4 root admin components;
This commit is contained in:
1
.env
1
.env
@@ -1,5 +1,6 @@
|
|||||||
REACT_APP_TAB_TITLE=Gepafin
|
REACT_APP_TAB_TITLE=Gepafin
|
||||||
REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1
|
REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1
|
||||||
|
REACT_APP_API_ADMIN_BASE_URL=https://admin-gepafin-dev-be.bflows.ai
|
||||||
REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit
|
REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit
|
||||||
REACT_APP_API_ADDRESS_WS=https://api-dev-gepafin.memento.credit/wss
|
REACT_APP_API_ADDRESS_WS=https://api-dev-gepafin.memento.credit/wss
|
||||||
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
|
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
REACT_APP_TAB_TITLE=Gepafin
|
REACT_APP_TAB_TITLE=Gepafin
|
||||||
REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1
|
REACT_APP_API_EXECUTION_ADDRESS=https://api-dev-gepafin.memento.credit/v1
|
||||||
|
REACT_APP_API_ADMIN_BASE_URL=https://admin-gepafin-dev-be.bflows.ai
|
||||||
REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit
|
REACT_APP_API_ADDRESS=https://api-dev-gepafin.memento.credit
|
||||||
REACT_APP_API_ADDRESS_WS=https://api-dev-gepafin.memento.credit/wss
|
REACT_APP_API_ADDRESS_WS=https://api-dev-gepafin.memento.credit/wss
|
||||||
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
|
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
REACT_APP_TAB_TITLE=Gepafin
|
REACT_APP_TAB_TITLE=Gepafin
|
||||||
REACT_APP_API_EXECUTION_ADDRESS=https://bandi-api.gepafin.it/v1
|
REACT_APP_API_EXECUTION_ADDRESS=https://bandi-api.gepafin.it/v1
|
||||||
|
REACT_APP_API_ADMIN_BASE_URL=https://admin-gepafin-dev-be.bflows.ai
|
||||||
REACT_APP_API_ADDRESS=https://bandi-api.gepafin.it
|
REACT_APP_API_ADDRESS=https://bandi-api.gepafin.it
|
||||||
REACT_APP_API_ADDRESS_WS=https://bandi-api.gepafin.it/wss
|
REACT_APP_API_ADDRESS_WS=https://bandi-api.gepafin.it/wss
|
||||||
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
|
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
|
||||||
|
|||||||
@@ -1,10 +1,280 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { is } from 'ramda';
|
||||||
|
|
||||||
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import AmendmentsService from '../../../../service/amendments-service';
|
||||||
|
import AdminService from '../../../../service/admin-service';
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||||
|
import getQueryParamsForPaginatedEndpoint from '../../../../helpers/getQueryParamsForPaginatedEndpoint';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { InputNumber } from 'primereact/inputnumber';
|
||||||
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
|
|
||||||
|
const statuses = ['AWAITING', 'RESPONSE_RECEIVED', 'CLOSE', 'EXPIRED'];
|
||||||
|
|
||||||
const ManageAmendmentExtendSection = () => {
|
const ManageAmendmentExtendSection = () => {
|
||||||
return <div className="appPageSection">
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
<h2>{__('Estensione soccorso istruttorio', 'gepafin')}</h2>
|
const [items, setItems] = useState(null);
|
||||||
</div>
|
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||||
}
|
const [isExtendDialogVisible, setIsExtendDialogVisible] = useState(false);
|
||||||
|
const [selectedAmendmentId, setSelectedAmendmentId] = useState(null);
|
||||||
|
const [daysValue, setDaysValue] = useState(1);
|
||||||
|
const [lazyState, setLazyState] = useState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
applicationId: { value: null, matchMode: 'equals' },
|
||||||
|
callName: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
expirationDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
|
const getPaginationQuery = useCallback(
|
||||||
|
() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'applicationId', { personalRecords: false }),
|
||||||
|
[lazyState]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onPage = (event) => setLazyState(event);
|
||||||
|
|
||||||
|
const onSort = (event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFilter = useCallback((event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
const getFormattedData = (data) => data.map((d) => {
|
||||||
|
d.startDate = is(String, d.startDate) ? new Date(d.startDate) : (d.startDate ? d.startDate : '');
|
||||||
|
d.expirationDate = is(String, d.expirationDate) ? new Date(d.expirationDate) : (d.expirationDate ? d.expirationDate : '');
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getCallback = (resp) => {
|
||||||
|
if (resp.status === 'SUCCESS') {
|
||||||
|
const { body, totalRecords } = resp.data;
|
||||||
|
setTotalRecordsNum(totalRecords);
|
||||||
|
setItems(getFormattedData(body));
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const errGetCallback = () => setLocalAsyncRequest(false);
|
||||||
|
|
||||||
|
const openExtendDialog = (amendmentId) => {
|
||||||
|
setSelectedAmendmentId(amendmentId);
|
||||||
|
setDaysValue(1);
|
||||||
|
setIsExtendDialogVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const hideExtendDialog = () => {
|
||||||
|
setIsExtendDialogVisible(false);
|
||||||
|
setSelectedAmendmentId(null);
|
||||||
|
setDaysValue(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleExtend = useCallback(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
AdminService.doAmendmentExtend(
|
||||||
|
{ amendment_id: selectedAmendmentId, days: daysValue },
|
||||||
|
(resp) => {
|
||||||
|
if (resp && resp.status === 'ok') {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({ severity: 'success', summary: '', detail: __('Scadenza estesa con successo', 'gepafin') });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
hideExtendDialog();
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({ severity: 'error', summary: '', detail: resp ? resp.detail : __('Errore', 'gepafin') });
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
hideExtendDialog();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, [selectedAmendmentId, daysValue]);
|
||||||
|
|
||||||
|
const actionsBodyTemplate = (rowData) => (
|
||||||
|
<div className="appPageSection__tableActions lessGap">
|
||||||
|
<Button
|
||||||
|
severity="info"
|
||||||
|
label={__('Extend', 'gepafin')}
|
||||||
|
size="small"
|
||||||
|
onClick={() => openExtendDialog(rowData.id)}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusBodyTemplate = (rowData) => <ProperBandoLabel status={rowData.status}/>;
|
||||||
|
|
||||||
|
const statusItemTemplate = (option) => <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)}/>;
|
||||||
|
|
||||||
|
const statusFilterTemplate = (options) => (
|
||||||
|
<Dropdown
|
||||||
|
value={options.value}
|
||||||
|
options={statuses}
|
||||||
|
valueTemplate={getBandoLabel(options.value)}
|
||||||
|
onChange={(e) => {
|
||||||
|
options.filterCallback(e.value, options.index);
|
||||||
|
const filters = { ...lazyState.filters };
|
||||||
|
if (e.value) {
|
||||||
|
filters['status'] = { value: e.value, matchMode: 'equals' };
|
||||||
|
} else {
|
||||||
|
delete filters['status'];
|
||||||
|
}
|
||||||
|
setLazyState({ ...lazyState, filters, first: 0 });
|
||||||
|
}}
|
||||||
|
itemTemplate={statusItemTemplate}
|
||||||
|
placeholder={translationStrings.selectOneLabel}
|
||||||
|
className="p-column-filter"/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const dateFilterTemplate = (options) => (
|
||||||
|
<Calendar
|
||||||
|
value={options.value}
|
||||||
|
onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||||
|
dateFormat="dd/mm/yy" placeholder="dd/mm/yyyy" mask="99/99/9999"/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const dateStartBodyTemplate = (rowData) => getFormattedDateString(rowData.startDate);
|
||||||
|
const dateExpirationBodyTemplate = (rowData) => rowData.expirationDate ? getFormattedDateString(rowData.expirationDate) : '';
|
||||||
|
|
||||||
|
const clearFilter = () => {
|
||||||
|
setLazyState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
applicationId: { value: null, matchMode: 'equals' },
|
||||||
|
callName: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
expirationDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const header = (
|
||||||
|
<div className="flex justify-content-between">
|
||||||
|
<Button type="button" icon="pi pi-filter-slash" label={__('Pulisci', 'gepafin')} outlined onClick={clearFilter}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const extendDialogFooter = (
|
||||||
|
<div>
|
||||||
|
<Button label={__('Annulla', 'gepafin')} icon="pi pi-times" outlined onClick={hideExtendDialog}/>
|
||||||
|
<Button label={__('Salva', 'gepafin')} icon="pi pi-check" disabled={!daysValue || daysValue < 1} onClick={handleExtend}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const paginationQuery = getPaginationQuery();
|
||||||
|
AmendmentsService.getSoccorsiPaginated(1, paginationQuery, getCallback, errGetCallback);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="appPageSection">
|
||||||
|
<h2>{__('Estensione soccorso istruttorio', 'gepafin')}</h2>
|
||||||
|
<Toast ref={toast}/>
|
||||||
|
<div className="appPageSection__table">
|
||||||
|
<DataTable
|
||||||
|
value={items} stripedRows showGridlines
|
||||||
|
lazy filterDisplay="menu" dataKey="id" paginator
|
||||||
|
first={lazyState.first} rows={lazyState.rows} totalRecords={totalRecordsNum} onPage={onPage}
|
||||||
|
onSort={onSort} sortField={lazyState.sortField} sortOrder={lazyState.sortOrder}
|
||||||
|
onFilter={onFilter} filters={lazyState.filters} loading={localAsyncRequest}
|
||||||
|
header={header}
|
||||||
|
emptyMessage={translationStrings.emptyMessage}>
|
||||||
|
<Column field="applicationId" header={__('ID domanda', 'gepafin')}
|
||||||
|
sortable
|
||||||
|
filterField="applicationId" filter
|
||||||
|
filterMatchModeOptions={translationStrings.numberFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca', 'gepafin')}
|
||||||
|
style={{ minWidth: '6rem' }}/>
|
||||||
|
<Column field="callName" header={__('Bando', 'gepafin')}
|
||||||
|
filterField="callName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '10rem' }}/>
|
||||||
|
<Column field="companyName" header={__('Azienda Beneficiaria', 'gepafin')}
|
||||||
|
filterField="companyName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column header={__('Data richiesta', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="startDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={dateStartBodyTemplate}/>
|
||||||
|
<Column header={__('Scadenza', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="expirationDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={dateExpirationBodyTemplate}/>
|
||||||
|
<Column field="status" header={__('Stato', 'gepafin')}
|
||||||
|
filterElement={statusFilterTemplate} filter
|
||||||
|
filterMatchModeOptions={translationStrings.statusFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={statusBodyTemplate}/>
|
||||||
|
<Column header={__('Azioni', 'gepafin')}
|
||||||
|
body={actionsBodyTemplate}/>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
visible={isExtendDialogVisible}
|
||||||
|
modal
|
||||||
|
header={__('Estendi scadenza', 'gepafin')}
|
||||||
|
footer={extendDialogFooter}
|
||||||
|
style={{ maxWidth: '400px', width: '100%' }}
|
||||||
|
onHide={hideExtendDialog}>
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label htmlFor="daysInput">{__('Numero di giorni', 'gepafin')}</label>
|
||||||
|
<InputNumber
|
||||||
|
id="daysInput"
|
||||||
|
value={daysValue}
|
||||||
|
onValueChange={(e) => setDaysValue(e.value)}
|
||||||
|
min={1}
|
||||||
|
showButtons
|
||||||
|
style={{ width: '100%' }}/>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default ManageAmendmentExtendSection;
|
export default ManageAmendmentExtendSection;
|
||||||
|
|||||||
@@ -1,10 +1,236 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { is } from 'ramda';
|
||||||
|
|
||||||
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import AmendmentsService from '../../../../service/amendments-service';
|
||||||
|
import AdminService from '../../../../service/admin-service';
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||||
|
import getQueryParamsForPaginatedEndpoint from '../../../../helpers/getQueryParamsForPaginatedEndpoint';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
|
|
||||||
|
const statuses = ['AWAITING', 'RESPONSE_RECEIVED', 'CLOSE', 'EXPIRED'];
|
||||||
|
|
||||||
const ManageAmendmentReopenSection = () => {
|
const ManageAmendmentReopenSection = () => {
|
||||||
return <div className="appPageSection">
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
<h2>{__('Riapertura soccorso istruttorio', 'gepafin')}</h2>
|
const [items, setItems] = useState(null);
|
||||||
</div>
|
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||||
}
|
const [lazyState, setLazyState] = useState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
applicationId: { value: null, matchMode: 'equals' },
|
||||||
|
callName: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
expirationDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
|
const getPaginationQuery = useCallback(
|
||||||
|
() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'applicationId', { personalRecords: false }),
|
||||||
|
[lazyState]
|
||||||
|
);
|
||||||
|
|
||||||
|
const onPage = (event) => setLazyState(event);
|
||||||
|
|
||||||
|
const onSort = (event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFilter = useCallback((event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
const getFormattedData = (data) => data.map((d) => {
|
||||||
|
d.startDate = is(String, d.startDate) ? new Date(d.startDate) : (d.startDate ? d.startDate : '');
|
||||||
|
d.expirationDate = is(String, d.expirationDate) ? new Date(d.expirationDate) : (d.expirationDate ? d.expirationDate : '');
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getCallback = (resp) => {
|
||||||
|
if (resp.status === 'SUCCESS') {
|
||||||
|
const { body, totalRecords } = resp.data;
|
||||||
|
setTotalRecordsNum(totalRecords);
|
||||||
|
setItems(getFormattedData(body));
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const errGetCallback = () => setLocalAsyncRequest(false);
|
||||||
|
|
||||||
|
const handleReopen = (amendmentId) => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
AdminService.doAmendmentReopen(
|
||||||
|
{ amendment_id: amendmentId },
|
||||||
|
(resp) => {
|
||||||
|
if (resp && resp.status === 'ok') {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({ severity: 'success', summary: '', detail: __('Soccorso riaperto con successo', 'gepafin') });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
},
|
||||||
|
(resp) => {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({ severity: 'error', summary: '', detail: resp ? resp.detail : __('Errore', 'gepafin') });
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionsBodyTemplate = (rowData) => (
|
||||||
|
<div className="appPageSection__tableActions lessGap">
|
||||||
|
<Button
|
||||||
|
severity="warning"
|
||||||
|
label={__('Re open', 'gepafin')}
|
||||||
|
size="small"
|
||||||
|
disabled={localAsyncRequest}
|
||||||
|
onClick={() => handleReopen(rowData.id)}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusBodyTemplate = (rowData) => <ProperBandoLabel status={rowData.status}/>;
|
||||||
|
|
||||||
|
const statusItemTemplate = (option) => <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)}/>;
|
||||||
|
|
||||||
|
const statusFilterTemplate = (options) => (
|
||||||
|
<Dropdown
|
||||||
|
value={options.value}
|
||||||
|
options={statuses}
|
||||||
|
valueTemplate={getBandoLabel(options.value)}
|
||||||
|
onChange={(e) => {
|
||||||
|
options.filterCallback(e.value, options.index);
|
||||||
|
const filters = { ...lazyState.filters };
|
||||||
|
if (e.value) {
|
||||||
|
filters['status'] = { value: e.value, matchMode: 'equals' };
|
||||||
|
} else {
|
||||||
|
delete filters['status'];
|
||||||
|
}
|
||||||
|
setLazyState({ ...lazyState, filters, first: 0 });
|
||||||
|
}}
|
||||||
|
itemTemplate={statusItemTemplate}
|
||||||
|
placeholder={translationStrings.selectOneLabel}
|
||||||
|
className="p-column-filter"/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const dateFilterTemplate = (options) => (
|
||||||
|
<Calendar
|
||||||
|
value={options.value}
|
||||||
|
onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||||
|
dateFormat="dd/mm/yy" placeholder="dd/mm/yyyy" mask="99/99/9999"/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const dateStartBodyTemplate = (rowData) => getFormattedDateString(rowData.startDate);
|
||||||
|
const dateExpirationBodyTemplate = (rowData) => rowData.expirationDate ? getFormattedDateString(rowData.expirationDate) : '';
|
||||||
|
|
||||||
|
const clearFilter = () => {
|
||||||
|
setLazyState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
applicationId: { value: null, matchMode: 'equals' },
|
||||||
|
callName: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
startDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
expirationDate: { value: null, matchMode: 'dateIs' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const header = (
|
||||||
|
<div className="flex justify-content-between">
|
||||||
|
<Button type="button" icon="pi pi-filter-slash" label={__('Pulisci', 'gepafin')} outlined onClick={clearFilter}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const paginationQuery = getPaginationQuery();
|
||||||
|
AmendmentsService.getSoccorsiPaginated(1, paginationQuery, getCallback, errGetCallback);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="appPageSection">
|
||||||
|
<h2>{__('Riapertura soccorso istruttorio', 'gepafin')}</h2>
|
||||||
|
<Toast ref={toast}/>
|
||||||
|
<div className="appPageSection__table">
|
||||||
|
<DataTable
|
||||||
|
value={items} stripedRows showGridlines
|
||||||
|
lazy filterDisplay="menu" dataKey="id" paginator
|
||||||
|
first={lazyState.first} rows={lazyState.rows} totalRecords={totalRecordsNum} onPage={onPage}
|
||||||
|
onSort={onSort} sortField={lazyState.sortField} sortOrder={lazyState.sortOrder}
|
||||||
|
onFilter={onFilter} filters={lazyState.filters} loading={localAsyncRequest}
|
||||||
|
header={header}
|
||||||
|
emptyMessage={translationStrings.emptyMessage}>
|
||||||
|
<Column field="applicationId" header={__('ID domanda', 'gepafin')}
|
||||||
|
sortable
|
||||||
|
filterField="applicationId" filter
|
||||||
|
filterMatchModeOptions={translationStrings.numberFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca', 'gepafin')}
|
||||||
|
style={{ minWidth: '6rem' }}/>
|
||||||
|
<Column field="callName" header={__('Bando', 'gepafin')}
|
||||||
|
filterField="callName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '10rem' }}/>
|
||||||
|
<Column field="companyName" header={__('Azienda Beneficiaria', 'gepafin')}
|
||||||
|
filterField="companyName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column header={__('Data richiesta', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="startDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={dateStartBodyTemplate}/>
|
||||||
|
<Column header={__('Scadenza', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="expirationDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={dateExpirationBodyTemplate}/>
|
||||||
|
<Column field="status" header={__('Stato', 'gepafin')}
|
||||||
|
filterElement={statusFilterTemplate} filter
|
||||||
|
filterMatchModeOptions={translationStrings.statusFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={statusBodyTemplate}/>
|
||||||
|
<Column header={__('Azioni', 'gepafin')}
|
||||||
|
body={actionsBodyTemplate}/>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default ManageAmendmentReopenSection;
|
export default ManageAmendmentReopenSection;
|
||||||
|
|||||||
@@ -1,10 +1,283 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import ApplicationService from '../../../../service/application-service';
|
||||||
|
import AdminService from '../../../../service/admin-service';
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
import getQueryParamsForPaginatedEndpoint from '../../../../helpers/getQueryParamsForPaginatedEndpoint';
|
||||||
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
|
||||||
|
const allStatuses = [
|
||||||
|
'SUBMIT', 'EVALUATION', 'SOCCORSO', 'APPOINTMENT', 'NDG', 'ADMISSIBLE',
|
||||||
|
'AWAITING_TECHNICAL_EVALUATION', 'TECHNICAL_EVALUATION'
|
||||||
|
];
|
||||||
|
|
||||||
|
const availableStatuses = [
|
||||||
|
'EVALUATION', 'SOCCORSO', 'APPOINTMENT', 'NDG', 'ADMISSIBLE',
|
||||||
|
'AWAITING_TECHNICAL_EVALUATION', 'TECHNICAL_EVALUATION'
|
||||||
|
];
|
||||||
|
|
||||||
const ManageApplStatusSection = () => {
|
const ManageApplStatusSection = () => {
|
||||||
return <div className="appPageSection">
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
<h2>{__('Gestione stato domande', 'gepafin')}</h2>
|
const [items, setItems] = useState(null);
|
||||||
</div>
|
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||||
}
|
const [isStatusDialogVisible, setIsStatusDialogVisible] = useState(false);
|
||||||
|
const [selectedAppId, setSelectedAppId] = useState(null);
|
||||||
|
const [selectedStatus, setSelectedStatus] = useState(null);
|
||||||
|
const [lazyState, setLazyState] = useState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
id: { value: null, matchMode: 'equals' },
|
||||||
|
callTitle: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
|
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, allStatuses, 'id'), [lazyState]);
|
||||||
|
|
||||||
|
const onPage = (event) => {
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSort = (event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFilter = useCallback((event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
const getCallback = (resp) => {
|
||||||
|
if (resp.status === 'SUCCESS') {
|
||||||
|
const { body, totalRecords } = resp.data;
|
||||||
|
setTotalRecordsNum(totalRecords);
|
||||||
|
setItems(body);
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const errGetCallback = () => {
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openStatusDialog = (appId) => {
|
||||||
|
setSelectedAppId(appId);
|
||||||
|
setSelectedStatus(null);
|
||||||
|
setIsStatusDialogVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const hideStatusDialog = () => {
|
||||||
|
setIsStatusDialogVisible(false);
|
||||||
|
setSelectedAppId(null);
|
||||||
|
setSelectedStatus(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeStatus = useCallback(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const body = { application_id: selectedAppId, status: selectedStatus };
|
||||||
|
|
||||||
|
AdminService.setApplStatus(body, callback, errCallback);
|
||||||
|
}, [selectedStatus, selectedAppId]);
|
||||||
|
|
||||||
|
const callback = (resp) => {
|
||||||
|
setItems(prev => prev.map(o => {
|
||||||
|
return o.id === resp.application_id
|
||||||
|
? {
|
||||||
|
...o,
|
||||||
|
status: resp.status_set
|
||||||
|
}
|
||||||
|
: o;
|
||||||
|
}));
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
hideStatusDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errCallback = () => {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'error',
|
||||||
|
summary: '',
|
||||||
|
detail: resp.detail
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
hideStatusDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionsBodyTemplate = (rowData) => {
|
||||||
|
return (
|
||||||
|
<div className="appPageSection__tableActions lessGap">
|
||||||
|
<Button
|
||||||
|
severity="info"
|
||||||
|
onClick={() => openStatusDialog(rowData.id)}
|
||||||
|
label={__('Cambia stato', 'gepafin')}
|
||||||
|
icon="pi pi-sync"
|
||||||
|
size="small"
|
||||||
|
iconPos="right"/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusBodyTemplate = (rowData) => {
|
||||||
|
return <ProperBandoLabel status={rowData.status}/>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusItemTemplate = (option) => {
|
||||||
|
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)}/>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusFilterTemplate = (options) => {
|
||||||
|
return (
|
||||||
|
<Dropdown
|
||||||
|
value={options.value}
|
||||||
|
options={allStatuses}
|
||||||
|
valueTemplate={getBandoLabel(options.value)}
|
||||||
|
onChange={(e) => {
|
||||||
|
options.filterCallback(e.value, options.index);
|
||||||
|
const filters = { ...lazyState.filters };
|
||||||
|
if (e.value) {
|
||||||
|
filters['status'] = { value: e.value, matchMode: 'equals' };
|
||||||
|
} else {
|
||||||
|
delete filters['status'];
|
||||||
|
}
|
||||||
|
setLazyState({ ...lazyState, filters, first: 0 });
|
||||||
|
}}
|
||||||
|
itemTemplate={statusItemTemplate}
|
||||||
|
placeholder={translationStrings.selectOneLabel}
|
||||||
|
className="p-column-filter"/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearFilter = () => {
|
||||||
|
setLazyState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
id: { value: null, matchMode: 'equals' },
|
||||||
|
callTitle: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderHeader = () => (
|
||||||
|
<div className="flex justify-content-between">
|
||||||
|
<Button type="button" icon="pi pi-filter-slash" label={__('Pulisci', 'gepafin')} outlined
|
||||||
|
onClick={clearFilter}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const statusDialogFooter = (
|
||||||
|
<div>
|
||||||
|
<Button label={__('Annulla', 'gepafin')} icon="pi pi-times" outlined onClick={hideStatusDialog}/>
|
||||||
|
<Button label={__('Salva', 'gepafin')} icon="pi pi-check" onClick={handleChangeStatus}
|
||||||
|
disabled={!selectedStatus}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const header = renderHeader();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const paginationQuery = getPaginationQuery();
|
||||||
|
ApplicationService.getApplicationsPaginated(paginationQuery, getCallback, errGetCallback);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="appPageSection">
|
||||||
|
<h2>{__('Gestione stato domande', 'gepafin')}</h2>
|
||||||
|
<Toast ref={toast}/>
|
||||||
|
<div className="appPageSection__table">
|
||||||
|
<DataTable
|
||||||
|
value={items} stripedRows showGridlines
|
||||||
|
lazy filterDisplay="menu" dataKey="id" paginator
|
||||||
|
first={lazyState.first} rows={lazyState.rows} totalRecords={totalRecordsNum} onPage={onPage}
|
||||||
|
onSort={onSort} sortField={lazyState.sortField} sortOrder={lazyState.sortOrder}
|
||||||
|
onFilter={onFilter} filters={lazyState.filters} loading={localAsyncRequest}
|
||||||
|
header={header}
|
||||||
|
emptyMessage={translationStrings.emptyMessage}>
|
||||||
|
<Column field="id" header={__('ID domanda', 'gepafin')}
|
||||||
|
sortable
|
||||||
|
filterField="id" filter
|
||||||
|
filterMatchModeOptions={translationStrings.numberFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca', 'gepafin')}
|
||||||
|
style={{ minWidth: '6rem' }}/>
|
||||||
|
<Column field="callTitle" header={__('Bando', 'gepafin')}
|
||||||
|
filterField="callTitle" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '10rem' }}/>
|
||||||
|
<Column field="companyName" header={__('Azienda Beneficiaria', 'gepafin')}
|
||||||
|
filterField="companyName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column field="status" header={__('Stato', 'gepafin')}
|
||||||
|
filterElement={statusFilterTemplate} filter
|
||||||
|
filterMatchModeOptions={translationStrings.statusFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={statusBodyTemplate}/>
|
||||||
|
<Column header={__('Azioni', 'gepafin')}
|
||||||
|
body={actionsBodyTemplate}/>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
visible={isStatusDialogVisible}
|
||||||
|
modal
|
||||||
|
header={__('Cambia stato domanda', 'gepafin')}
|
||||||
|
footer={statusDialogFooter}
|
||||||
|
style={{ maxWidth: '500px', width: '100%' }}
|
||||||
|
onHide={hideStatusDialog}>
|
||||||
|
<div className="appForm__field">
|
||||||
|
<p>{__('Seleziona il nuovo stato', 'gepafin')}</p>
|
||||||
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem', marginTop: '0.5rem' }}>
|
||||||
|
{availableStatuses.map((status) => (
|
||||||
|
<Tag
|
||||||
|
key={status}
|
||||||
|
value={getBandoLabel(status)}
|
||||||
|
severity={getBandoSeverity(status)}
|
||||||
|
onClick={() => setSelectedStatus(status)}
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
outline: selectedStatus === status ? '2px solid var(--primary-color)' : 'none',
|
||||||
|
outlineOffset: '2px'
|
||||||
|
}}/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default ManageApplStatusSection;
|
export default ManageApplStatusSection;
|
||||||
|
|||||||
@@ -1,10 +1,230 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
|
||||||
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import ApplicationService from '../../../../service/application-service';
|
||||||
|
import AdminService from '../../../../service/admin-service';
|
||||||
|
|
||||||
|
// helpers
|
||||||
|
import getQueryParamsForPaginatedEndpoint from '../../../../helpers/getQueryParamsForPaginatedEndpoint';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { InputText } from 'primereact/inputtext';
|
||||||
|
import { Toast } from 'primereact/toast';
|
||||||
|
|
||||||
|
const statuses = [
|
||||||
|
'SUBMIT', 'EVALUATION', 'SOCCORSO', 'APPOINTMENT', 'NDG', 'ADMISSIBLE',
|
||||||
|
'AWAITING_TECHNICAL_EVALUATION', 'TECHNICAL_EVALUATION'
|
||||||
|
];
|
||||||
|
|
||||||
const ManageNdgSection = () => {
|
const ManageNdgSection = () => {
|
||||||
return <div className="appPageSection">
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
<h2>{__('Gestione NDG', 'gepafin')}</h2>
|
const [items, setItems] = useState(null);
|
||||||
</div>
|
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||||
}
|
const [isNdgDialogVisible, setIsNdgDialogVisible] = useState(false);
|
||||||
|
const [selectedAppId, setSelectedAppId] = useState(null);
|
||||||
|
const [ndgValue, setNdgValue] = useState('');
|
||||||
|
const [lazyState, setLazyState] = useState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
id: { value: null, matchMode: 'equals' },
|
||||||
|
callTitle: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const toast = useRef(null);
|
||||||
|
|
||||||
|
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||||
|
|
||||||
|
const onPage = (event) => {
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSort = (event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFilter = useCallback((event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
const getCallback = (resp) => {
|
||||||
|
if (resp.status === 'SUCCESS') {
|
||||||
|
const { body, totalRecords } = resp.data;
|
||||||
|
setTotalRecordsNum(totalRecords);
|
||||||
|
setItems(body);
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const errGetCallback = () => {
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openNdgDialog = (appId) => {
|
||||||
|
setSelectedAppId(appId);
|
||||||
|
setNdgValue('');
|
||||||
|
setIsNdgDialogVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const hideNdgDialog = () => {
|
||||||
|
setIsNdgDialogVisible(false);
|
||||||
|
setSelectedAppId(null);
|
||||||
|
setNdgValue('');
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetNdg = useCallback(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const body = { application_id: selectedAppId, ndg: ndgValue };
|
||||||
|
|
||||||
|
AdminService.setApplNdg(body, callback, errCallback);
|
||||||
|
}, [ndgValue, selectedAppId]);
|
||||||
|
|
||||||
|
const callback = (resp) => {
|
||||||
|
setItems(prev => prev.map(o => {
|
||||||
|
return o.id === resp.application_id
|
||||||
|
? {
|
||||||
|
...o,
|
||||||
|
ndg: resp.ndg
|
||||||
|
}
|
||||||
|
: o;
|
||||||
|
}));
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
hideNdgDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
const errCallback = (resp) => {
|
||||||
|
if (toast.current) {
|
||||||
|
toast.current.show({
|
||||||
|
severity: 'error',
|
||||||
|
summary: '',
|
||||||
|
detail: resp.detail
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
hideNdgDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionsBodyTemplate = (rowData) => {
|
||||||
|
return (
|
||||||
|
<div className="appPageSection__tableActions lessGap">
|
||||||
|
<Button
|
||||||
|
severity="info"
|
||||||
|
onClick={() => openNdgDialog(rowData.id)}
|
||||||
|
label={__('Set NDG', 'gepafin')}
|
||||||
|
icon="pi pi-pencil"
|
||||||
|
size="small"
|
||||||
|
iconPos="right"/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearFilter = () => {
|
||||||
|
setLazyState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
id: { value: null, matchMode: 'equals' },
|
||||||
|
callTitle: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderHeader = () => (
|
||||||
|
<div className="flex justify-content-between">
|
||||||
|
<Button type="button" icon="pi pi-filter-slash" label={__('Pulisci', 'gepafin')} outlined
|
||||||
|
onClick={clearFilter}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const ndgDialogFooter = (
|
||||||
|
<div>
|
||||||
|
<Button label={__('Annulla', 'gepafin')} icon="pi pi-times" outlined onClick={hideNdgDialog}/>
|
||||||
|
<Button label={__('Salva', 'gepafin')} icon="pi pi-check" onClick={handleSetNdg}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const header = renderHeader();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const paginationQuery = getPaginationQuery();
|
||||||
|
ApplicationService.getApplicationsPaginated(paginationQuery, getCallback, errGetCallback);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="appPageSection">
|
||||||
|
<h2>{__('Gestione NDG', 'gepafin')}</h2>
|
||||||
|
<Toast ref={toast}/>
|
||||||
|
<div className="appPageSection__table">
|
||||||
|
<DataTable
|
||||||
|
value={items} stripedRows showGridlines
|
||||||
|
lazy filterDisplay="menu" dataKey="id" paginator
|
||||||
|
first={lazyState.first} rows={lazyState.rows} totalRecords={totalRecordsNum} onPage={onPage}
|
||||||
|
onSort={onSort} sortField={lazyState.sortField} sortOrder={lazyState.sortOrder}
|
||||||
|
onFilter={onFilter} filters={lazyState.filters} loading={localAsyncRequest}
|
||||||
|
header={header}
|
||||||
|
emptyMessage={translationStrings.emptyMessage}>
|
||||||
|
<Column field="id" header={__('ID domanda', 'gepafin')}
|
||||||
|
sortable
|
||||||
|
filterField="id" filter
|
||||||
|
filterMatchModeOptions={translationStrings.numberFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca', 'gepafin')}
|
||||||
|
style={{ minWidth: '6rem' }}/>
|
||||||
|
<Column field="callTitle" header={__('Bando', 'gepafin')}
|
||||||
|
filterField="callTitle" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '10rem' }}/>
|
||||||
|
<Column field="companyName" header={__('Azienda Beneficiaria', 'gepafin')}
|
||||||
|
filterField="companyName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
filterPlaceholder={__('Cerca il nome', 'gepafin')}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column field="ndg" header={__('NDG', 'gepafin')}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column header={__('Azioni', 'gepafin')}
|
||||||
|
body={actionsBodyTemplate}/>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
visible={isNdgDialogVisible}
|
||||||
|
modal
|
||||||
|
header={__('Imposta NDG', 'gepafin')}
|
||||||
|
footer={ndgDialogFooter}
|
||||||
|
style={{ maxWidth: '500px', width: '100%' }}
|
||||||
|
onHide={hideNdgDialog}>
|
||||||
|
<div className="appForm__field">
|
||||||
|
<label htmlFor="ndgInput">{__('NDG', 'gepafin')}</label>
|
||||||
|
<InputText
|
||||||
|
id="ndgInput"
|
||||||
|
value={ndgValue}
|
||||||
|
onChange={(e) => setNdgValue(e.target.value)}
|
||||||
|
placeholder={__('Inserisci NDG', 'gepafin')}
|
||||||
|
style={{ width: '100%' }}/>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default ManageNdgSection;
|
export default ManageNdgSection;
|
||||||
|
|||||||
22
src/service/admin-service.js
Normal file
22
src/service/admin-service.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { NetworkService } from './network-service';
|
||||||
|
|
||||||
|
const API_ADMIN_BASE_URL = process.env.REACT_APP_API_ADMIN_BASE_URL;
|
||||||
|
|
||||||
|
export default class AdminService {
|
||||||
|
|
||||||
|
static setApplNdg = (body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.post(`${API_ADMIN_BASE_URL}/set-ndg`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
static setApplStatus = (body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.post(`${API_ADMIN_BASE_URL}/set-status`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
static doAmendmentReopen = (body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.post(`${API_ADMIN_BASE_URL}/reopen`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
|
||||||
|
static doAmendmentExtend = (body, callback, errCallback, queryParams) => {
|
||||||
|
NetworkService.post(`${API_ADMIN_BASE_URL}/extend-days`, body, callback, errCallback, queryParams);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user