mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +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) => {
|
||||
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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user