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: don't navigate to the same path

Brad Barbin2d3fe34624f0
diff --git a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
index 107d0b0d3d..4b99b86a04 100644
--- a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
@@ -12,6 +12,7 @@ import {
cn,
useMount,
} from "@carbon/react";
+import { useOptimisticLocation } from "@carbon/remix";
import { useNavigate, useParams } from "@remix-run/react";
import { useRef, useState } from "react";
import { LuChevronDown, LuChevronRight, LuSearch } from "react-icons/lu";
@@ -79,6 +80,7 @@ const BoMExplorer = ({
});
const navigate = useNavigate();
+ const location = useOptimisticLocation();
const { itemId } = params;
if (!itemId) throw new Error("itemId not found");
@@ -141,15 +143,26 @@ const BoMExplorer = ({
selectNode(node.id);
setSelectedMaterialId(node.data.methodMaterialId);
if (node.data.isRoot) {
- navigate(getRootLink(itemType, itemId));
+ if (location.pathname !== getRootLink(itemType, itemId)) {
+ navigate(getRootLink(itemType, itemId));
+ }
} else {
- navigate(
+ if (
+ location.pathname !==
getMaterialLink(
itemType,
itemId,
node.data.makeMethodId
)
- );
+ ) {
+ navigate(
+ getMaterialLink(
+ itemType,
+ itemId,
+ node.data.makeMethodId
+ )
+ );
+ }
}
}}
>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
index fd5191e1d6..ce3fbc234f 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBoMExplorer.tsx
@@ -140,7 +140,9 @@ const JobBoMExplorer = ({ method }: JobBoMExplorerProps) => {
onClick={(e) => {
selectNode(node.id);
setSelectedMaterialId(node.data.methodMaterialId);
- navigate(getNodePath(node));
+ if (location.pathname !== getNodePath(node)) {
+ navigate(getNodePath(node));
+ }
}}
>
<div className="flex h-8 items-center">
@@ -303,9 +305,5 @@ function NodePreview({ node }: { node: FlatTreeItem<JobMethod> }) {
function getNodePath(node: FlatTreeItem<JobMethod>) {
return node.data.isRoot
? path.to.jobMethod(node.data.jobId, node.data.jobMaterialMakeMethodId)
- : path.to.jobMakeMethod(
- node.data.jobId,
- node.data.jobMakeMethodId,
- node.data.methodMaterialId
- );
+ : path.to.jobMakeMethod(node.data.jobId, node.data.jobMakeMethodId);
}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
index 8bec499332..9eb2a090b2 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
@@ -148,7 +148,9 @@ const QuoteBoMExplorer = ({
onClick={(e) => {
selectNode(node.id);
setSelectedMaterialId(node.data.methodMaterialId);
- navigate(getNodePath(node), { replace: true });
+ if (location.pathname !== getNodePath(node)) {
+ navigate(getNodePath(node), { replace: true });
+ }
}}
>
<div className="flex h-8 items-center">
@@ -318,7 +320,6 @@ function getNodePath(node: FlatTreeItem<QuoteMethod>) {
: path.to.quoteLineMakeMethod(
node.data.quoteId,
node.data.quoteLineId,
- node.data.quoteMakeMethodId,
- node.data.methodMaterialId
+ node.data.quoteMakeMethodId
);
}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 0c358a7d83..936e58fc55 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -896,14 +896,8 @@ export const path = {
quoteLineMakeMethod: (
quoteId: string,
lineId: string,
- makeMethodId: string,
- materialId?: string
- ) =>
- generatePath(
- `${x}/quote/${quoteId}/${lineId}/make/${makeMethodId}${
- materialId ? `?materialId=${materialId}` : ""
- }`
- ),
+ makeMethodId: string
+ ) => generatePath(`${x}/quote/${quoteId}/${lineId}/make/${makeMethodId}`),
quoteLineMethod: (quoteId: string, quoteLineId: string, methodId: string) =>
generatePath(`${x}/quote/${quoteId}/${quoteLineId}/method/${methodId}`),
quoteLinePriceUpdate: (quoteId: string, lineId: string) =>