import api from "src/api";

export const getStudentMedias = async (studentId) => {
  const { data } = await api.get("/franchisee/students/medias", { params: { student_id: studentId } });
  return data.payload;
};

export const getContractMedias = async (contractId) => {
  const { data } = await api.get("/franchisee/contracts/medias", { params: { student_contract_id: contractId } });
  return data.payload;
};

export const deleteContractMedia = async (id) => {
  const { data } = await api.delete(`/franchisee/contracts/medias/${id}`);
  return data;
};

export const createStudentMedia = async (formData) => {
  const { data } = await api.post("/franchisee/students/medias", formData, {
    headers: { "Content-Type": "multipart/form-data" },
  });
  return data.payload;
};

export const updateStudentMedia = async (id, formData) => {
  formData.append("_method", "PUT");
  const { data } = await api.post(`/franchisee/students/medias/${id}`, formData, {
    headers: { "Content-Type": "multipart/form-data" },
  });
  return data.payload;
};

export const deleteStudentMedia = async (id) => {
  const { data } = await api.delete(`/franchisee/students/medias/${id}`);
  return data;
};
