import client from "./client"; // ── Types ─────────────────────────────────────────────────────────── export interface NotificationItem { id: string; user_id: string; type: string; title: string; message: string | null; entity_type: string | null; entity_id: string | null; read: boolean; created_at: string | null; } export interface UnreadCount { unread_count: number; } // ── API ───────────────────────────────────────────────────────────── /** Fetch notifications for the current user (paginated). */ export async function getNotifications( offset = 0, limit = 20, ): Promise { const { data } = await client.get( `/notifications?offset=${offset}&limit=${limit}`, ); return data; } /** Get the unread notification count. */ export async function getUnreadCount(): Promise { const { data } = await client.get("/notifications/unread-count"); return data; } /** Mark a single notification as read. */ export async function markAsRead(id: string): Promise { const { data } = await client.patch( `/notifications/${id}/read`, ); return data; } /** Mark all notifications as read. */ export async function markAllAsRead(): Promise { await client.post("/notifications/read-all"); }