feat(phase-18): add in-app notification system (T-128, T-129)

This commit is contained in:
2026-02-09 13:52:04 +01:00
parent cda59de426
commit fb7f340038
16 changed files with 7577 additions and 2 deletions

View File

@@ -0,0 +1,51 @@
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<NotificationItem[]> {
const { data } = await client.get<NotificationItem[]>(
`/notifications?offset=${offset}&limit=${limit}`,
);
return data;
}
/** Get the unread notification count. */
export async function getUnreadCount(): Promise<UnreadCount> {
const { data } = await client.get<UnreadCount>("/notifications/unread-count");
return data;
}
/** Mark a single notification as read. */
export async function markAsRead(id: string): Promise<NotificationItem> {
const { data } = await client.patch<NotificationItem>(
`/notifications/${id}/read`,
);
return data;
}
/** Mark all notifications as read. */
export async function markAllAsRead(): Promise<void> {
await client.post("/notifications/read-all");
}