continue: add pagination for notification page and some featur

This commit is contained in:
smanylov
2026-04-05 15:06:08 +07:00
parent 27ca7ddf8e
commit 1fe49c24e8
5 changed files with 222 additions and 75 deletions
@@ -3,20 +3,24 @@ import { fetchAllNotifications, NotificationBody } from '@/app/actions/notificat
export interface UseAllNotifications {
notifications: NotificationBody[],
unreadCount: number
currentPage: number,
totalElements: number,
totalPages: number,
}
export const useAllNotifications = () => {
export const useAllNotifications = (page: number, size: number = 10) => {
return useQuery({
queryKey: ['allNotifications'],
queryKey: ['allNotifications', page, size],
queryFn: () => {
return fetchAllNotifications()
return fetchAllNotifications(page, size)
},
select: (data: UseAllNotifications | null) => {
if (!data) {
return {
notifications: [],
unreadCount: 0
currentPage: 0,
totalElements: 0,
totalPages: 0,
}
}
return data;