feat(FE): Support per-kandang sales fetching

This commit is contained in:
rstubryan
2026-01-13 11:00:36 +07:00
parent 0f5ac917d2
commit 06accca19e
2 changed files with 26 additions and 2 deletions
+9 -2
View File
@@ -35,8 +35,15 @@ const ClosingDetailPage = () => {
);
const { data: salesData, isLoading: isLoadingSales } = useSWR(
closingId ? `sales-${closingId}` : null,
() => ClosingApi.getPenjualan(Number(closingId))
kandangId
? `sales-${closingId}-${kandangId}`
: closingId
? `sales-${closingId}`
: null,
() =>
kandangId
? ClosingApi.getPenjualanByKandang(Number(closingId), Number(kandangId))
: ClosingApi.getPenjualan(Number(closingId))
);
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
+17
View File
@@ -37,6 +37,23 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
}
}
async getPenjualanByKandang(
closingId: number,
kandangId: number
): Promise<BaseApiResponse<ClosingSales> | undefined> {
try {
const path = `${this.basePath}/${closingId}/${kandangId}/penjualan`;
return await httpClient<BaseApiResponse<ClosingSales>>(path, {
method: 'GET',
});
} catch (error) {
if (axios.isAxiosError<BaseApiResponse<ClosingSales>>(error)) {
return error.response?.data;
}
return undefined;
}
}
async getAllIncomingSapronakFetcher(
endpoint: string
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {