- beneficiary notifications pagination added;

This commit is contained in:
Vitalii Kiiko
2025-02-26 11:08:11 +01:00
parent 6326735417
commit c672ff2623
3 changed files with 12 additions and 50 deletions

View File

@@ -88,35 +88,24 @@ const NotificationsSidebar = () => {
const bodyParams = getPaginationQuery(status, currentPage); const bodyParams = getPaginationQuery(status, currentPage);
if (currentSubscription) { if (currentSubscription) {
//console.log('UNsubscribed')
currentSubscription.unsubscribe(); currentSubscription.unsubscribe();
setCurrentSubscription(null); setCurrentSubscription(null);
} }
if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') { if (userData.id && chosenCompanyId !== 0 && role === 'ROLE_BENEFICIARY') {
setLoading(true); setLoading(true);
NotificationService.getNotificationsByCompanyId( NotificationService.getNotificationsByCompanyIdPagination(
userData.id, userData.id,
chosenCompanyId, chosenCompanyId,
status === 'UNREAD' ? getNotifications : getNotificationsRead, bodyParams,
errGetNotifications, status === 'UNREAD' ? getNotificationsPagi : getNotificationsReadPagi,
[ errGetNotifications
['status', status]
]
); );
if (isConnected && socket.current) { if (isConnected && socket.current) {
subscribeTo(`/topic/notifications_user_${userData.id}_company_${chosenCompanyId}`) subscribeTo(`/topic/notifications_user_${userData.id}_company_${chosenCompanyId}`)
} }
} else if (userData.id && role !== 'ROLE_BENEFICIARY') { } else if (userData.id && role !== 'ROLE_BENEFICIARY') {
setLoading(true); setLoading(true);
/*NotificationService.getNotifications(
userData.id,
status === 'UNREAD' ? getNotifications : getNotificationsRead,
errGetNotifications,
[
['status', status]
]
);*/
NotificationService.getNotificationsPagination( NotificationService.getNotificationsPagination(
userData.id, userData.id,
bodyParams, bodyParams,
@@ -157,24 +146,6 @@ const NotificationsSidebar = () => {
setLoading(false); setLoading(false);
} }
const getNotifications = (resp) => {
if (resp.status === 'SUCCESS') {
setNotifications(resp.data);
setTotalRecordsNum(resp.data.length);
}
set404FromErrorResponse(resp);
setLoading(false);
}
const getNotificationsRead = (resp) => {
if (resp.status === 'SUCCESS') {
setNotificationsRead(resp.data);
setTotalRecordsNum(resp.data.length);
}
set404FromErrorResponse(resp);
setLoading(false);
}
const errGetNotifications = (resp) => { const errGetNotifications = (resp) => {
set404FromErrorResponse(resp); set404FromErrorResponse(resp);
setLoading(false); setLoading(false);

View File

@@ -5,6 +5,10 @@ import { uniq } from 'ramda';
// api // api
import BandoService from '../../../../service/bando-service'; import BandoService from '../../../../service/bando-service';
// tools
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
import getTimeFromISOstring from '../../../../helpers/getTimeFromISOstring';
// components // components
import { FilterMatchMode, FilterOperator } from 'primereact/api'; import { FilterMatchMode, FilterOperator } from 'primereact/api';
import { DataTable } from 'primereact/datatable'; import { DataTable } from 'primereact/datatable';
@@ -12,10 +16,7 @@ import { Column } from 'primereact/column';
import { Button } from 'primereact/button'; import { Button } from 'primereact/button';
import { Calendar } from 'primereact/calendar'; import { Calendar } from 'primereact/calendar';
import ProperBandoLabel from '../../../../components/ProperBandoLabel'; import ProperBandoLabel from '../../../../components/ProperBandoLabel';
import { Link } from 'react-router-dom';
import translationStrings from '../../../../translationStringsForComponents'; import translationStrings from '../../../../translationStringsForComponents';
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
import getTimeFromISOstring from '../../../../helpers/getTimeFromISOstring';
const LatestBandiTable = () => { const LatestBandiTable = () => {
@@ -100,12 +101,6 @@ const LatestBandiTable = () => {
return <ProperBandoLabel status={rowData.status}/>; return <ProperBandoLabel status={rowData.status}/>;
}; };
const actionsBodyTemplate = (rowData) => {
return <Link to={`/bandi/${rowData.id}`}>
<Button severity="info" label={__('Modifica', 'gepafin')} icon="pi pi-pencil" size="small" iconPos="right" />
</Link>
}
const header = renderHeader(); const header = renderHeader();
return( return(

View File

@@ -4,12 +4,8 @@ const API_BASE_URL = process.env.REACT_APP_API_EXECUTION_ADDRESS;
export default class NotificationService { export default class NotificationService {
/*static getNotifications = (id, callback, errCallback, queryParams) => { static getNotificationsByCompanyIdPagination = (id, companyId, body, callback, errCallback, queryParams) => {
NetworkService.get(`${API_BASE_URL}/notification/user/${id}`, callback, errCallback, queryParams); NetworkService.post(`${API_BASE_URL}/notification/user/${id}/company/${companyId}/pagination`, body, 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) => { static getNotificationsPagination = (id, body, callback, errCallback, queryParams) => {
@@ -22,9 +18,9 @@ export default class NotificationService {
]); ]);
}; };
static notificationMakeUnread = (id, callback, errCallback) => { /*static notificationMakeUnread = (id, callback, errCallback) => {
NetworkService.put(`${API_BASE_URL}/notification/${id}`, {}, callback, errCallback, [ NetworkService.put(`${API_BASE_URL}/notification/${id}`, {}, callback, errCallback, [
['status', 'UNREAD'] ['status', 'UNREAD']
]); ]);
}; };*/
} }