mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix(FE): remove dummy data and integrate live API for closing finance and fixing closing UI when given data is null
This commit is contained in:
@@ -11,56 +11,13 @@ import {
|
||||
ClosingSapronakCalculation,
|
||||
} from '@/types/api/closing';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import {
|
||||
dummyGetAllFetcher,
|
||||
dummyGetSingle,
|
||||
dummyGetAllIncomingSapronakFetcher,
|
||||
dummyGetAllOutgoingSapronakFetcher,
|
||||
dummyGetGeneralInfo,
|
||||
dummyGetPerhitunganSapronak,
|
||||
dummyGetOverhead,
|
||||
} from '@/dummy/closing.dummy';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { ClosingSales } from '@/types/api/closing';
|
||||
import { dummyGetOneClosingFinance } from '@/dummy/json/closing-finance.dummy';
|
||||
|
||||
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
constructor(basePath: string) {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async getAllFetcher(endpoint: string): Promise<BaseApiResponse<Closing[]>> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// return await dummyGetAllFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
return await httpClientFetcher<BaseApiResponse<Closing[]>>(endpoint);
|
||||
}
|
||||
|
||||
async getSingle(id: number): Promise<BaseApiResponse<Closing> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetSingle(id);
|
||||
// } catch (error) {
|
||||
// if (axios.isAxiosError<BaseApiResponse<Closing>>(error)) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const getSinglePath = `${this.basePath}/${id}`;
|
||||
const getSingleRes =
|
||||
await httpClient<BaseApiResponse<Closing>>(getSinglePath);
|
||||
return getSingleRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<Closing>>(error)) {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getPenjualan(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingSales> | undefined> {
|
||||
@@ -81,10 +38,6 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
async getAllIncomingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// return await dummyGetAllIncomingSapronakFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
return await httpClientFetcher<BaseApiResponse<ClosingIncomingSapronak[]>>(
|
||||
endpoint
|
||||
);
|
||||
@@ -93,31 +46,14 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
async getAllOutgoingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingOutgoingSapronak[]>> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
return await dummyGetAllOutgoingSapronakFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
// return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
||||
// endpoint
|
||||
// );
|
||||
return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
||||
endpoint
|
||||
);
|
||||
}
|
||||
|
||||
async getGeneralInfo(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingGeneralInformation> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetGeneralInfo(id);
|
||||
// } catch (error) {
|
||||
// if (
|
||||
// axios.isAxiosError<BaseApiResponse<ClosingGeneralInformation>>(error)
|
||||
// ) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const getGeneralInfoPath = `${this.basePath}/${id}`;
|
||||
const getGeneralInfoRes =
|
||||
@@ -138,19 +74,6 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
async getPerhitunganSapronak(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingSapronakCalculation> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetPerhitunganSapronak(id);
|
||||
// } catch (error) {
|
||||
// if (
|
||||
// axios.isAxiosError<BaseApiResponse<ClosingSapronakCalculation>>(error)
|
||||
// ) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/perhitungan_sapronak`;
|
||||
return await httpClient<BaseApiResponse<ClosingSapronakCalculation>>(
|
||||
@@ -172,17 +95,6 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
async getOverhead(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingOverhead> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetOverhead(id);
|
||||
// } catch (error) {
|
||||
// if (axios.isAxiosError<BaseApiResponse<ClosingOverhead>>(error)) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/overhead`;
|
||||
return await httpClient<BaseApiResponse<ClosingOverhead>>(path, {
|
||||
@@ -199,12 +111,8 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
async getFinance(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingFinance> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// return dummyGetOneClosingFinance(id);
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/finance`;
|
||||
const path = `${this.basePath}/${id}/keuangan`;
|
||||
return await httpClient<BaseApiResponse<ClosingFinance>>(path, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user