diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 4f9018fc..66164faa 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -570,6 +570,33 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return recordedIds; }, [existingRecordings, today]); + const currentTotalChickQty = useMemo(() => { + if (!isResponseSuccess(existingRecordings) || !selectedKandang) return null; + + let projectFlockKandangId: number | undefined; + + if (projectFlockKandangLookup) { + projectFlockKandangId = + projectFlockKandangLookup.project_flock_kandang_id; + } else if (projectFlockKandangDetail) { + projectFlockKandangId = projectFlockKandangDetail.id; + } + + if (!projectFlockKandangId) return null; + + const recording = existingRecordings.data.find( + (rec) => + rec.project_flock.project_flock_kandang_id === projectFlockKandangId + ); + + return recording?.project_flock.total_chick_qty || null; + }, [ + existingRecordings, + selectedKandang, + projectFlockKandangLookup, + projectFlockKandangDetail, + ]); + const unifiedStockProducts = useMemo(() => { const options: OptionType[] = []; if (isResponseSuccess(stockProducts) && selectedKandang) { @@ -1436,6 +1463,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { ? getProjectFlockBadgeAdornment() : undefined } + bottomLabel={ + currentTotalChickQty + ? `Jumlah ayam saat ini: ${formatNumber( + currentTotalChickQty + )}` + : undefined + } />