import {
  PaggingReq,
  PaggingRes,
  axios,
  exampleList,
  deleteExample,
  setExample as setExampleUrl,
} from "@/request";
import { Case } from "@/store/case";

export type Example = Case;

export const getExamplePagging = async (
  params: PaggingReq<Pick<Case, "caseTitle">>
) => (await axios.get(exampleList, { params })).data as PaggingRes<Example>;

export const delExample = (example: Example) =>
  axios.post(deleteExample, { caseId: example.caseId });

export const addExample = (caseTitle: string) =>
  axios.post(setExampleUrl, { caseTitle });

export const setExample = (caseTitle: string, id: number) =>
  axios.post(setExampleUrl, { caseTitle, caseId: id });
