fixing get csv to post

This commit is contained in:
Dimas Atmodjo 2024-12-16 14:13:59 +07:00
parent ba94945f00
commit d7c8c62ff4
3 changed files with 9 additions and 5 deletions

View File

@ -80,7 +80,13 @@ const useProgressClass = (progressId) => {
const handleDownloadCSV = async () => { const handleDownloadCSV = async () => {
try { try {
const response = await progressService.getCsvProgress(); const [classId, topicId] = progressId.split("&");
const dataId = {
ID_CLASS: classId,
ID_TOPIC: topicId,
};
const response = await progressService.getCsvProgress(dataId);
const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const downloadUrl = URL.createObjectURL(blob); const downloadUrl = URL.createObjectURL(blob);

View File

@ -60,7 +60,7 @@ const fetchDataClassProgress = async (dataId, search, sort, page, limit) => {
} }
}; };
const getCsvProgress = async () => { const getCsvProgress = async (data) => {
const configs = { const configs = {
headers: { headers: {
Authorization: localStorage.getItem('token') Authorization: localStorage.getItem('token')
@ -68,7 +68,7 @@ const getCsvProgress = async () => {
responseType: 'blob', responseType: 'blob',
}; };
try { try {
const response = await axiosInstance.get(`/monitoring/class/csv`, configs); const response = await axiosInstance.post(`/monitoring/class/csv`,data ,configs);
return response.data; return response.data;
} catch (error) { } catch (error) {
console.error(`Error get file:`, error); console.error(`Error get file:`, error);

View File

@ -1,6 +1,4 @@
import axiosInstance from '../../../../utils/axiosInstance'; import axiosInstance from '../../../../utils/axiosInstance';
import axios from 'axios';
import { API_URL } from '../../../../utils/Constant';
const fetchDataStudent = async (search, sort, page, limit) => { const fetchDataStudent = async (search, sort, page, limit) => {
try { try {