mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 21:15:41 +00:00
feat: setup notification to the backoffice
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import type { NotificationListResult } from "@edr/types";
|
||||
|
||||
import { api } from "@/auth/http";
|
||||
|
||||
export interface ListNotificationsParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
isRead?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backoffice notification REST calls. The backoffice axios `api` response
|
||||
* interceptor already unwraps the `{ success, data }` envelope, so `.data` here
|
||||
* is the payload itself.
|
||||
*/
|
||||
export const notificationsApi = {
|
||||
list: async (
|
||||
params: ListNotificationsParams = {},
|
||||
): Promise<NotificationListResult> => {
|
||||
const { data } = await api.get<NotificationListResult>("/notifications", {
|
||||
params,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
unreadCount: async (): Promise<number> => {
|
||||
const { data } = await api.get<{ unreadCount: number }>(
|
||||
"/notifications/unread-count",
|
||||
);
|
||||
return data.unreadCount;
|
||||
},
|
||||
markRead: async (id: string): Promise<void> => {
|
||||
await api.patch(`/notifications/${id}/read`);
|
||||
},
|
||||
markAllRead: async (): Promise<void> => {
|
||||
await api.post("/notifications/read-all");
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user