mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat: implement closing production data per kandang
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { useSearchParams } from 'next/navigation';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import { ClosingApi } from '@/services/api/closing';
|
import { ClosingApi } from '@/services/api/closing';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
@@ -12,9 +13,12 @@ interface ClosingProductionDataTabContentProps {
|
|||||||
const ClosingProductionDataTabContent = ({
|
const ClosingProductionDataTabContent = ({
|
||||||
projectFlockId,
|
projectFlockId,
|
||||||
}: ClosingProductionDataTabContentProps) => {
|
}: ClosingProductionDataTabContentProps) => {
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const kandangId = searchParams.get('kandangId');
|
||||||
|
|
||||||
const { data: productionData, isLoading } = useSWR(
|
const { data: productionData, isLoading } = useSWR(
|
||||||
`${ClosingApi.basePath}/${projectFlockId}/production-data`,
|
`${ClosingApi.basePath}/${projectFlockId}/production-data?kandang_id=${kandangId ? `${kandangId}` : ''}`,
|
||||||
() => ClosingApi.getProductionData(projectFlockId)
|
() => ClosingApi.getProductionData(projectFlockId, Number(kandangId))
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@@ -91,10 +91,11 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getProductionData(
|
async getProductionData(
|
||||||
id: number
|
id: number,
|
||||||
|
kandangId?: number
|
||||||
): Promise<BaseApiResponse<ClosingProductionData> | undefined> {
|
): Promise<BaseApiResponse<ClosingProductionData> | undefined> {
|
||||||
try {
|
try {
|
||||||
const getProductionDataPath = `${this.basePath}/${id}/production-data`;
|
const getProductionDataPath = `${this.basePath}/${id}/production-data?kandang_id=${kandangId ? `${kandangId}` : ''}`;
|
||||||
const getProductionDataRes = await httpClient<
|
const getProductionDataRes = await httpClient<
|
||||||
BaseApiResponse<ClosingProductionData>
|
BaseApiResponse<ClosingProductionData>
|
||||||
>(getProductionDataPath);
|
>(getProductionDataPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user