import {axios} from "@/requests/axios.config";

const prefix = "/project";

function findAllProjects() {
  return axios.get(`${prefix}/findAll`);
}

function findCourseProjects() {
  return axios.get(`${prefix}/findCourse`);
}

function findNonCourseProjects() {
  return axios.get(`${prefix}/findNonCourse`);
}

function findProjectById(id) {
  return axios.get(`${prefix}/findById`, {
    params: {
      id,
    }
  });
}

function findProjectsByCourse(courseId) {
  return axios.get(`${prefix}/findByCourse`, {
    params: {
      courseId,
    }
  });
}

function createProject(data) {
  return axios.post(`${prefix}`, data);
}

function findProjectMembers(id) {
  return axios.get(`${prefix}/findMembers`, {
    params: {
      id,
    }
  });
}

function updateCourseProjectState(id) {
  return axios.put(`${prefix}/updateState`, null, {
    params: {
      id,
    }
  });
}

function forkProject(projectId) {
  return axios.post(`${prefix}/fork`, null, {
    params: {
      projectId,
    }
  });
}

const projectAPIs = {
  findAllProjects,
  findCourseProjects,
  findNonCourseProjects,
  findProjectById,
  findProjectMembers,
  findProjectsByCourse,
  createProject,
  updateCourseProjectState,
  forkProject,
};

export default projectAPIs;