import axiosInstance from "@/apis/axios.config";

const PREFIX = "/api/behaviorRecord"

const bevaviorApis = {
    selectBehaviorRecord: (studentId: number, assignmentId :number) => {
        return axiosInstance.get(`${PREFIX}`, {
            params: {
                studentId,
                assignmentId
            }
        })
    },
    addBehaviorRecord: (assignmentId :number, file) => {
        const formData = new FormData();
        formData.append("assignmentId", assignmentId.toString())
        formData.append('file', file);
        return axiosInstance.post(`${PREFIX}`, formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    },
    getOverview: (studentId:number,assignmentId :number) => {
        return axiosInstance.get(`${PREFIX}/overview`, {
            params: {
                studentId,
                assignmentId
            }
        })
    },
    getBehaviorRecordAll: (studentId:number,assignmentId :number) => {
        return axiosInstance.get(`${PREFIX}/all`, {
            params: {
                studentId,
                assignmentId
            }
        })
    },
    getPauseStatisticData:(studentId:number,assignmentId :number,threshold:number) =>{
        return axiosInstance.get(`${PREFIX}/pauseStatistics`, {
            params: {
                studentId,
                assignmentId,
                threshold
            }
        })
    },
    downLoadBehaviorData:(studentId:number,assignmentId :number)=>{
        return axiosInstance.get(`/api/export/behaviorOverview/excel`, {
            responseType: 'blob',
            params: {
                studentId,
                assignmentId
            }
        })
    },
    downLoadAllBehaviorData:(assignmentId :number)=>{
        return axiosInstance.get(`/api/export/behaviorOverview/excel/assignment`, {
            responseType: 'blob',
            params: {
                assignmentId
            }
        })
    },
    downLoadAllBehaviorDataByClass:(classId :number,assignmentId :number)=>{
        return axiosInstance.get(`/api/export/behaviorOverview/excel/class/assignment`, {
            responseType: 'blob',
            params: {
                classId,
                assignmentId
            }
        })
    },
}

export default bevaviorApis;
