refactor(FE): Use initialValues total_chick_qty for edit/detail

This commit is contained in:
rstubryan
2026-01-15 16:41:24 +07:00
parent 76c1b2f628
commit 4a9cbdc219
@@ -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,