feat: export file
This commit is contained in:
@@ -5,6 +5,7 @@ import axios from "axios";
|
||||
import {appConfig} from "../config/app";
|
||||
import fileDownload from "react-file-download";
|
||||
import {TokenUtil} from "../utils/token";
|
||||
import {message} from "antd";
|
||||
|
||||
export class Transaction {
|
||||
page = 0;
|
||||
@@ -273,24 +274,26 @@ export class Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
async exportTransaction(id,dateStart) {
|
||||
exportTransaction(data,date) {
|
||||
try {
|
||||
axios({
|
||||
url: appConfig.apiUrl + `/excel/history-user/export/${id}`,
|
||||
url: appConfig.apiUrl + `/excel/history-user/export/${data.id}`,
|
||||
headers: {"Authorization" : `Bearer ${TokenUtil.accessToken}`},
|
||||
method: 'POST',
|
||||
data: dateStart,
|
||||
data: date,
|
||||
responseType: 'blob'
|
||||
}).then((response) => {
|
||||
var fileDownload = require('react-file-download');
|
||||
fileDownload(response.data, `Mutasi Transaki IRS 2022-12-08.xlsx`);
|
||||
message.success("Success export");
|
||||
fileDownload(response.data, `Mutasi Transaki ${data.userDetail.name} ${date.dateStart}.xlsx`);
|
||||
return fileDownload;
|
||||
}).catch(function (error) {
|
||||
return error.message;
|
||||
message.error("No data to export");
|
||||
return error;
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e,':)')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user