| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import type { Fetcher } from 'swr'
- import { get, post } from './base'
- export type Notification = {
- id: string
- type: string
- title: string
- content: string
- sender_id: string
- sender_name: string
- dataset_id: string
- dataset_name: string
- segment_id: string
- segment_preview: string
- link_url: string
- is_read: boolean
- created_at: string
- }
- export type NotificationListResponse = {
- notifications: Notification[]
- unread_count: number
- total: number
- }
- export type UnreadCountResponse = {
- unread_count: number
- }
- export type MarkAsReadRequest = {
- notification_ids?: string[]
- mark_all_as_read?: boolean
- }
- export const fetchNotifications: Fetcher<NotificationListResponse, string> = (url) => {
- return get<NotificationListResponse>(url)
- }
- export const fetchUnreadCount: Fetcher<UnreadCountResponse, string> = (url) => {
- return get<UnreadCountResponse>(url)
- }
- export const markNotificationsAsRead = (data: MarkAsReadRequest) => {
- return post<{ result: string }>('/datasets/notifications', { body: data })
- }
|