import api from "src/api";

export const getClasses = async (params = {}) => {
  const { data } = await api.get("/class", { params });
  return data.payload;
};

export const getClass = async (id) => {
  const { data } = await api.get(`/class/${id}`);
  return data.payload;
};

export const createClass = async (payload) => {
  const { data } = await api.post("/class", payload);
  return data.payload;
};

export const updateClass = async (payload, id) => {
  const { data } = await api.put(`/class/${id}`, payload);
  return data.payload;
};

export const deleteClass = async (id) => {
  const { data } = await api.delete(`/class/${id}`);
  return data.payload;
};

// Alunos com contrato ativo no pacote da aula + presença registrada
export const getClassStudents = async (id) => {
  const { data } = await api.get(`/class/${id}/students`);
  return data.payload;
};

// Salva a lista de presença da aula em lote
export const saveClassAttendance = async (id, attendances) => {
  const { data } = await api.post(`/class/${id}/attendances`, { attendances });
  return data.payload;
};
