mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
Merge branch 'feat/closing-kandang-hpp-ekspedisi-dan-penjualan' into 'development'
[FEAT/FE] Add Closing (Kandang) HPP Expedition (Ekspedisi) dan Sales (Penjualan) See merge request mbugroup/lti-web-client!164
This commit is contained in:
@@ -35,13 +35,30 @@ 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(
|
||||||
closingId ? `hpp-ekspedisi-${closingId}` : null,
|
kandangId
|
||||||
() => ClosingApi.getHppEkspedisi(Number(closingId))
|
? `hpp-ekspedisi-${closingId}-${kandangId}`
|
||||||
|
: closingId
|
||||||
|
? `hpp-ekspedisi-${closingId}`
|
||||||
|
: null,
|
||||||
|
() =>
|
||||||
|
kandangId
|
||||||
|
? ClosingApi.getHppEkspedisiByKandang(
|
||||||
|
Number(closingId),
|
||||||
|
Number(kandangId)
|
||||||
|
)
|
||||||
|
: ClosingApi.getHppEkspedisi(Number(closingId))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!closingId) {
|
if (!closingId) {
|
||||||
|
|||||||
@@ -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[]>> {
|
||||||
@@ -162,6 +179,23 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
|||||||
return undefined;
|
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');
|
export const ClosingApi = new ClosingApiService('/closings');
|
||||||
|
|||||||
Reference in New Issue
Block a user