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
@@ -22,7 +22,6 @@ import HppExpeditionReportTable from './hpp-ekspedisi/HppExpeditionReportTable';
import ClosingKandangList from '@/components/pages/closing/ClosingKandangList';
import { ProjectFlock } from '@/types/api/production/project-flock';
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
interface ClosingDetailProps {
id: number;
initialValue?: ClosingGeneralInformation;
@@ -56,7 +55,6 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
<ClosingSapronakCalculationTabContent
closingGeneralInformation={initialValue}
projectFlockId={id}
projectKandangId={kandangData?.id}
/>
),
},
@@ -5,13 +5,11 @@ import { ClosingGeneralInformation } from '@/types/api/closing';
interface ClosingSapronakCalculationTabContentProps {
projectFlockId?: number;
projectKandangId?: number;
closingGeneralInformation?: ClosingGeneralInformation;
}
const ClosingSapronakCalculationTabContent = ({
projectFlockId,
projectKandangId,
closingGeneralInformation,
}: ClosingSapronakCalculationTabContentProps) => {
return (
@@ -21,7 +19,6 @@ const ClosingSapronakCalculationTabContent = ({
<ClosingSapronakCalculationTable
closingGeneralInformation={closingGeneralInformation}
projectFlockId={projectFlockId}
projectKandangId={projectKandangId}
/>
</>
)}
@@ -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'
}
+1
View File
@@ -63,6 +63,7 @@ export type BaseClosing = {
location_id: number;
location_name: string;
project_category: 'GROWING' | 'LAYING';
project_type?: 'GROWING' | 'LAYING'; // berubah dari BE?
period: number;
closing_date?: string;
shed_label: string;