diff --git a/src/helpers/getBandoLabel.js b/src/helpers/getBandoLabel.js
index bc4d043..c51643f 100644
--- a/src/helpers/getBandoLabel.js
+++ b/src/helpers/getBandoLabel.js
@@ -74,6 +74,9 @@ const getBandoLabel = (status) => {
case 'REJECTED':
return __('Respinto', 'gepafin');
+ case 'DELETED':
+ return __('Cancellato', 'gepafin');
+
case 'TECHNICAL_EVALUATION_REJECTED':
return __('Respinto Tec-Fin', 'gepafin');
diff --git a/src/helpers/getBandoSeverity.js b/src/helpers/getBandoSeverity.js
index 38a2d97..9020d62 100644
--- a/src/helpers/getBandoSeverity.js
+++ b/src/helpers/getBandoSeverity.js
@@ -72,6 +72,9 @@ const getBandoSeverity = (status) => {
case 'REJECTED':
return 'danger';
+ case 'DELETED':
+ return 'danger';
+
case 'TECHNICAL_EVALUATION_REJECTED':
return 'danger';
diff --git a/src/pages/Admin/components/ManageApplDeleteSection/index.js b/src/pages/Admin/components/ManageApplDeleteSection/index.js
index ba0933e..24a62e8 100644
--- a/src/pages/Admin/components/ManageApplDeleteSection/index.js
+++ b/src/pages/Admin/components/ManageApplDeleteSection/index.js
@@ -1,10 +1,370 @@
-import React from 'react';
+import React, { useEffect, useState, useCallback, useRef } from 'react';
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 initialDeletedLazyState = {
+ first: 0,
+ rows: 10,
+ page: 0
+};
+
+const initialPreDeleteLazyState = {
+ 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 ManageApplDeleteSection = ({ canViewDeleted, canDeleteConfirm, canDelete }) => {
- return
-
{__('Gestione domande eliminate', 'gepafin')}
-
-}
+ const toast = useRef(null);
+
+ // --- Table 1: Deleted applications ---
+ const [deletedLoading, setDeletedLoading] = useState(false);
+ const [deletedItems, setDeletedItems] = useState(null);
+ const [deletedTotal, setDeletedTotal] = useState(0);
+ const [deletedLazyState, setDeletedLazyState] = useState(initialDeletedLazyState);
+ const [deletedRefreshKey, setDeletedRefreshKey] = useState(0);
+ const [finalDeleteDialogVisible, setFinalDeleteDialogVisible] = useState(false);
+ const [finalDeleteAppId, setFinalDeleteAppId] = useState(null);
+ const [finalDeleteLoading, setFinalDeleteLoading] = useState(false);
+
+ // --- Table 2: Pre-delete applications ---
+ const [preDeleteLoading, setPreDeleteLoading] = useState(false);
+ const [preDeleteItems, setPreDeleteItems] = useState(null);
+ const [preDeleteTotal, setPreDeleteTotal] = useState(0);
+ const [preDeleteLazyState, setPreDeleteLazyState] = useState(initialPreDeleteLazyState);
+ const [preDeleteRefreshKey, setPreDeleteRefreshKey] = useState(0);
+ const [preDeleteDialogVisible, setPreDeleteDialogVisible] = useState(false);
+ const [preDeleteAppId, setPreDeleteAppId] = useState(null);
+ const [preDeleteActionLoading, setPreDeleteActionLoading] = useState(false);
+
+ // ---- Table 1 handlers ----
+
+ const getDeletedCallback = (resp) => {
+ if (resp.status === 'success') {
+ const { body, totalRecords } = resp.data;
+ setDeletedTotal(totalRecords);
+ setDeletedItems(body);
+ }
+ setDeletedLoading(false);
+ };
+
+ const errDeletedCallback = () => {
+ setDeletedLoading(false);
+ };
+
+ const openFinalDeleteDialog = (appId) => {
+ setFinalDeleteAppId(appId);
+ setFinalDeleteDialogVisible(true);
+ };
+
+ const hideFinalDeleteDialog = () => {
+ setFinalDeleteDialogVisible(false);
+ setFinalDeleteAppId(null);
+ };
+
+ const handleFinalDelete = useCallback(() => {
+ setFinalDeleteLoading(true);
+ AdminService.doFinalDelete(
+ { application_id: finalDeleteAppId },
+ () => {
+ setDeletedRefreshKey(k => k + 1);
+ setFinalDeleteLoading(false);
+ hideFinalDeleteDialog();
+ },
+ (resp) => {
+ if (toast.current) {
+ toast.current.show({ severity: 'error', summary: '', detail: resp.detail });
+ }
+ setFinalDeleteLoading(false);
+ hideFinalDeleteDialog();
+ }
+ );
+ }, [finalDeleteAppId]);
+
+ const deletedActionsBodyTemplate = (rowData) => (
+
+
+ );
+
+ const finalDeleteDialogFooter = (
+
+
+ );
+
+ useEffect(() => {
+ if (!canViewDeleted) return;
+ setDeletedLoading(true);
+ AdminService.getDeletedAppl(getDeletedCallback, errDeletedCallback, {
+ page: deletedLazyState.page + 1,
+ page_size: deletedLazyState.rows
+ });
+ }, [deletedLazyState, deletedRefreshKey, canViewDeleted]);
+
+ // ---- Table 2 handlers ----
+
+ const getPreDeletePaginationQuery = useCallback(
+ () => getQueryParamsForPaginatedEndpoint(preDeleteLazyState, allStatuses, 'id'),
+ [preDeleteLazyState]
+ );
+
+ const getPreDeleteCallback = (resp) => {
+ if (resp.status === 'SUCCESS') {
+ const { body, totalRecords } = resp.data;
+ setPreDeleteTotal(totalRecords);
+ setPreDeleteItems(body);
+ }
+ setPreDeleteLoading(false);
+ };
+
+ const errPreDeleteCallback = () => {
+ setPreDeleteLoading(false);
+ };
+
+ const openPreDeleteDialog = (appId) => {
+ setPreDeleteAppId(appId);
+ setPreDeleteDialogVisible(true);
+ };
+
+ const hidePreDeleteDialog = () => {
+ setPreDeleteDialogVisible(false);
+ setPreDeleteAppId(null);
+ };
+
+ const handlePreDelete = useCallback(() => {
+ setPreDeleteActionLoading(true);
+ AdminService.doPreDelete(
+ { application_id: preDeleteAppId },
+ () => {
+ setPreDeleteRefreshKey(k => k + 1);
+ setDeletedRefreshKey(k => k + 1);
+ setPreDeleteActionLoading(false);
+ hidePreDeleteDialog();
+ },
+ (resp) => {
+ if (toast.current) {
+ toast.current.show({ severity: 'error', summary: '', detail: resp.detail });
+ }
+ setPreDeleteActionLoading(false);
+ hidePreDeleteDialog();
+ }
+ );
+ }, [preDeleteAppId]);
+
+ const preDeleteActionsBodyTemplate = (rowData) => (
+
+ openPreDeleteDialog(rowData.id)}
+ label={__('Cancella', 'gepafin')}
+ icon="pi pi-trash"
+ size="small"
+ iconPos="right"/>
+
+ );
+
+ const statusBodyTemplate = (rowData) => ;
+
+ const statusItemTemplate = (option) => (
+
+ );
+
+ const statusFilterTemplate = (options) => (
+ {
+ options.filterCallback(e.value, options.index);
+ const filters = { ...preDeleteLazyState.filters };
+ if (e.value) {
+ filters['status'] = { value: e.value, matchMode: 'equals' };
+ } else {
+ delete filters['status'];
+ }
+ setPreDeleteLazyState({ ...preDeleteLazyState, filters, first: 0 });
+ }}
+ itemTemplate={statusItemTemplate}
+ placeholder={translationStrings.selectOneLabel}
+ className="p-column-filter"/>
+ );
+
+ const preDeleteDialogFooter = (
+
+
+
+
+ );
+
+ useEffect(() => {
+ if (!canDelete) return;
+ setPreDeleteLoading(true);
+ const paginationQuery = getPreDeletePaginationQuery();
+ ApplicationService.getApplicationsPaginated(paginationQuery, getPreDeleteCallback, errPreDeleteCallback);
+ }, [preDeleteLazyState, preDeleteRefreshKey, canDelete]);
+
+ return (
+
+
{__('Gestione domande eliminate', 'gepafin')}
+
+
+ {canViewDeleted && (
+ <>
+ {__('Domande eliminate', 'gepafin')}
+
+
setDeletedLazyState(e)}
+ loading={deletedLoading}
+ header={
+
+ setDeletedLazyState({ ...deletedLazyState })}/>
+
+ }
+ emptyMessage={translationStrings.emptyMessage}>
+ rowData.id}
+ style={{ minWidth: '6rem' }}/>
+
+
+
+ {canDeleteConfirm && (
+
+ )}
+
+
+
+
+ >
+ )}
+
+ {canDelete && (
+ <>
+
+ {__('Cancella domanda', 'gepafin')}
+
+
setPreDeleteLazyState(e)}
+ onSort={(e) => { e['first'] = 0; e['page'] = 0; setPreDeleteLazyState(e); }}
+ sortField={preDeleteLazyState.sortField}
+ sortOrder={preDeleteLazyState.sortOrder}
+ onFilter={(e) => { e['first'] = 0; e['page'] = 0; setPreDeleteLazyState(e); }}
+ filters={preDeleteLazyState.filters}
+ loading={preDeleteLoading}
+ header={
+
+ setPreDeleteLazyState(initialPreDeleteLazyState)}/>
+
+ }
+ emptyMessage={translationStrings.emptyMessage}>
+
+
+
+
+
+
+
+
+
+ >
+ )}
+
+ );
+};
export default ManageApplDeleteSection;
diff --git a/src/pages/Admin/components/ManageApplStatusSection/index.js b/src/pages/Admin/components/ManageApplStatusSection/index.js
index e8e201e..e4ea1fe 100644
--- a/src/pages/Admin/components/ManageApplStatusSection/index.js
+++ b/src/pages/Admin/components/ManageApplStatusSection/index.js
@@ -117,7 +117,7 @@ const ManageApplStatusSection = () => {
hideStatusDialog();
}
- const errCallback = () => {
+ const errCallback = (resp) => {
if (toast.current) {
toast.current.show({
severity: 'error',
diff --git a/src/pages/DomandaEditInstructorManager/index.js b/src/pages/DomandaEditInstructorManager/index.js
index 7e742fa..3cd2e85 100644
--- a/src/pages/DomandaEditInstructorManager/index.js
+++ b/src/pages/DomandaEditInstructorManager/index.js
@@ -822,7 +822,7 @@ const DomandaEditInstructorManager = () => {
storeSet('unsetAsyncRequest');
}
- const doCreateAppointment = () => {
+ /*const doCreateAppointment = () => {
setAppointmentData({
title: '',
text: '',
@@ -830,7 +830,7 @@ const DomandaEditInstructorManager = () => {
amount: 0
});
setIsVisibleAppointmentDialog(true);
- }
+ }*/
const setAppointmentFieldValue = (name, value) => {
const newData = wrap(appointmentData).set(name, value).value();
diff --git a/src/pages/DomandaEditPreInstructor/index.js b/src/pages/DomandaEditPreInstructor/index.js
index 7b44651..fcad5c2 100644
--- a/src/pages/DomandaEditPreInstructor/index.js
+++ b/src/pages/DomandaEditPreInstructor/index.js
@@ -822,7 +822,7 @@ const DomandaEditPreInstructor = () => {
storeSet('unsetAsyncRequest');
}
- const doCreateAppointment = () => {
+ /*const doCreateAppointment = () => {
setAppointmentData({
title: '',
text: '',
@@ -830,7 +830,7 @@ const DomandaEditPreInstructor = () => {
amount: 0
});
setIsVisibleAppointmentDialog(true);
- }
+ }*/
const setAppointmentFieldValue = (name, value) => {
const newData = wrap(appointmentData).set(name, value).value();
diff --git a/src/service/admin-service.js b/src/service/admin-service.js
index a553e71..01dc2c1 100644
--- a/src/service/admin-service.js
+++ b/src/service/admin-service.js
@@ -21,10 +21,22 @@ export default class AdminService {
};
static doSendPec = (body, callback, errCallback, queryParams) => {
- NetworkService.post(`${API_ADMIN_BASE_URL}/send-pec`, body, callback, errCallback, queryParams);
+ NetworkService.postMultiPart(`${API_ADMIN_BASE_URL}/send-pec`, body, callback, errCallback, queryParams);
};
static getAdminLog = (callback, errCallback, queryParams) => {
NetworkService.get(`${API_ADMIN_BASE_URL}/admin-operations`, callback, errCallback, queryParams);
};
+
+ static getDeletedAppl = (callback, errCallback, queryParams) => {
+ NetworkService.get(`${API_ADMIN_BASE_URL}/status-deleted`, callback, errCallback, queryParams);
+ };
+
+ static doPreDelete = (body, callback, errCallback, queryParams) => {
+ NetworkService.delete(`${API_ADMIN_BASE_URL}/pre-delete`, body, callback, errCallback, queryParams);
+ };
+
+ static doFinalDelete = (body, callback, errCallback, queryParams) => {
+ NetworkService.delete(`${API_ADMIN_BASE_URL}/def-delete`, body, callback, errCallback, queryParams);
+ };
}