From 5d740c1069f15b735fe461f39835fbb8c291439b Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 15 Jan 2025 11:50:35 +0100 Subject: [PATCH] - added pagination for notifications (non beneficiary); --- .../NotificationItemChosen/index.js | 5 +- src/components/NotificationsSidebar/index.js | 177 +++++++++++++----- src/components/PaginatorBasic/index.js | 59 ++++++ .../components/AppSidebar/index.js | 22 +-- .../Bandi/components/AllBandiTable/index.js | 2 +- .../components/AllBandiAccordion/index.js | 2 +- .../AllBandiPreferredAccordion/index.js | 2 +- .../DraftApplicationsTable/index.js | 2 +- .../components/LatestBandiTable/index.js | 33 +++- .../LatestUsersActivityTable/index.js | 2 +- .../components/LatestBandiTable/index.js | 2 +- .../MyLatestSubmissionsTable/index.js | 2 +- .../PreInstructorDomandeTable/index.js | 2 +- .../components/AllDomandeTable/index.js | 2 +- .../AllDomandeArchiveTable/index.js | 5 +- .../BeneficiarioDomandeTable/index.js | 2 +- .../PreInstructorSoccorsiTable/index.js | 2 +- .../Users/components/AllUsersTable/index.js | 2 +- src/service/bando-service.js | 4 + src/service/notification-service.js | 8 + 20 files changed, 259 insertions(+), 78 deletions(-) create mode 100644 src/components/PaginatorBasic/index.js diff --git a/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js b/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js index 4588de6..24ecc1e 100644 --- a/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js +++ b/src/components/NotificationsSidebar/components/NotificationItemChosen/index.js @@ -17,12 +17,13 @@ const NotificationItemChosen = ({ item, closeFn, markReadFn }) => { {getDateFromISOstring(item.createdDate)} {item.message} - + + ({currentPage} {__('di', 'gepafin')} {totalPages}) + + + : null + ) +} + +export default PaginatorBasic; \ No newline at end of file diff --git a/src/layouts/DefaultLayout/components/AppSidebar/index.js b/src/layouts/DefaultLayout/components/AppSidebar/index.js index 5c81b8f..30bc83e 100644 --- a/src/layouts/DefaultLayout/components/AppSidebar/index.js +++ b/src/layouts/DefaultLayout/components/AppSidebar/index.js @@ -45,77 +45,77 @@ const AppSidebar = () => { label: __('Bandi osservati', 'gepafin'), icon: 'pi pi-star', href: '/bandi-osservati', - id: 13, + id: 5, enable: intersection(permissions, ['VIEW_CALLS']).length }, { label: __('Gestione domande', 'gepafin'), icon: 'pi pi-file', href: '/domande', - id: 5, + id: 6, enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length }, { label: __('Domande da valutare', 'gepafin'), icon: 'pi pi-calendar-clock', href: '/domande', - id: 6, + id: 7, enable: intersection(permissions, ['EVALUATE_APPLICATIONS']).length }, { label: __('Archivio domande', 'gepafin'), icon: 'pi pi-briefcase', href: '/domande', - id: 7, + id: 8, enable: intersection(permissions, ['APPLY_CALLS']).length }, { label: __('Archivio domande', 'gepafin'), icon: 'pi pi-briefcase', href: '/domande-archivio', - id: 5, + id: 9, enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length }, { label: __('Archivio domande', 'gepafin'), icon: 'pi pi-briefcase', href: '/domande-archivio', - id: 6, + id: 10, enable: intersection(permissions, ['EVALUATE_APPLICATIONS']).length }, { label: __('Soccorso istruttorio', 'gepafin'), icon: , href: '/soccorso-istruttorio', - id: 8, + id: 11, enable: intersection(permissions, ['EVALUATE_APPLICATIONS']).length }, { label: __('Gestione utenti', 'gepafin'), icon: 'pi pi-users', href: '/utenti', - id: 9, + id: 12, enable: intersection(permissions, ['VIEW_USERS', 'MANAGE_USERS']).length }, { label: __('Configurazione', 'gepafin'), icon: 'pi pi-cog', //href: '/configurazione', - id: 10, + id: 13, enable: false }, { label: __('Report e Analisi', 'gepafin'), icon: 'pi pi-chart-bar', //href: '/stats', - id: 11, + id: 14, enable: false }, { label: __('Log di Sistema', 'gepafin'), icon: 'pi pi-receipt', clickFn: () => {}, - id: 12, + id: 15, enable: false } ] diff --git a/src/pages/Bandi/components/AllBandiTable/index.js b/src/pages/Bandi/components/AllBandiTable/index.js index 9bbc70f..14e457b 100644 --- a/src/pages/Bandi/components/AllBandiTable/index.js +++ b/src/pages/Bandi/components/AllBandiTable/index.js @@ -121,7 +121,7 @@ const AllBandiTable = () => { return(
- {
{
{ return (
- { const [filters, setFilters] = useState(null); const [localAsyncRequest, setLocalAsyncRequest] = useState(false); const [, setStatuses] = useState([]); + /*const [totalRecordsNum, setTotalRecordsNum] = useState(0); + const [perPageNum, setPerPageNum] = useState(0); + const getPaginationQuery = () => { + return { + "globalFilters": { + "page": 1, + "limit": 5, + "sortBy": { + "columnName": "ID", + "sortDesc": true + } + } + } + } + + const onPageChange = (e) => { + console.log('onPageChange', e) + }*/ useEffect(() => { setLocalAsyncRequest(true); BandoService.getBandi(getCallback, errGetCallbacks); + //const paginationQuery = getPaginationQuery(); + //BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks); }, []); const getCallback = (data) => { if (data.status === 'SUCCESS') { + /*const { body, totalRecords, currentPage, totalPages, pageSize } = data.data; + setTotalRecordsNum(totalRecords); + setPerPageNum(pageSize); + const newItems = body.filter(o => o.status === 'PUBLISH'); + setItems(getFormattedBandiData(newItems)); + setStatuses(uniq(body.map(o => o.status)));*/ const newItems = data.data.filter(o => o.status === 'PUBLISH'); setItems(getFormattedBandiData(newItems)); - setStatuses(uniq(data.data.map(o => o.status))) + setStatuses(uniq(data.data.map(o => o.status))); initFilters(); } setLocalAsyncRequest(false); @@ -106,7 +132,10 @@ const LatestBandiTable = () => { return(
- { return(
- { return (
- { return (
- { return(
- { return (
- { const [filters, setFilters] = useState(null); const [localAsyncRequest, setLocalAsyncRequest] = useState(false); const [statuses, setStatuses] = useState([]); - const location = useLocation(); useEffect(() => { setLocalAsyncRequest(true); @@ -141,7 +140,7 @@ const AllDomandeArchiveTable = ({ updaterString = '' }) => { return (
- { return (
- { return(
- { return (
- { + NetworkService.post(`${API_BASE_URL}/call/pagination`, body, callback, errCallback, queryParams); + }; + static getBando = (id, callback, errCallback, queryParams) => { NetworkService.get(`${API_BASE_URL}/call/${id}`, callback, errCallback, queryParams); }; diff --git a/src/service/notification-service.js b/src/service/notification-service.js index c3457b2..25b77f6 100644 --- a/src/service/notification-service.js +++ b/src/service/notification-service.js @@ -8,6 +8,14 @@ export default class NotificationService { NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams); }; + static getNotificationsByCompanyId = (id, companyId, callback, errCallback, queryParams) => { + NetworkService.get(`${API_BASE_URL}/notification/user/${id}/company/${companyId}/notifications`, callback, errCallback, queryParams); + }; + + static getNotificationsPagination = (id, body, callback, errCallback, queryParams) => { + NetworkService.post(`${API_BASE_URL}/notification/user/${id}/pagination`, body, callback, errCallback, queryParams); + }; + static notificationMakeRead = (id, callback, errCallback) => { NetworkService.put(`${API_BASE_URL}/notification/${id}`, {}, callback, errCallback, [ ['status', 'READ']