import {
  axios,
  cameraTypeStatistics,
  casePlaceStatistics,
  caseReasonStatistics,
  caseStatistics,
  caseTimeStatistics,
  sceneStatistics,
} from "@/request";

export type StatisticsParams = {
  startTime: string;
  endTime: string;
};
export type StatisticsItem = { groupKey: string; dataCount: number };
export type StatisticsItems = StatisticsItem[];

export const getSceneStatistics = async (params: StatisticsParams) =>
  (await axios.post<StatisticsItems>(sceneStatistics, params)).data;

export const getCaseStatistics = async (params: StatisticsParams) =>
  (await axios.post<StatisticsItems>(caseStatistics, params)).data;

export const getCameraTypeStatistics = async (params: StatisticsParams) =>
  (await axios.post<StatisticsItems>(cameraTypeStatistics, params)).data;

export const getCaseTimeStatistics = async (params: StatisticsParams) =>
  (await axios.post<StatisticsItems>(caseTimeStatistics, params)).data;

export const getCasePlaceStatistics = async (params: StatisticsParams) =>
  (await axios.post<StatisticsItems>(casePlaceStatistics, params)).data;

export const getCaseReasonStatistics = async (params: StatisticsParams) =>
  (await axios.post<StatisticsItems>(caseReasonStatistics, params)).data;
