import { apiClient } from "@/lib/api-client"

export interface Notification {
  id: string
  type: string
  title: string
  message: string
  link: string
  read: boolean
  createdAt: string
}

export interface NotificationsResponse {
  notifications: Notification[]
  unreadCount: number
}

export async function getNotifications(): Promise<NotificationsResponse> {
  return apiClient<NotificationsResponse>("/notifications")
}

export async function markNotificationAsRead(id: string): Promise<void> {
  await apiClient<void>(`/notifications/${id}/read`, { method: "PUT" })
}

export async function markAllNotificationsAsRead(): Promise<{
  updated: number
}> {
  return apiClient<{ updated: number }>("/notifications/read-all", {
    method: "PUT",
  })
}
