import { baseAPI } from "@/lib/api";

import type { DraftDashboard } from "@/features/cdc-gpsf/progress-report/components/draft-dashboard/draft-dashboard-service";

type ApiResponse<T> = {
  success: boolean;
  statusCode: number;
  message: string;
  data: T;
};

// The plenary dashboard CDC-GPSF published, plus the progress report it came
// from. Null while nothing has been published.
export type LivePlenaryDashboard = DraftDashboard & {
  report: { id: number; title: string; year: number; semester: string };
};

export async function getLivePlenaryDashboard(): Promise<LivePlenaryDashboard | null> {
  const response = (await baseAPI(
    "/dashboards/plenary/live",
  )) as ApiResponse<LivePlenaryDashboard | null>;

  return response.data ?? null;
}
