diff --git a/src/components/pages/flock/recording/form/RecordingForm.tsx b/src/components/pages/flock/recording/form/RecordingForm.tsx index 42edc1ca..e97b0377 100644 --- a/src/components/pages/flock/recording/form/RecordingForm.tsx +++ b/src/components/pages/flock/recording/form/RecordingForm.tsx @@ -205,11 +205,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return pakanProducts.data.filter((product) => { const warehouse = product.warehouse; - if ('location' in warehouse && warehouse.location) { - return warehouse.location.id === formik.values.location_id; - } + const hasLocationMatch = + 'location' in warehouse && warehouse.location + ? warehouse.location.id === formik.values.location_id + : false; - return false; + const hasPakanFlag = product.product.flags?.includes('PAKAN'); + + return hasLocationMatch && hasPakanFlag; }); }, [pakanProducts, formik.values.location_id]); @@ -237,11 +240,16 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { return ovkProducts.data.filter((product) => { const warehouse = product.warehouse; - if ('location' in warehouse && warehouse.location) { - return warehouse.location.id === formik.values.location_id; - } + // Validate location match + const hasLocationMatch = + 'location' in warehouse && warehouse.location + ? warehouse.location.id === formik.values.location_id + : false; - return false; + // Validate product has OVK flag + const hasOvkFlag = product.product.flags?.includes('OVK'); + + return hasLocationMatch && hasOvkFlag; }); }, [ovkProducts, formik.values.location_id]);