mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
feat(FE-338): Slicing UI Halaman Reporting BOP & API integration & refactor debounce input: adding useEffect for sync value
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { ReportExpense } from '@/types/api/report/report-expense';
|
||||
import axios from 'axios';
|
||||
|
||||
export class ReportExpenseApiService extends BaseApiService<
|
||||
ReportExpense,
|
||||
unknown,
|
||||
unknown
|
||||
> {
|
||||
constructor(basePath: string) {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async getAllFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ReportExpense[]>> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// const { dummyGetAllFetcher } = await import('@/dummy/report/expense.dummy');
|
||||
// return await dummyGetAllFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
return await httpClientFetcher<BaseApiResponse<ReportExpense[]>>(endpoint);
|
||||
}
|
||||
|
||||
async getSingle(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ReportExpense> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
const { dummyGetSingle } = await import('@/dummy/report/expense.dummy');
|
||||
return await dummyGetSingle(id);
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
// try {
|
||||
// const getSinglePath = `${this.basePath}/${id}`;
|
||||
// const getSingleRes =
|
||||
// await httpClient<BaseApiResponse<ReportExpense>>(getSinglePath);
|
||||
// return getSingleRes;
|
||||
// } catch (error) {
|
||||
// if (axios.isAxiosError<BaseApiResponse<ReportExpense>>(error)) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
export const ReportExpenseApi = new ReportExpenseApiService('/report/expense');
|
||||
Reference in New Issue
Block a user