mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +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(() => {
|
const productOptions = useMemo(() => {
|
||||||
return isResponseSuccess(productWarehouses)
|
if (!isResponseSuccess(productWarehouses)) return [];
|
||||||
? productWarehouses.data.map((pw) => ({
|
|
||||||
value: pw.product.id,
|
const excludedFlags = ['AYAM-AFKIR', 'AYAM-CULLING', 'AYAM-MATI'];
|
||||||
label: pw.product.name,
|
const filteredProducts = productWarehouses.data.filter((pw) => {
|
||||||
quantity: pw.quantity,
|
const productFlags = (pw.product.flags as string[]) || [];
|
||||||
flags: pw.product.flags,
|
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]);
|
}, [productWarehouses]);
|
||||||
|
|
||||||
const selectedProductQuantity = useMemo(() => {
|
const selectedProductQuantity = useMemo(() => {
|
||||||
@@ -340,11 +346,7 @@ const InventoryAdjustmentForm = ({
|
|||||||
flag.startsWith('TELUR')
|
flag.startsWith('TELUR')
|
||||||
);
|
);
|
||||||
const isChickenProduct = selectedProductFlags.some(
|
const isChickenProduct = selectedProductFlags.some(
|
||||||
(flag) =>
|
(flag) => flag === 'AYAM' || flag === 'DOC'
|
||||||
flag.startsWith('AYAM') ||
|
|
||||||
flag === 'DOC' ||
|
|
||||||
flag === 'PULLET' ||
|
|
||||||
flag === 'LAYER'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isEggProduct) {
|
if (isEggProduct) {
|
||||||
@@ -852,7 +854,7 @@ const InventoryAdjustmentForm = ({
|
|||||||
readOnly={type === 'detail'}
|
readOnly={type === 'detail'}
|
||||||
bottomLabel={
|
bottomLabel={
|
||||||
selectedProduct
|
selectedProduct
|
||||||
? `Kuantitas: ${formatNumber(selectedProductQuantity)}`
|
? `Tersedia: ${formatNumber(selectedProductQuantity)}`
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user