fixing teacher feedback csv download

This commit is contained in:
Dimas Atmodjo 2024-12-16 09:40:56 +07:00
parent b22ada1c99
commit ba94945f00
3 changed files with 14 additions and 6 deletions

View File

@ -80,14 +80,20 @@ const useProgressClass = (progressId) => {
const handleDownloadCSV = async () => {
try {
const response = await progressService.getCsvProgress();
const [classId, topicId] = progressId.split("&");
const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const dataId = {
ID_CLASS: classId,
ID_TOPIC: topicId,
};
const response = await progressService.getCsvProgress(dataId);
const blob = new Blob([response], { type: '.csv' });
const downloadUrl = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = downloadUrl;
link.download = `progress ${name}-${topic}.csv`;
link.download = `progress ${name} - ${topic}.csv`;
link.click();
URL.revokeObjectURL(downloadUrl);

View File

@ -1,4 +1,6 @@
import axiosInstance from '../../../../utils/axiosInstance';
import axios from 'axios';
import { API_URL } from '../../../../utils/Constant';
const fetchDataStudent = async (search, sort, page, limit) => {
try {
@ -70,7 +72,7 @@ const postFeedback = async (id, feedback) => {
}
};
const getCsvProgress = async () => {
const getCsvProgress = async (data) => {
const configs = {
headers: {
Authorization: localStorage.getItem('token')
@ -78,7 +80,7 @@ const getCsvProgress = async () => {
responseType: 'blob',
};
try {
const response = await axiosInstance.get(`/monitoring/class/csv`, configs);
const response = await axiosInstance.post(`/monitoring/class/csv`,data ,configs);
return response.data;
} catch (error) {
console.error(`Error get file:`, error);

View File

@ -114,7 +114,7 @@ const Feedback = () => {
))
):(
<tr>
<td colSpan={5} style={{height:'20vh'}}>
<td colSpan={6} style={{height:'20vh'}}>
<h3>Empty Data</h3>
</td>
</tr>