fe integration for notification system with context, components, and API integration

This commit is contained in:
2026-10-20 16:53:15 +05:30
parent 6b9f27573b
commit 209ee7da2d
11 changed files with 696 additions and 17 deletions
+24
View File
@@ -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'