fixing teacher feedback csv download
This commit is contained in:
parent
b22ada1c99
commit
ba94945f00
|
|
@ -80,9 +80,15 @@ const useProgressClass = (progressId) => {
|
||||||
|
|
||||||
const handleDownloadCSV = async () => {
|
const handleDownloadCSV = async () => {
|
||||||
try {
|
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 downloadUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
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 {
|
||||||
|
|
@ -70,7 +72,7 @@ const postFeedback = async (id, feedback) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCsvProgress = async () => {
|
const getCsvProgress = async (data) => {
|
||||||
const configs = {
|
const configs = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: localStorage.getItem('token')
|
Authorization: localStorage.getItem('token')
|
||||||
|
|
@ -78,7 +80,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);
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ const Feedback = () => {
|
||||||
))
|
))
|
||||||
):(
|
):(
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={5} style={{height:'20vh'}}>
|
<td colSpan={6} style={{height:'20vh'}}>
|
||||||
<h3>Empty Data</h3>
|
<h3>Empty Data</h3>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user