From 0f5ac917d2a4634dca92ddea9ce1984ade5cf4e6 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 10:57:40 +0700 Subject: [PATCH] feat(FE): Support fetching HPP ekspedisi by kandang --- src/app/closing/detail/page.tsx | 14 ++++++++++++-- src/services/api/closing.ts | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/app/closing/detail/page.tsx b/src/app/closing/detail/page.tsx index f271700b..c76d04e1 100644 --- a/src/app/closing/detail/page.tsx +++ b/src/app/closing/detail/page.tsx @@ -40,8 +40,18 @@ const ClosingDetailPage = () => { ); const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR( - closingId ? `hpp-ekspedisi-${closingId}` : null, - () => ClosingApi.getHppEkspedisi(Number(closingId)) + kandangId + ? `hpp-ekspedisi-${closingId}-${kandangId}` + : closingId + ? `hpp-ekspedisi-${closingId}` + : null, + () => + kandangId + ? ClosingApi.getHppEkspedisiByKandang( + Number(closingId), + Number(kandangId) + ) + : ClosingApi.getHppEkspedisi(Number(closingId)) ); if (!closingId) { diff --git a/src/services/api/closing.ts b/src/services/api/closing.ts index 8ea2faa5..7e1910c8 100644 --- a/src/services/api/closing.ts +++ b/src/services/api/closing.ts @@ -162,6 +162,23 @@ export class ClosingApiService extends BaseApiService { return undefined; } } + + async getHppEkspedisiByKandang( + closingId: number, + kandangId: number + ): Promise | undefined> { + try { + const path = `${this.basePath}/${closingId}/${kandangId}/expedition-hpp`; + return await httpClient>(path, { + method: 'GET', + }); + } catch (error) { + if (axios.isAxiosError>(error)) { + return error.response?.data; + } + return undefined; + } + } } export const ClosingApi = new ClosingApiService('/closings');