mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
feat(FE): Support per-kandang sales fetching
This commit is contained in:
@@ -35,8 +35,15 @@ const ClosingDetailPage = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { data: salesData, isLoading: isLoadingSales } = useSWR(
|
const { data: salesData, isLoading: isLoadingSales } = useSWR(
|
||||||
closingId ? `sales-${closingId}` : null,
|
kandangId
|
||||||
() => ClosingApi.getPenjualan(Number(closingId))
|
? `sales-${closingId}-${kandangId}`
|
||||||
|
: closingId
|
||||||
|
? `sales-${closingId}`
|
||||||
|
: null,
|
||||||
|
() =>
|
||||||
|
kandangId
|
||||||
|
? ClosingApi.getPenjualanByKandang(Number(closingId), Number(kandangId))
|
||||||
|
: ClosingApi.getPenjualan(Number(closingId))
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
|
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
|
||||||
|
|||||||
@@ -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(
|
async getAllIncomingSapronakFetcher(
|
||||||
endpoint: string
|
endpoint: string
|
||||||
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user