chore: update CHANGELOG for version 0.6.0-alpha, add in-app notification center, and update package dependencies
This commit is contained in:
39
lib/api/notifications.ts
Normal file
39
lib/api/notifications.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file Notifications API client
|
||||
*/
|
||||
|
||||
import apiRequest from './client'
|
||||
|
||||
export interface Notification {
|
||||
id: string
|
||||
organization_id: string
|
||||
type: string
|
||||
title: string
|
||||
body?: string
|
||||
read: boolean
|
||||
link_url?: string
|
||||
link_label?: string
|
||||
metadata?: Record<string, unknown>
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface ListNotificationsResponse {
|
||||
notifications: Notification[]
|
||||
unread_count: number
|
||||
}
|
||||
|
||||
export async function listNotifications(): Promise<ListNotificationsResponse> {
|
||||
return apiRequest<ListNotificationsResponse>('/notifications')
|
||||
}
|
||||
|
||||
export async function markNotificationRead(id: string): Promise<void> {
|
||||
return apiRequest<void>(`/notifications/${id}/read`, {
|
||||
method: 'PATCH',
|
||||
})
|
||||
}
|
||||
|
||||
export async function markAllNotificationsRead(): Promise<void> {
|
||||
return apiRequest<void>('/notifications/mark-all-read', {
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user