From 4a9cbdc219573dd4a4889014ceea222ff45a4bb0 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 15 Jan 2026 16:41:24 +0700 Subject: [PATCH] refactor(FE): Use initialValues total_chick_qty for edit/detail --- .../production/recording/form/RecordingForm.tsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 32c8c4c6..5312c0be 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -729,17 +729,8 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return projectFlockKandangLookup.available_quantity || null; } - if ((type === 'edit' || type === 'detail') && projectFlockKandangDetail) { - if ( - projectFlockKandangDetail.available_qtys && - projectFlockKandangDetail.available_qtys.length > 0 - ) { - return projectFlockKandangDetail.available_qtys.reduce( - (sum, item) => sum + (item.available_qty || 0), - 0 - ); - } - return null; + if ((type === 'edit' || type === 'detail') && initialValues) { + return initialValues.project_flock?.total_chick_qty || null; } if (!isResponseSuccess(existingRecordings) || !selectedKandang) { @@ -765,6 +756,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return recording?.project_flock.total_chick_qty || null; }, [ type, + initialValues, existingRecordings, selectedKandang, projectFlockKandangLookup,