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