fe integration for notification system with context, components, and API integration
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { api } from '@/lib/api'
|
||||
import type { NotificationPage } from '@/types/notifications'
|
||||
|
||||
export const notifications = {
|
||||
list: (params?: { unreadOnly?: boolean; page?: number; pageSize?: number }) =>
|
||||
api.get<NotificationPage>('/notifications', { params }).then(r => r.data),
|
||||
|
||||
unreadCount: () =>
|
||||
api.get<{ count: number }>('/notifications/unread-count').then(r => r.data.count),
|
||||
|
||||
markRead: (id: string) =>
|
||||
api.patch(`/notifications/${id}/read`).then(() => undefined),
|
||||
|
||||
markAllRead: () =>
|
||||
api.patch('/notifications/read-all').then(() => undefined),
|
||||
|
||||
remove: (id: string) =>
|
||||
api.delete(`/notifications/${id}`).then(() => undefined),
|
||||
}
|
||||
|
||||
/** SignalR hub URL — the API base URL without its trailing /api. */
|
||||
export const NOTIFICATION_HUB_URL =
|
||||
(process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:5089/api').replace(/\/api\/?$/, '') +
|
||||
'/hubs/notifications'
|
||||
Reference in New Issue
Block a user