import axios from "@/config/axios";
import type {
  CreateScheduleType,
  GetSchedulesResponseType,
  GetScheduleResponseType,
} from "../types/Types";

export const getSchedules = async (
  params?: Record<string, unknown>
): Promise<GetSchedulesResponseType> => {
  const { data } = await axios.get<GetSchedulesResponseType>("/schedules", {
    params,
  });
  return data;
};

export const deleteSchedule = async (id: string) => {
  const { data } = await axios.delete(`/schedules/${id}`);
  return data;
};

export const createSchedule = async (params: CreateScheduleType) => {
  const { data } = await axios.post("/schedules", params);
  return data;
};

export const updateSchedule = async (
  id: string,
  params: CreateScheduleType
) => {
  const { data } = await axios.patch(`/schedules/${id}`, params);
  return data;
};

export const getSchedule = async (
  id: string
): Promise<GetScheduleResponseType> => {
  const { data } = await axios.get<GetScheduleResponseType>(`/schedules/${id}`);
  return data;
};
