mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
codex: initiated changes
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
import { Warehouse } from '@/types/api/master-data/warehouse';
|
||||
|
||||
export const getWarehouseScopeLabel = (
|
||||
warehouse?: Warehouse | null
|
||||
): string => {
|
||||
if (!warehouse) {
|
||||
return 'Gudang';
|
||||
}
|
||||
|
||||
if (warehouse.type === 'KANDANG') {
|
||||
return warehouse.kandang?.name
|
||||
? `Kandang ${warehouse.kandang.name}`
|
||||
: 'Gudang Kandang';
|
||||
}
|
||||
|
||||
if (warehouse.type === 'LOKASI') {
|
||||
return 'Gudang Farm';
|
||||
}
|
||||
|
||||
return 'Gudang Area';
|
||||
};
|
||||
|
||||
export const getProductWarehouseOptionLabel = (
|
||||
productWarehouse?: ProductWarehouse | null
|
||||
): string => {
|
||||
if (!productWarehouse) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const productName = productWarehouse.product?.name || 'Produk';
|
||||
const warehouseName = productWarehouse.warehouse?.name || 'Gudang';
|
||||
const warehouseScope = getWarehouseScopeLabel(productWarehouse.warehouse);
|
||||
|
||||
return `${productName} • ${warehouseName} (${warehouseScope})`;
|
||||
};
|
||||
|
||||
export const isProductWarehouseSelectableForKandang = (
|
||||
productWarehouse: ProductWarehouse,
|
||||
kandangId?: number | null
|
||||
): boolean => {
|
||||
const warehouse = productWarehouse.warehouse;
|
||||
|
||||
if (!warehouse) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (warehouse.type === 'LOKASI') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (warehouse.type === 'KANDANG') {
|
||||
return Boolean(kandangId) && warehouse.kandang?.id === kandangId;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user