mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import axios from 'axios';
|
|
|
|
import { BaseApiService } from '@/services/api/base';
|
|
import {
|
|
Closing,
|
|
ClosingGeneralInformation,
|
|
ClosingIncomingSapronak,
|
|
ClosingOutgoingSapronak,
|
|
} from '@/types/api/closing';
|
|
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
|
import { BaseApiResponse } from '@/types/api/api-general';
|
|
import { ClosingSales } from '@/types/api/closing';
|
|
|
|
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
|
constructor(basePath: string) {
|
|
super(basePath);
|
|
}
|
|
|
|
async getPenjualan(
|
|
id: number
|
|
): Promise<BaseApiResponse<ClosingSales> | undefined> {
|
|
try {
|
|
const getPenjualanPath = `${id}/penjualan`;
|
|
return await this.customRequest<BaseApiResponse<ClosingSales>>(
|
|
getPenjualanPath
|
|
);
|
|
} catch (error) {
|
|
if (axios.isAxiosError<BaseApiResponse<ClosingSales>>(error)) {
|
|
return error.response?.data;
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
async getAllIncomingSapronakFetcher(
|
|
endpoint: string
|
|
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
|
return await httpClientFetcher<BaseApiResponse<ClosingIncomingSapronak[]>>(
|
|
endpoint
|
|
);
|
|
}
|
|
|
|
async getAllOutgoingSapronakFetcher(
|
|
endpoint: string
|
|
): Promise<BaseApiResponse<ClosingOutgoingSapronak[]>> {
|
|
return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
|
endpoint
|
|
);
|
|
}
|
|
|
|
async getGeneralInfo(id: number) {
|
|
try {
|
|
const getGeneralInfoPath = `${this.basePath}/${id}`;
|
|
const getGeneralInfoRes =
|
|
await httpClient<BaseApiResponse<ClosingGeneralInformation>>(
|
|
getGeneralInfoPath
|
|
);
|
|
|
|
return getGeneralInfoRes;
|
|
} catch (error) {
|
|
if (
|
|
axios.isAxiosError<BaseApiResponse<ClosingGeneralInformation>>(error)
|
|
) {
|
|
return error.response?.data;
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|
|
}
|
|
|
|
export const ClosingApi = new ClosingApiService('/closings');
|