import { apiClient } from './api-client'; // ─── Types ────────────────────────────────────────────── export interface NotificationDto { id: string; type: string; title: string; body: string; link: string | null; isRead: boolean; createdAt: string; } export interface PaginatedNotifications { data: NotificationDto[]; total: number; page: number; limit: number; totalPages: number; } export interface UnreadCountDto { count: number; } // ─── API Functions ────────────────────────────────────── export const notificationsApi = { /** Get paginated notifications for the current user */ list: (params: { page?: number; limit?: number } = {}) => { const query = new URLSearchParams(); if (params.page) query.append('page', String(params.page)); if (params.limit) query.append('limit', String(params.limit)); const qs = query.toString(); return apiClient.get( `/notifications${qs ? `?${qs}` : ''}`, ); }, /** Get unread notification count */ unreadCount: () => apiClient.get('/notifications/unread-count'), /** Mark a single notification as read */ markAsRead: (id: string) => apiClient.patch<{ success: boolean }>(`/notifications/${id}/read`), /** Mark all notifications as read */ markAllAsRead: () => apiClient.patch<{ success: boolean }>('/notifications/read-all'), };