feat: initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import api from './client'
|
||||
|
||||
export interface Notification {
|
||||
id: string
|
||||
action: string
|
||||
entity_type: string | null
|
||||
entity_id: string | null
|
||||
details: Record<string, unknown> | null
|
||||
timestamp: string
|
||||
read_at: string | null
|
||||
}
|
||||
|
||||
export interface NotificationListResponse {
|
||||
items: Notification[]
|
||||
unread_count: number
|
||||
total: number
|
||||
}
|
||||
|
||||
export async function getNotifications(params?: {
|
||||
limit?: number
|
||||
offset?: number
|
||||
unread_only?: boolean
|
||||
}): Promise<NotificationListResponse> {
|
||||
const { data } = await api.get('/notifications', { params })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function getUnreadCount(): Promise<number> {
|
||||
const { data } = await api.get('/notifications/unread-count')
|
||||
return data.unread_count
|
||||
}
|
||||
|
||||
export async function markAsRead(ids?: string[]): Promise<void> {
|
||||
await api.post('/notifications/mark-read', { notification_ids: ids ?? null })
|
||||
}
|
||||
|
||||
export async function markOneAsRead(id: string): Promise<void> {
|
||||
await api.post(`/notifications/${id}/mark-read`)
|
||||
}
|
||||
Reference in New Issue
Block a user