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.

refactor: remove makeMethodId from item method routes

Brad Barbinc6676c1a025e
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
index c85156a7c5..e597e74e26 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -165,7 +165,7 @@ const BillOfMaterial = ({
fetcher.submit(new FormData(), {
method: "post",
- action: path.to.deleteMethodMaterial(makeMethodId, item.id),
+ action: path.to.deleteMethodMaterial(item.id),
});
};
@@ -193,7 +193,7 @@ const BillOfMaterial = ({
formData.append("updates", JSON.stringify(updates));
fetcher.submit(formData, {
method: "post",
- action: path.to.methodMaterialsOrder(makeMethodId),
+ action: path.to.methodMaterialsOrder,
});
}, 1000);
@@ -477,8 +477,8 @@ function MaterialForm({
<ValidatedForm
action={
isTemporaryId(item.id)
- ? path.to.newMethodMaterial(item.data.makeMethodId!)
- : path.to.methodMaterial(item.data.makeMethodId, item.id!)
+ ? path.to.newMethodMaterial
+ : path.to.methodMaterial(item.id!)
}
method="post"
defaultValues={item.data}
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
index 4d0d5ef42d..011f5284a2 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -184,7 +184,7 @@ const BillOfProcess = ({ makeMethodId, operations }: BillOfProcessProps) => {
formData.append("updates", JSON.stringify(updates));
sortOrderFetcher.submit(formData, {
method: "post",
- action: path.to.methodOperationsOrder(makeMethodId),
+ action: path.to.methodOperationsOrder,
});
}, 1000);
@@ -548,8 +548,8 @@ function OperationForm({
<ValidatedForm
action={
isTemporaryId(item.id)
- ? path.to.newMethodOperation(item.data.makeMethodId!)
- : path.to.methodOperation(item.data.makeMethodId, item.id!)
+ ? path.to.newMethodOperation
+ : path.to.methodOperation(item.id!)
}
method="post"
defaultValues={item.data}
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.$id.tsx b/apps/carbon/app/routes/x+/items+/methods.material.$id.tsx
similarity index 93%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.$id.tsx
rename to apps/carbon/app/routes/x+/items+/methods.material.$id.tsx
index 0ab7c8df5a..f1dc17d262 100644
--- a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.$id.tsx
+++ b/apps/carbon/app/routes/x+/items+/methods.material.$id.tsx
@@ -13,10 +13,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
create: "parts",
});
- const { makeMethodId, id } = params;
- if (!makeMethodId) {
- throw new Error("makeMethodId not found");
- }
+ const { id } = params;
if (!id) {
throw new Error("id not found");
}
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.delete.$id.tsx b/apps/carbon/app/routes/x+/items+/methods.material.delete.$id.tsx
similarity index 88%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.delete.$id.tsx
rename to apps/carbon/app/routes/x+/items+/methods.material.delete.$id.tsx
index bfe8afe575..18bcde80fe 100644
--- a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.delete.$id.tsx
+++ b/apps/carbon/app/routes/x+/items+/methods.material.delete.$id.tsx
@@ -11,10 +11,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
delete: "parts",
});
- const { makeMethodId, id } = params;
- if (!makeMethodId) {
- throw new Error("makeMethodId not found");
- }
+ const { id } = params;
if (!id) {
throw new Error("id not found");
}
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.new.tsx b/apps/carbon/app/routes/x+/items+/methods.material.new.tsx
similarity index 93%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.new.tsx
rename to apps/carbon/app/routes/x+/items+/methods.material.new.tsx
index 92d83240b0..455f8f2ae0 100644
--- a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.new.tsx
+++ b/apps/carbon/app/routes/x+/items+/methods.material.new.tsx
@@ -13,11 +13,6 @@ export async function action({ request, params }: ActionFunctionArgs) {
create: "parts",
});
- const { makeMethodId } = params;
- if (!makeMethodId) {
- throw new Error("makeMethodId not found");
- }
-
const formData = await request.formData();
const validation = await validator(methodMaterialValidator).validate(
formData
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.order.tsx b/apps/carbon/app/routes/x+/items+/methods.material.order.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.material.order.tsx
rename to apps/carbon/app/routes/x+/items+/methods.material.order.tsx
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.$id.tsx b/apps/carbon/app/routes/x+/items+/methods.operation.$id.tsx
similarity index 93%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.$id.tsx
rename to apps/carbon/app/routes/x+/items+/methods.operation.$id.tsx
index ff49ed5cf3..b0269716f7 100644
--- a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.$id.tsx
+++ b/apps/carbon/app/routes/x+/items+/methods.operation.$id.tsx
@@ -16,10 +16,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
create: "parts",
});
- const { makeMethodId, id } = params;
- if (!makeMethodId) {
- throw new Error("makeMethodId not found");
- }
+ const { id } = params;
if (!id) {
throw new Error("id not found");
}
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.new.tsx b/apps/carbon/app/routes/x+/items+/methods.operation.new.tsx
similarity index 93%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.new.tsx
rename to apps/carbon/app/routes/x+/items+/methods.operation.new.tsx
index 21c59f290d..77c4549aed 100644
--- a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.new.tsx
+++ b/apps/carbon/app/routes/x+/items+/methods.operation.new.tsx
@@ -16,11 +16,6 @@ export async function action({ request, params }: ActionFunctionArgs) {
create: "parts",
});
- const { makeMethodId } = params;
- if (!makeMethodId) {
- throw new Error("makeMethodId not found");
- }
-
const formData = await request.formData();
const validation = await validator(methodOperationValidator).validate(
formData
diff --git a/apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.order.tsx b/apps/carbon/app/routes/x+/items+/methods.operation.order.tsx
similarity index 100%
rename from apps/carbon/app/routes/x+/items+/methods.$makeMethodId.operation.order.tsx
rename to apps/carbon/app/routes/x+/items+/methods.operation.order.tsx
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 6516084186..31ae753387 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -215,8 +215,8 @@ export const path = {
generatePath(`${x}/items/forms/delete/${id}`),
deleteMaterialSubstance: (id: string) =>
generatePath(`${x}/items/substances/delete/${id}`),
- deleteMethodMaterial: (makeMethodId: string, id: string) =>
- generatePath(`${x}/items/methods/${makeMethodId}/material/delete/${id}`),
+ deleteMethodMaterial: (id: string) =>
+ generatePath(`${x}/items/methods/material/delete/${id}`),
deleteNote: (id: string) => generatePath(`${x}/shared/notes/${id}/delete`),
deletePartner: (id: string) =>
generatePath(`${x}/resources/partners/delete/${id}`),
@@ -371,14 +371,12 @@ export const path = {
materialSubstance: (id: string) =>
generatePath(`${x}/items/substances/${id}`),
materialSubstances: `${x}/items/substances`,
- methodMaterial: (makeMethodId: string, id: string) =>
- generatePath(`${x}/items/methods/${makeMethodId}/material/${id}`),
- methodMaterialsOrder: (makeMethodId: string) =>
- generatePath(`${x}/items/methods/${makeMethodId}/material/order`),
- methodOperation: (makeMethodId: string, id: string) =>
- generatePath(`${x}/items/methods/${makeMethodId}/operation/${id}`),
- methodOperationsOrder: (makeMethodId: string) =>
- generatePath(`${x}/items/methods/${makeMethodId}/operation/order`),
+ methodMaterial: (id: string) =>
+ generatePath(`${x}/items/methods/material/${id}`),
+ methodMaterialsOrder: `${x}/items/methods/material/order`,
+ methodOperation: (id: string) =>
+ generatePath(`${x}/items/methods/operation/${id}`),
+ methodOperationsOrder: `${x}/items/methods/operation/order`,
newAbility: `${x}/resources/abilities/new`,
newAccountingCategory: `${x}/accounting/categories/new`,
newAccountingSubcategory: (id: string) =>
@@ -421,10 +419,8 @@ export const path = {
newHoliday: `${x}/resources/holidays/new`,
newLocation: `${x}/resources/locations/new`,
newMaterial: `${x}/material/new`,
- newMethodMaterial: (id: string) =>
- generatePath(`${x}/items/methods/${id}/material/new`),
- newMethodOperation: (id: string) =>
- generatePath(`${x}/items/methods/${id}/operation/new`),
+ newMethodMaterial: `${x}/items/methods/material/new`,
+ newMethodOperation: `${x}/items/methods/operation/new`,
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
newItemPostingGroup: `${x}/items/groups/new`,