import { apiGet, apiPost } from "@/api/client";

export interface AlertItem {
  id: string;
  source: string;
  title: string;
  message: string;
  tone: string;
  created_at: string;
  read: boolean;
}

export interface AlertsPayload {
  unread_count: number;
  items: AlertItem[];
}

export interface AlertsReadAllResult {
  updated_count: number;
  unread_count: number;
}

export function fetchAlerts(accessToken: string) {
  return apiGet<AlertsPayload>("/alerts", { accessToken });
}

export function markAlertRead(alertId: string, accessToken: string) {
  return apiPost<AlertItem>(`/alerts/${alertId}/read`, { accessToken });
}

export function markAllAlertsRead(accessToken: string) {
  return apiPost<AlertsReadAllResult>("/alerts/read-all", { accessToken });
}
