feat: implement purchase export to excel

This commit is contained in:
ValdiANS
2026-04-22 23:20:31 +07:00
parent 60df577cc6
commit 5d6aaace86
2 changed files with 54 additions and 0 deletions
+27
View File
@@ -115,6 +115,33 @@ export const PurchaseApi = {
},
},
async exportToExcel(initialQueryString: string) {
const params = new URLSearchParams(initialQueryString);
params.set('export', 'excel');
params.set('type', 'all');
params.set('page', '1');
params.set('limit', '99999999999');
const queryString = `?${params.toString()}`;
const res = await httpClient<Blob>(`${this.basePath}${queryString}`, {
method: 'GET',
responseType: 'blob',
});
const url = window.URL.createObjectURL(new Blob([res]));
const link = document.createElement('a');
link.href = url;
const fileName = `pembelian-${formatDate(Date.now(), 'DD-MM-YYYY')}.xlsx`;
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
link.remove();
},
async exportInputProgressToExcel(startDate: string, endDate: string) {
const params = new URLSearchParams();