mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
refactor(FE-114): improve product filtering logic for location and flag validation
This commit is contained in:
@@ -205,11 +205,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
return pakanProducts.data.filter((product) => {
|
return pakanProducts.data.filter((product) => {
|
||||||
const warehouse = product.warehouse;
|
const warehouse = product.warehouse;
|
||||||
|
|
||||||
if ('location' in warehouse && warehouse.location) {
|
const hasLocationMatch =
|
||||||
return warehouse.location.id === formik.values.location_id;
|
'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]);
|
}, [pakanProducts, formik.values.location_id]);
|
||||||
|
|
||||||
@@ -237,11 +240,16 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
return ovkProducts.data.filter((product) => {
|
return ovkProducts.data.filter((product) => {
|
||||||
const warehouse = product.warehouse;
|
const warehouse = product.warehouse;
|
||||||
|
|
||||||
if ('location' in warehouse && warehouse.location) {
|
// Validate location match
|
||||||
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;
|
// Validate product has OVK flag
|
||||||
|
const hasOvkFlag = product.product.flags?.includes('OVK');
|
||||||
|
|
||||||
|
return hasLocationMatch && hasOvkFlag;
|
||||||
});
|
});
|
||||||
}, [ovkProducts, formik.values.location_id]);
|
}, [ovkProducts, formik.values.location_id]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user