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 { constructor(basePath: string) { super(basePath); } async getPenjualan( id: number ): Promise | undefined> { try { const getPenjualanPath = `${this.basePath}/${id}/penjualan`; const getPenjualanRes = await httpClient>(getPenjualanPath); return getPenjualanRes; } catch (error) { if (axios.isAxiosError>(error)) { return error.response?.data; } return undefined; } } async getAllIncomingSapronakFetcher( endpoint: string ): Promise> { return await httpClientFetcher>( endpoint ); } async getAllOutgoingSapronakFetcher( endpoint: string ): Promise> { return await httpClientFetcher>( endpoint ); } async getGeneralInfo(id: number) { try { const getGeneralInfoPath = `${this.basePath}/${id}`; const getGeneralInfoRes = await httpClient>( getGeneralInfoPath ); return getGeneralInfoRes; } catch (error) { if ( axios.isAxiosError>(error) ) { return error.response?.data; } return undefined; } } } export const ClosingApi = new ClosingApiService('/closings');