feat(FE): Support fetching HPP ekspedisi by kandang

This commit is contained in:
rstubryan
2026-01-13 10:57:40 +07:00
parent a526772e02
commit 0f5ac917d2
2 changed files with 29 additions and 2 deletions
+12 -2
View File
@@ -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) {
+17
View File
@@ -162,6 +162,23 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
return undefined;
}
}
async getHppEkspedisiByKandang(
closingId: number,
kandangId: number
): Promise<BaseApiResponse<ClosingHppExpedition> | undefined> {
try {
const path = `${this.basePath}/${closingId}/${kandangId}/expedition-hpp`;
return await httpClient<BaseApiResponse<ClosingHppExpedition>>(path, {
method: 'GET',
});
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<ClosingHppExpedition>>(error)) {
return error.response?.data;
}
return undefined;
}
}
}
export const ClosingApi = new ClosingApiService('/closings');