import axiosInstance from '../../../../utils/axiosInstance';

const fetchTotalStudent = async (search, sort, page, limit) => {
    try {
        const response = await axiosInstance.get(`/user/student?search=${search}&sort=${sort}&page=${page}&limit=${limit}`);
        return response.data;
    } catch (error) {
        console.error('Error fetching reports:', error);
        throw error;
    }
};

const fetchTotalTeacher = async (search, sort, page, limit) => {
    try {
        const response = await axiosInstance.get(`/user/teacher?search=${search}&sort=${sort}&page=${page}&limit=${limit}`);
        return response.data;
    } catch (error) {
        console.error('Error fetching reports:', error);
        throw error;
    }
};

const fetchActivity = async (search, sort, page, limit) => {
    try {
        const response = await axiosInstance.get(`/stdLearning/activities?search=${search}&sort=${sort}&page=${page}&limit=${limit}`);
        return response.data;
    } catch (error) {
        console.error('Error fetching reports:', error);
        throw error;
    }
};

const fetchReport = async (search, sort, page, limit) => {
    try {
        const response = await axiosInstance.get(`/report?search=${search}&sort=${sort}&page=${page}&limit=${limit}`);
        return response.data;
    } catch (error) {
        console.error('Error fetching reports:', error);
        throw error;
    }
};

export default{
    fetchTotalStudent,
    fetchTotalTeacher,
    fetchReport,
    fetchActivity
};
