- fix export transaction history data in detail user
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import { http } from "../utils/http";
|
||||
import { binaryStringToArrayBuffer, arrayBufferToBlob } from 'blob-util'
|
||||
import axios from "axios";
|
||||
import {appConfig} from "../config/app";
|
||||
import fileDownload from "react-file-download";
|
||||
import {TokenUtil} from "../utils/token";
|
||||
|
||||
export class Transaction {
|
||||
page = 0;
|
||||
@@ -269,20 +273,24 @@ export class Transaction {
|
||||
}
|
||||
}
|
||||
|
||||
async exportTransaction(id,data) {
|
||||
async exportTransaction(id,dateStart) {
|
||||
try {
|
||||
const response = await http
|
||||
.post(`/excel/history-user/export/${id}`)
|
||||
.send(data)
|
||||
axios({
|
||||
url: appConfig.apiUrl + `/excel/history-user/export/${id}`,
|
||||
headers: {"Authorization" : `Bearer ${TokenUtil.accessToken}`},
|
||||
method: 'POST',
|
||||
data: dateStart,
|
||||
responseType: 'blob'
|
||||
}).then((response) => {
|
||||
var fileDownload = require('react-file-download');
|
||||
fileDownload(response.data, `Mutasi Transaki IRS 2022-12-08.xlsx`);
|
||||
return fileDownload;
|
||||
}).catch(function (error) {
|
||||
return error.message;
|
||||
});
|
||||
|
||||
console.log(response, 'ress');
|
||||
const apa = binaryStringToArrayBuffer(response.text)
|
||||
const ini = arrayBufferToBlob(apa, 'text/xlsx')
|
||||
let file = new File([ini], 'text.xlsx', {type: "text/xlsx;charset=utf-8"})
|
||||
console.log(file, 'ini file');
|
||||
return file;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user