- re added tables with pagination;

This commit is contained in:
Vitalii Kiiko
2025-03-31 16:14:27 +02:00
parent 16602129f9
commit 713af3ac32
34 changed files with 1225 additions and 420 deletions

View File

@@ -1,6 +1,6 @@
import React, { useEffect, useState, useCallback } from 'react';
import { __ } from '@wordpress/i18n';
import { is, isEmpty, pathOr } from 'ramda';
import { is } from 'ramda';
import { Link, useLocation } from 'react-router-dom';
import translationStrings from '../../../../translationStringsForComponents';
@@ -12,6 +12,7 @@ import ApplicationService from '../../../../service/application-service';
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';
@@ -34,43 +35,17 @@ const AllDomandeTableAsync = ({ openDialogFn, updaterString = '' }) => {
sortField: null,
sortOrder: null,
filters: {
id: { value: null, matchMode: 'contains' },
id: { value: null, matchMode: 'equals' },
callTitle: { value: null, matchMode: 'contains' },
companyName: { value: null, matchMode: 'contains' },
submissionDate: { value: null, matchMode: 'date_is' },
assignedUserName: { value: null, matchMode: 'equals' },
status: { value: null, matchMode: 'equals' }
}
});
const statuses = ['SUBMIT', 'EVALUATION', 'SOCCORSO'];
const statuses = ['SUBMIT', 'EVALUATION', 'SOCCORSO', 'APPOINTMENT', 'NDG', 'ADMISSIBLE', 'TECHNICAL_EVALUATION'];
const getPaginationQuery = useCallback(() => {
let sortBy = {
columnName: "ID",
sortDesc: true
};
if (lazyState.sortField) {
sortBy = {
columnName: lazyState.sortField,
sortDesc: lazyState.sortOrder === -1
}
}
return {
globalFilters: {
page: lazyState.page ? lazyState.page + 1 : 1,
limit: lazyState.rows,
sortBy
},
status: statuses,
filters: Object.keys(lazyState.filters).reduce((acc, cur) => {
const value = pathOr('', ['filters', cur, 'value'], lazyState);
if (!isEmpty(value)) {
acc[cur] = lazyState.filters[cur];
}
return acc;
}, {}),
}
}, [lazyState]);
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
const onPage = (event) => {
setLazyState(event);
@@ -182,7 +157,7 @@ const AllDomandeTableAsync = ({ openDialogFn, updaterString = '' }) => {
<Column field="id" header={__('ID domanda', 'gepafin')}
sortable
filterField="id" filter
filterMatchModeOptions={translationStrings.textFilterOptions}
filterMatchModeOptions={translationStrings.numberFilterOptions}
filterPlaceholder={__('Cerca', 'gepafin')}
style={{ minWidth: '6rem' }}/>
<Column field="protocolNumber" header={__('Protocollo', 'gepafin')}
@@ -204,6 +179,8 @@ const AllDomandeTableAsync = ({ openDialogFn, updaterString = '' }) => {
style={{ minWidth: '8rem' }}
body={dateAppliedBodyTemplate}/>
<Column field="assignedUserName" header={__('Assegnato', 'gepafin')}
filterField="assignedUserName" filter
filterMatchModeOptions={translationStrings.textFilterOptions}
style={{ minWidth: '8rem' }}/>
<Column field="status" header={__('Stato', 'gepafin')}
filterElement={statusFilterTemplate} filter