fix(FE): fixing sapronak calculation get kandangId state

This commit is contained in:
randy-ar
2026-01-12 15:38:07 +07:00
parent 36b167dafb
commit 0f9849c0ac
4 changed files with 8 additions and 10 deletions
@@ -14,21 +14,23 @@ import useSWR from 'swr';
import { ClosingApi } from '@/services/api/closing';
import { isResponseSuccess } from '@/lib/api-helper';
import { ClosingGeneralInformation } from '@/types/api/closing';
import { useSearchParams } from 'next/navigation';
interface ClosingSapronakCalculationTableProps {
projectFlockId: number;
projectKandangId?: number;
closingGeneralInformation?: ClosingGeneralInformation;
}
const ClosingSapronakCalculationTable = ({
projectFlockId,
closingGeneralInformation,
projectKandangId,
}: ClosingSapronakCalculationTableProps) => {
const searchParams = useSearchParams();
const kandangId = searchParams.get('kandangId');
const { data: sapronakCalculation, isLoading } = useSWR(
`/closing/sapronak-calculation/${projectFlockId}${projectKandangId ? `/${projectKandangId}` : ''}`,
() => ClosingApi.getPerhitunganSapronak(projectFlockId, projectKandangId),
`/closing/sapronak-calculation/${projectFlockId}${kandangId ? `/${kandangId}` : ''}`,
() => ClosingApi.getPerhitunganSapronak(projectFlockId, Number(kandangId)),
{
keepPreviousData: true,
}
@@ -180,7 +182,7 @@ const ClosingSapronakCalculationTable = ({
{/* Table DOC jika kategori Project Flock Growing */}
<Card
title={
closingGeneralInformation?.project_category === 'GROWING'
closingGeneralInformation?.project_type == 'GROWING'
? 'DOC'
: 'Pullet'
}