diff --git a/src/configData.js b/src/configData.js index dbed67c..6e5efda 100644 --- a/src/configData.js +++ b/src/configData.js @@ -207,6 +207,21 @@ export const classificationType = [ 'name': 'ALTRO', 'idTipoprotocollo': 1 }, + { + 'idClassificazione': 135, + 'name': 'DOMANDA PDF FIRMATO', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 136, + 'name': 'DELEGA-PROCURA BANDI', + 'idTipoprotocollo': 1 + }, + { + 'idClassificazione': 137, + 'name': 'DIGITAL ASSESMENT', + 'idTipoprotocollo': 1 + }, { 'idClassificazione': 202, 'name': 'LETTERA DI GARANZIA', diff --git a/src/pages/DashboardInstructorManager/components/MieDomandeTableInstructorManagerAsync/index.js b/src/pages/DashboardInstructorManager/components/MieDomandeTableInstructorManagerAsync/index.js new file mode 100644 index 0000000..2a9cb73 --- /dev/null +++ b/src/pages/DashboardInstructorManager/components/MieDomandeTableInstructorManagerAsync/index.js @@ -0,0 +1,276 @@ +import React, { useEffect, useState, useCallback } from 'react'; +import { __ } from '@wordpress/i18n'; +import { head, is, isEmpty, pathOr } from 'ramda'; +import { klona } from 'klona'; + +import translationStrings from '../../../../translationStringsForComponents'; + +// api +import AssignedApplicationService from '../../../../service/assigned-application-service'; + +// store +import { useStore } from '../../../../store'; + +// tools +import getFormattedDateString from '../../../../helpers/getFormattedDateString'; +import getBandoLabel from '../../../../helpers/getBandoLabel'; +import getBandoSeverity from '../../../../helpers/getBandoSeverity'; + +// components +import { DataTable } from 'primereact/datatable'; +import { Column } from 'primereact/column'; +import ProperBandoLabel from '../../../../components/ProperBandoLabel'; +import { Dropdown } from 'primereact/dropdown'; +import { Tag } from 'primereact/tag'; +import { Calendar } from 'primereact/calendar'; +import { Button } from 'primereact/button'; +import { Link, useNavigate } from 'react-router-dom'; + + +const APP_HUB_ID = process.env.REACT_APP_HUB_ID; + +const MieDomandeTableInstructorManagerAsync = ({ userId = null, statuses = [] }) => { + const navigate = useNavigate(); + const userData = useStore().main.userData(); + 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: 'contains' }, + protocolNumber: { value: null, matchMode: 'contains' }, + callName: { value: null, matchMode: 'contains' }, + companyName: { value: null, matchMode: 'contains' }, + submissionDate: { value: null, matchMode: 'date_is' }, + evaluationEndDate: { value: null, matchMode: 'date_is' }, + status: { value: null, matchMode: 'equals' } + } + }); + + 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 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, + //currentPage, totalPages, pageSize + } = resp.data; + setTotalRecordsNum(totalRecords); + setItems(getFormattedData(body)); + } + setLocalAsyncRequest(false); + } + + const errGetCallbacks = () => { + setLocalAsyncRequest(false); + } + + const getFormattedData = (data) => { + return data.map((d) => { + d.evaluationEndDate = is(String, d.evaluationEndDate) ? new Date(d.evaluationEndDate) : (d.evaluationEndDate ? d.evaluationEndDate : ''); + d.submissionDate = is(String, d.submissionDate) ? new Date(d.submissionDate) : (d.submissionDate ? d.submissionDate : ''); + return d; + }); + }; + + 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" + showClear/>; + }; + + const dateFilterTemplate = (options) => { + return options.filterCallback(e.value, options.index)} + dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999"/>; + }; + + const dateAppliedBodyTemplate = (rowData) => { + return getFormattedDateString(rowData.submissionDate); + }; + + const dateEndBodyTemplate = (rowData) => { + return getFormattedDateString(rowData.evaluationEndDate); + }; + + const actionsBodyTemplate = (rowData) => { + if (rowData.status === 'AWAITING') { + return