diff --git a/.env b/.env
index 16f67c8..80c96c4 100644
--- a/.env
+++ b/.env
@@ -1,5 +1,6 @@
REACT_APP_TAB_TITLE=Gepafin
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_WS=https://api-dev-gepafin.memento.credit/wss
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
diff --git a/environments/dev/dev.env b/environments/dev/dev.env
index ae149fd..50a6ba2 100644
--- a/environments/dev/dev.env
+++ b/environments/dev/dev.env
@@ -1,5 +1,6 @@
REACT_APP_TAB_TITLE=Gepafin
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_WS=https://api-dev-gepafin.memento.credit/wss
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
diff --git a/environments/prod/prod.env b/environments/prod/prod.env
index 8e5fc08..abf8eef 100644
--- a/environments/prod/prod.env
+++ b/environments/prod/prod.env
@@ -1,5 +1,6 @@
REACT_APP_TAB_TITLE=Gepafin
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_WS=https://bandi-api.gepafin.it/wss
REACT_APP_LOGO_FILENAME=gepafin-logo.svg
diff --git a/src/pages/Admin/components/ManageAmendmentExtendSection/index.js b/src/pages/Admin/components/ManageAmendmentExtendSection/index.js
index 898403f..f2a5370 100644
--- a/src/pages/Admin/components/ManageAmendmentExtendSection/index.js
+++ b/src/pages/Admin/components/ManageAmendmentExtendSection/index.js
@@ -1,10 +1,280 @@
-import React from 'react';
+import React, { useEffect, useState, useCallback, useRef } from 'react';
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 = () => {
- return
-
{__('Estensione soccorso istruttorio', 'gepafin')}
-
-}
+ const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
+ const [items, setItems] = useState(null);
+ 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) => (
+
+
+ );
+
+ const statusBodyTemplate = (rowData) => ;
+
+ const statusItemTemplate = (option) => ;
+
+ const statusFilterTemplate = (options) => (
+ {
+ 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) => (
+ 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 = (
+
+
+ );
+
+ const extendDialogFooter = (
+
+
+ );
+
+ useEffect(() => {
+ setLocalAsyncRequest(true);
+ const paginationQuery = getPaginationQuery();
+ AmendmentsService.getSoccorsiPaginated(1, paginationQuery, getCallback, errGetCallback);
+ }, [lazyState]);
+
+ return (
+
+
{__('Estensione soccorso istruttorio', 'gepafin')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
export default ManageAmendmentExtendSection;
diff --git a/src/pages/Admin/components/ManageAmendmentReopenSection/index.js b/src/pages/Admin/components/ManageAmendmentReopenSection/index.js
index 40b8ba4..c2e5e33 100644
--- a/src/pages/Admin/components/ManageAmendmentReopenSection/index.js
+++ b/src/pages/Admin/components/ManageAmendmentReopenSection/index.js
@@ -1,10 +1,236 @@
-import React from 'react';
+import React, { useEffect, useState, useCallback, useRef } from 'react';
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 = () => {
- return
-
{__('Riapertura soccorso istruttorio', 'gepafin')}
-
-}
+ const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
+ const [items, setItems] = useState(null);
+ 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) => (
+
+ handleReopen(rowData.id)}/>
+
+ );
+
+ const statusBodyTemplate = (rowData) => ;
+
+ const statusItemTemplate = (option) => ;
+
+ const statusFilterTemplate = (options) => (
+ {
+ 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) => (
+ 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 = (
+
+
+
+ );
+
+ useEffect(() => {
+ setLocalAsyncRequest(true);
+ const paginationQuery = getPaginationQuery();
+ AmendmentsService.getSoccorsiPaginated(1, paginationQuery, getCallback, errGetCallback);
+ }, [lazyState]);
+
+ return (
+
+
{__('Riapertura soccorso istruttorio', 'gepafin')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
export default ManageAmendmentReopenSection;
diff --git a/src/pages/Admin/components/ManageApplStatusSection/index.js b/src/pages/Admin/components/ManageApplStatusSection/index.js
index d18e189..e8e201e 100644
--- a/src/pages/Admin/components/ManageApplStatusSection/index.js
+++ b/src/pages/Admin/components/ManageApplStatusSection/index.js
@@ -1,10 +1,283 @@
-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 availableStatuses = [
+ 'EVALUATION', 'SOCCORSO', 'APPOINTMENT', 'NDG', 'ADMISSIBLE',
+ 'AWAITING_TECHNICAL_EVALUATION', 'TECHNICAL_EVALUATION'
+];
+
const ManageApplStatusSection = () => {
- return
-
{__('Gestione stato domande', 'gepafin')}
-
-}
+ const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
+ const [items, setItems] = useState(null);
+ 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 (
+
+ openStatusDialog(rowData.id)}
+ label={__('Cambia stato', 'gepafin')}
+ icon="pi pi-sync"
+ size="small"
+ iconPos="right"/>
+
+ );
+ };
+
+ const statusBodyTemplate = (rowData) => {
+ return ;
+ };
+
+ const statusItemTemplate = (option) => {
+ return ;
+ };
+
+ const statusFilterTemplate = (options) => {
+ return (
+ {
+ 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 = () => (
+
+
+
+ );
+
+ const statusDialogFooter = (
+
+
+
+
+ );
+
+ const header = renderHeader();
+
+ useEffect(() => {
+ setLocalAsyncRequest(true);
+ const paginationQuery = getPaginationQuery();
+ ApplicationService.getApplicationsPaginated(paginationQuery, getCallback, errGetCallback);
+ }, [lazyState]);
+
+ return (
+
+
{__('Gestione stato domande', 'gepafin')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
export default ManageApplStatusSection;
diff --git a/src/pages/Admin/components/ManageNdgSection/index.js b/src/pages/Admin/components/ManageNdgSection/index.js
index 0fa5a7c..8c895fe 100644
--- a/src/pages/Admin/components/ManageNdgSection/index.js
+++ b/src/pages/Admin/components/ManageNdgSection/index.js
@@ -1,10 +1,230 @@
-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';
+
+// 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 = () => {
- return
-
{__('Gestione NDG', 'gepafin')}
-
-}
+ const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
+ const [items, setItems] = useState(null);
+ 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 (
+
+ openNdgDialog(rowData.id)}
+ label={__('Set NDG', 'gepafin')}
+ icon="pi pi-pencil"
+ size="small"
+ iconPos="right"/>
+
+ );
+ };
+
+ 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 = () => (
+
+
+
+ );
+
+ const ndgDialogFooter = (
+
+
+
+
+ );
+
+ const header = renderHeader();
+
+ useEffect(() => {
+ setLocalAsyncRequest(true);
+ const paginationQuery = getPaginationQuery();
+ ApplicationService.getApplicationsPaginated(paginationQuery, getCallback, errGetCallback);
+ }, [lazyState]);
+
+ return (
+
+
{__('Gestione NDG', 'gepafin')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
export default ManageNdgSection;
diff --git a/src/service/admin-service.js b/src/service/admin-service.js
new file mode 100644
index 0000000..b10928b
--- /dev/null
+++ b/src/service/admin-service.js
@@ -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);
+ };
+}