Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: bom item highlighting for Buy and Pick types

Sidwebworksf34462c4ed95
diff --git a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
index 901ba2c49f..d2e65bf381 100644
--- a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
@@ -19,11 +19,10 @@ import {
InputGroup,
InputLeftElement,
useDisclosure,
- useMount,
VStack
} from "@carbon/react";
import { useOptimisticLocation } from "@carbon/remix";
-import { useRef, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import {
LuBraces,
LuChevronDown,
@@ -113,7 +112,7 @@ const BoMExplorer = ({
if (!methodId) throw new Error("methodId not found");
const [selectedMaterialId, setSelectedMaterialId] = useBom();
- useMount(() => {
+ useEffect(() => {
if (selectedMaterialId) {
const node = methods.find(
(m) => m.data.methodMaterialId === selectedMaterialId
@@ -129,7 +128,7 @@ const BoMExplorer = ({
selectNode(node.id);
}
}
- });
+ }, [selectedMaterialId, params.makeMethodId, methods, selectNode]);
const importBomDisclosure = useDisclosure();
@@ -259,12 +258,25 @@ const BoMExplorer = ({
<div
key={node.id}
className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2 gap-1 group/node",
+ "flex h-8 items-center overflow-hidden rounded-sm pr-2 gap-1 group/node",
+ node.data.methodType !== "Pick" &&
+ node.data.methodType !== "Buy" &&
+ "cursor-pointer",
state.selected
? "bg-muted hover:bg-muted/90"
- : "bg-transparent hover:bg-muted/90"
+ : node.data.methodType !== "Pick" &&
+ node.data.methodType !== "Buy"
+ ? "bg-transparent hover:bg-muted/90"
+ : "bg-transparent"
)}
onClick={() => {
+ // Buy and Pick items are not clickable
+ if (
+ node.data.methodType === "Buy" ||
+ node.data.methodType === "Pick"
+ ) {
+ return;
+ }
selectNode(node.id);
setSelectedMaterialId(node.data.methodMaterialId);
if (node.data.isRoot) {
@@ -307,7 +319,10 @@ const BoMExplorer = ({
<div
className={cn(
"flex h-8 w-4 items-center",
- node.hasChildren && "hover:bg-accent"
+ node.hasChildren &&
+ node.data.methodType !== "Pick" &&
+ node.data.methodType !== "Buy" &&
+ "hover:bg-accent"
)}
onClick={(e) => {
e.stopPropagation();
@@ -323,7 +338,9 @@ const BoMExplorer = ({
scrollToNode(node.id);
}}
>
- {node.hasChildren ? (
+ {node.hasChildren &&
+ node.data.methodType !== "Pick" &&
+ node.data.methodType !== "Buy" ? (
state.expanded ? (
<LuChevronDown className="h-4 w-4 text-gray-400 flex-shrink-0 ml-1" />
) : (