mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 12:18:11 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import type { NotificationListResult } from "@edr/types";
|
|
|
|
import { client } from "@/utils/api";
|
|
|
|
export interface ListNotificationsParams {
|
|
page?: number;
|
|
limit?: number;
|
|
isRead?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Portal notification REST calls. The portal axios `client` returns the raw
|
|
* response, and the API wraps payloads in a `{ success, data }` envelope — so we
|
|
* unwrap `.data.data` here (same convention as the other portal services).
|
|
*/
|
|
export const notificationsApi = {
|
|
list: async (
|
|
params: ListNotificationsParams = {},
|
|
): Promise<NotificationListResult> => {
|
|
const { data } = await client.get("/api/notifications", { params });
|
|
return data.data;
|
|
},
|
|
unreadCount: async (): Promise<number> => {
|
|
const { data } = await client.get("/api/notifications/unread-count");
|
|
return data.data.unreadCount;
|
|
},
|
|
markRead: async (id: string): Promise<void> => {
|
|
await client.patch(`/api/notifications/${id}/read`);
|
|
},
|
|
markAllRead: async (): Promise<void> => {
|
|
await client.post("/api/notifications/read-all");
|
|
},
|
|
};
|