30 lines
790 B
TypeScript
30 lines
790 B
TypeScript
import { apiRequest } from './api';
|
|
|
|
export type NotificationItem = {
|
|
id: string;
|
|
kind: string;
|
|
title: string;
|
|
body: string;
|
|
href: string;
|
|
readAt: string | null;
|
|
createdAt: string;
|
|
};
|
|
|
|
export type NotificationFeed = {
|
|
items: NotificationItem[];
|
|
unread: number;
|
|
};
|
|
|
|
export const getNotifications = async (): Promise<NotificationFeed> => {
|
|
const response = await apiRequest<{ data: NotificationFeed }>('/notifications');
|
|
return response.data;
|
|
};
|
|
|
|
export const markNotificationRead = async (notificationId: string): Promise<void> => {
|
|
await apiRequest<void>(`/notifications/${notificationId}/read`, { method: 'POST' });
|
|
};
|
|
|
|
export const markAllNotificationsRead = async (): Promise<void> => {
|
|
await apiRequest<void>('/notifications/read-all', { method: 'POST' });
|
|
};
|