import {axios} from "@/requests/axios.config";
const prefix = "/group";

function createGroupRule(data){
    return axios.post(`${prefix}/rule`,data);
}

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

function addGroupMember(data){
    return axios.post(`${prefix}/member/add`,data);
}

function sendInvitation(data){
    return axios.post(`${prefix}/invite`,data);
}

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

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

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

function deleteGroup(userId,courseId){
    return axios.get(`${prefix}/delete`,{
        params:{
            "userId":userId,
            "courseId":courseId,
        }
    });
}

const groupAPIs={
    createGroupRule,
    createGroup,
    addGroupMember,
    sendInvitation,
    findGroup,
    findAllGroupsByCourse,
    findGroupRule,
    deleteGroup
};

export default groupAPIs;