mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
Merge branch 'feat/progress-input-export' into 'development'
[FEAT/FE] Progress Input Exporet See merge request mbugroup/lti-web-client!418
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
UpdateExpensePayload,
|
||||
} from '@/types/api/expense';
|
||||
import { httpClient } from '@/services/http/client';
|
||||
import { formatDate } from '@/lib/helper';
|
||||
|
||||
export class ExpenseApiService extends BaseApiService<
|
||||
Expense,
|
||||
@@ -706,6 +707,33 @@ export class ExpenseApiService extends BaseApiService<
|
||||
|
||||
return formData;
|
||||
};
|
||||
|
||||
async exportInputProgressToExcel(startDate: string, endDate: string) {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
params.set('export', 'excel');
|
||||
params.set('type', 'progress');
|
||||
params.set('start_date', formatDate(startDate, 'YYYY-MM-DD'));
|
||||
params.set('end_date', formatDate(endDate, 'YYYY-MM-DD'));
|
||||
|
||||
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 = `input-progres-BOP-${formatDate(startDate, 'DD-MM-YYYY')}-ke-${formatDate(endDate, 'DD-MM-YYYY')}.xlsx`;
|
||||
link.setAttribute('download', fileName);
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
}
|
||||
}
|
||||
|
||||
export const ExpenseApi = new ExpenseApiService('/expenses');
|
||||
|
||||
Reference in New Issue
Block a user