import api from "src/api";

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

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

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

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

export const deleteClass = async (id) => {
  const { data } = await api.delete(`/franchisee/classes/${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(`/franchisee/classes/${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(`/franchisee/classes/${id}/attendances`, { attendances });
  return data.payload;
};
