mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Filter out excluded product flags in product options
This commit is contained in:
@@ -203,14 +203,20 @@ const InventoryAdjustmentForm = ({
|
||||
);
|
||||
|
||||
const productOptions = useMemo(() => {
|
||||
return isResponseSuccess(productWarehouses)
|
||||
? productWarehouses.data.map((pw) => ({
|
||||
value: pw.product.id,
|
||||
label: pw.product.name,
|
||||
quantity: pw.quantity,
|
||||
flags: pw.product.flags,
|
||||
}))
|
||||
: [];
|
||||
if (!isResponseSuccess(productWarehouses)) return [];
|
||||
|
||||
const excludedFlags = ['AYAM-AFKIR', 'AYAM-CULLING', 'AYAM-MATI'];
|
||||
const filteredProducts = productWarehouses.data.filter((pw) => {
|
||||
const productFlags = (pw.product.flags as string[]) || [];
|
||||
return !productFlags.some((flag) => excludedFlags.includes(flag));
|
||||
});
|
||||
|
||||
return filteredProducts.map((pw) => ({
|
||||
value: pw.product.id,
|
||||
label: pw.product.name,
|
||||
quantity: pw.quantity,
|
||||
flags: pw.product.flags,
|
||||
}));
|
||||
}, [productWarehouses]);
|
||||
|
||||
const selectedProductQuantity = useMemo(() => {
|
||||
@@ -340,11 +346,7 @@ const InventoryAdjustmentForm = ({
|
||||
flag.startsWith('TELUR')
|
||||
);
|
||||
const isChickenProduct = selectedProductFlags.some(
|
||||
(flag) =>
|
||||
flag.startsWith('AYAM') ||
|
||||
flag === 'DOC' ||
|
||||
flag === 'PULLET' ||
|
||||
flag === 'LAYER'
|
||||
(flag) => flag === 'AYAM' || flag === 'DOC'
|
||||
);
|
||||
|
||||
if (isEggProduct) {
|
||||
@@ -852,7 +854,7 @@ const InventoryAdjustmentForm = ({
|
||||
readOnly={type === 'detail'}
|
||||
bottomLabel={
|
||||
selectedProduct
|
||||
? `Kuantitas: ${formatNumber(selectedProductQuantity)}`
|
||||
? `Tersedia: ${formatNumber(selectedProductQuantity)}`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user