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.

feat: add tags to quote bop and method bop

Brad Barbinf8323340ad35
diff --git a/.env.example b/.env.example
index 52900df897..1097c3c74c 100644
--- a/.env.example
+++ b/.env.example
@@ -1,5 +1,8 @@
NOVU_APPLICATION_ID="********************"
NOVU_SECRET_KEY="********************"
+
+ONSHAPE_SECRET_KEY="********************"
+
POSTHOG_API_HOST="https://us.posthog.com"
POSTHOG_PROJECT_PUBLIC_KEY="********************"
diff --git a/apps/erp/app/components/Form/Item.tsx b/apps/erp/app/components/Form/Item.tsx
index 8dfcf2c599..e1cc417c9f 100644
--- a/apps/erp/app/components/Form/Item.tsx
+++ b/apps/erp/app/components/Form/Item.tsx
@@ -209,7 +209,7 @@ const Item = ({
"absolute right-0 top-0",
props.inline === true
? "ml-1"
- : "bg-transparent flex-shrink-0 h-10 w-10 px-3 rounded-l-none before:rounded-l-none !border-l-0 border -ml-px shadow-none hover:shadow-button-base"
+ : "bg-card flex-shrink-0 h-10 w-10 px-3 rounded-l-none before:rounded-l-none border -ml-px shadow-none hover:shadow-button-base"
)}
disabled={props.isReadOnly}
variant="secondary"
diff --git a/apps/erp/app/components/SortableList.tsx b/apps/erp/app/components/SortableList.tsx
index 21131e13cb..f732b83ba3 100644
--- a/apps/erp/app/components/SortableList.tsx
+++ b/apps/erp/app/components/SortableList.tsx
@@ -68,7 +68,7 @@ function SortableListItem<T>({
value={item}
className={cn(
"relative z-auto grow",
- "h-full rounded-md bg-muted/30 py-2",
+ "h-full rounded-md bg-muted/30",
"border border-border rounded-lg",
item.checked ? "cursor-not-allowed" : "cursor-grab",
item.checked && !isDragging ? "w-7/10" : "w-full"
@@ -163,7 +163,7 @@ function SortableListItem<T>({
{renderExtra && renderExtra(item)}
</motion.div>
{item.footer && (
- <div className="flex w-full items-center border-t border-border px-3 pt-3 pb-1">
+ <div className="flex w-full items-center border-t border-border px-3 py-2">
{item.footer}
</div>
)}
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index 6352095c28..2f31552d03 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -44,7 +44,7 @@ import {
LuTriangleAlert,
LuX,
} from "react-icons/lu";
-import type { z } from "zod";
+import { z } from "zod";
import { DirectionAwareTabs, EmployeeAvatar, TimeTypeIcon } from "~/components";
import {
Hidden,
@@ -57,6 +57,7 @@ import {
StandardFactor,
Submit,
SupplierProcess,
+ Tags,
Tool,
UnitHint,
WorkCenter,
@@ -65,11 +66,14 @@ import {
import { flushSync } from "react-dom";
import { ConfigurationEditor } from "~/components/Configurator/ConfigurationEditor";
import type { Configuration } from "~/components/Configurator/types";
+
import { getUnitHint } from "~/components/Form/UnitHint";
import { ConfirmDelete } from "~/components/Modals";
import type { Item, SortableItemRenderProps } from "~/components/SortableList";
import { SortableList, SortableListItem } from "~/components/SortableList";
import { usePermissions, useUser } from "~/hooks";
+import { useTags } from "~/hooks/useTags";
+
import type { OperationTool } from "~/modules/shared";
import {
methodOperationOrders,
@@ -86,6 +90,7 @@ import type { ConfigurationParameter, ConfigurationRule } from "../../types";
type Operation = z.infer<typeof methodOperationValidator> & {
workInstruction: JSONContent | null;
+ tags: string[];
};
type OperationWithTools = Operation & {
@@ -102,6 +107,7 @@ type BillOfProcessProps = {
makeMethodId: string;
operations: OperationWithTools[];
parameters?: ConfigurationParameter[];
+ tags: { name: string }[];
};
type PendingWorkInstructions = {
@@ -131,6 +137,7 @@ const initialOperation: Omit<Operation, "makeMethodId" | "order" | "tools"> = {
processId: "",
setupTime: 0,
setupUnit: "Total Minutes",
+ tags: [],
workCenterId: "",
workInstruction: {},
};
@@ -141,6 +148,7 @@ const BillOfProcess = ({
makeMethodId,
operations: initialOperations,
parameters,
+ tags,
}: BillOfProcessProps) => {
const permissions = usePermissions();
const { carbon } = useCarbon();
@@ -187,6 +195,7 @@ const BillOfProcess = ({
...pendingOperation,
workInstruction: {},
methodOperationTool: [],
+ tags: [],
});
return;
}
@@ -200,6 +209,7 @@ const BillOfProcess = ({
workInstruction: workInstructions[pendingOperation.id] || null,
order: orderState[pendingOperation.id] ?? pendingOperation.order,
methodOperationTool: [],
+ tags: [],
});
});
@@ -217,7 +227,7 @@ const BillOfProcess = ({
(a, b) => (orderState[a.id!] ?? a.order) - (orderState[b.id!] ?? b.order)
);
- const items = makeItems(operations).map((item) => ({
+ const items = makeItems(operations, tags).map((item) => ({
...item,
checked: checkedState[item.id] ?? false,
}));
@@ -1552,11 +1562,17 @@ function ToolsForm({
);
}
-function makeItems(operations: Operation[]): ItemWithData[] {
- return operations.map(makeItem);
+function makeItems(
+ operations: Operation[],
+ tags: { name: string }[]
+): ItemWithData[] {
+ return operations.map((operation) => makeItem(operation, tags));
}
-function makeItem(operation: Operation): ItemWithData {
+function makeItem(
+ operation: Operation,
+ tags: { name: string }[]
+): ItemWithData {
return {
id: operation.id!,
title: <h3 className="font-semibold truncate">{operation.description}</h3>,
@@ -1590,6 +1606,11 @@ function makeItem(operation: Operation): ItemWithData {
)}
</HStack>
),
+ footer: isTemporaryId(operation.id ?? "") ? null : (
+ <HStack className="w-full justify-end">
+ <MethodOperationTags operation={operation} availableTags={tags} />
+ </HStack>
+ ),
data: operation,
};
}
@@ -1623,3 +1644,36 @@ function usePendingOperations() {
function getFieldKey(field: string, operationId: string) {
return `${field}:${operationId}`;
}
+export function MethodOperationTags({
+ operation,
+ availableTags,
+}: {
+ operation: Operation;
+ availableTags: { name: string }[];
+}) {
+ const { onUpdateTags } = useTags({
+ id: operation.id,
+ table: "methodOperation",
+ });
+
+ return (
+ <ValidatedForm
+ defaultValues={{
+ tags: operation.tags ?? [],
+ }}
+ validator={z.object({
+ tags: z.array(z.string()).optional(),
+ })}
+ >
+ <Tags
+ availableTags={availableTags}
+ label=""
+ name="tags"
+ table="operation"
+ inline
+ maxPreview={3}
+ onChange={onUpdateTags}
+ />
+ </ValidatedForm>
+ );
+}
diff --git a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
index 1ca6a71692..943fec6290 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
@@ -180,3 +180,14 @@ export function getLinkToItemDetails(type: MethodItemType, id: string) {
throw new Error("Invalid type");
}
}
+
+export function getLinkToItemManufacturing(type: MethodItemType, id: string) {
+ switch (type) {
+ case "Part":
+ return path.to.partManufacturing(id);
+ case "Tool":
+ return path.to.toolManufacturing(id);
+ default:
+ return getLinkToItemDetails(type, id);
+ }
+}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index 3896917323..522557b2d3 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -102,7 +102,7 @@ import { jobOperationValidator } from "../../production.models";
import { getProductionEventsPage } from "../../production.service";
import type { Job, JobOperation } from "../../types";
-type Operation = z.infer<typeof jobOperationValidator> & {
+export type Operation = z.infer<typeof jobOperationValidator> & {
assignee: string | null;
status: JobOperation["status"];
tags: string[] | null;
@@ -173,7 +173,7 @@ function makeItem(
</HStack>
),
footer: isTemporaryId(operation.id ?? "") ? null : (
- <HStack>
+ <HStack className="w-full justify-between">
<Assignee
table="jobOperation"
id={operation.id!}
@@ -2054,13 +2054,13 @@ function JobOperationTags({
validator={z.object({
tags: z.array(z.string()).optional(),
})}
- className="w-full"
>
<Tags
availableTags={availableTags}
label=""
name="tags"
table="operation"
+ maxPreview={3}
inline
onChange={onUpdateTags}
/>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
index 506c44494a..ad13aa8031 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
@@ -55,7 +55,7 @@ import type {
ConfigurationParameter,
ConfigurationParameterGroup,
} from "~/modules/items";
-import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import { getLinkToItemManufacturing } from "~/modules/items/ui/Item/ItemForm";
import type { MethodItemType } from "~/modules/shared/types";
import { path } from "~/utils/path";
import { getJobMethodValidator } from "../../production.models";
@@ -86,7 +86,7 @@ const JobBreadcrumbs = () => {
const itemLink =
itemType && itemId
- ? getLinkToItemDetails(itemType as MethodItemType, itemId)
+ ? getLinkToItemManufacturing(itemType as MethodItemType, itemId)
: null;
const isDisabled = ["Completed", "Cancelled", "In Progress"].includes(
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index 341dfaae9f..5100f3ffed 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -43,7 +43,7 @@ import {
LuTriangleAlert,
LuX,
} from "react-icons/lu";
-import type { z } from "zod";
+import { z } from "zod";
import { DirectionAwareTabs, EmployeeAvatar, TimeTypeIcon } from "~/components";
import {
Hidden,
@@ -56,15 +56,18 @@ import {
StandardFactor,
Submit,
SupplierProcess,
+ Tags,
Tool,
UnitHint,
WorkCenter,
} from "~/components/Form";
+
import { getUnitHint } from "~/components/Form/UnitHint";
import { ConfirmDelete } from "~/components/Modals";
import type { Item, SortableItemRenderProps } from "~/components/SortableList";
import { SortableList, SortableListItem } from "~/components/SortableList";
import { usePermissions, useRouteData, useUser } from "~/hooks";
+import { useTags } from "~/hooks/useTags";
import type { OperationTool } from "~/modules/shared";
import {
methodOperationOrders,
@@ -78,8 +81,9 @@ import { getPrivateUrl, path } from "~/utils/path";
import { quoteOperationValidator } from "../../sales.models";
import type { Quotation } from "../../types";
-type Operation = z.infer<typeof quoteOperationValidator> & {
+export type Operation = z.infer<typeof quoteOperationValidator> & {
workInstruction: JSONContent | null;
+ tags: string[];
};
type OperationWithTools = Operation & {
@@ -93,6 +97,7 @@ type ItemWithData = Item & {
type QuoteBillOfProcessProps = {
quoteMakeMethodId: string;
operations: OperationWithTools[];
+ tags: { name: string }[];
};
type PendingWorkInstructions = {
@@ -111,11 +116,17 @@ type TemporaryItems = {
[key: string]: Operation;
};
-function makeItems(operations: Operation[]): ItemWithData[] {
- return operations.map(makeItem);
+function makeItems(
+ operations: Operation[],
+ tags: { name: string }[]
+): ItemWithData[] {
+ return operations.map((operation) => makeItem(operation, tags));
}
-function makeItem(operation: Operation): ItemWithData {
+function makeItem(
+ operation: Operation,
+ tags: { name: string }[]
+): ItemWithData {
return {
id: operation.id!,
title: <h3 className="font-semibold truncate">{operation.description}</h3>,
@@ -150,6 +161,11 @@ function makeItem(operation: Operation): ItemWithData {
)}
</HStack>
),
+ footer: isTemporaryId(operation.id ?? "") ? null : (
+ <HStack className="w-full justify-end">
+ <QuoteOperationTags operation={operation} availableTags={tags} />
+ </HStack>
+ ),
data: operation,
};
}
@@ -173,6 +189,7 @@ const initialOperation: Omit<
processId: "",
setupTime: 0,
setupUnit: "Total Minutes",
+ tags: [],
workCenterId: "",
workInstruction: {},
};
@@ -210,6 +227,7 @@ const usePendingOperations = () => {
const QuoteBillOfProcess = ({
quoteMakeMethodId,
operations: initialOperations,
+ tags,
}: QuoteBillOfProcessProps) => {
const { carbon } = useCarbon();
const sortOrderFetcher = useFetcher<{}>();
@@ -265,6 +283,7 @@ const QuoteBillOfProcess = ({
...pendingOperation,
workInstruction: {},
quoteOperationTool: [],
+ tags: [],
});
} else {
operationsById.set(pendingOperation.id, {
@@ -286,7 +305,7 @@ const QuoteBillOfProcess = ({
(a, b) => (orderState[a.id!] ?? a.order) - (orderState[b.id!] ?? b.order)
);
- const items = makeItems(operations).map((item) => ({
+ const items = makeItems(operations, tags).map((item) => ({
...item,
checked: checkedState[item.id] ?? false,
}));
@@ -660,7 +679,7 @@ const QuoteBillOfProcess = ({
export default QuoteBillOfProcess;
-function isTemporaryId(id: string) {
+export function isTemporaryId(id: string) {
return id.length < 20;
}
@@ -1570,3 +1589,37 @@ function ToolsForm({
</div>
);
}
+
+export function QuoteOperationTags({
+ operation,
+ availableTags,
+}: {
+ operation: Operation;
+ availableTags: { name: string }[];
+}) {
+ const { onUpdateTags } = useTags({
+ id: operation.id,
+ table: "quoteOperation",
+ });
+
+ return (
+ <ValidatedForm
+ defaultValues={{
+ tags: operation.tags ?? [],
+ }}
+ validator={z.object({
+ tags: z.array(z.string()).optional(),
+ })}
+ >
+ <Tags
+ availableTags={availableTags}
+ label=""
+ name="tags"
+ table="operation"
+ inline
+ maxPreview={3}
+ onChange={onUpdateTags}
+ />
+ </ValidatedForm>
+ );
+}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
index 07d7fd7ad2..4d7182a8dc 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMakeMethodTools.tsx
@@ -43,7 +43,7 @@ import type {
ConfigurationParameter,
ConfigurationParameterGroup,
} from "~/modules/items";
-import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import { getLinkToItemManufacturing } from "~/modules/items/ui/Item/ItemForm";
import type { MethodItemType } from "~/modules/shared/types";
import { path } from "~/utils/path";
import { getLineMethodValidator, getMethodValidator } from "../../sales.models";
@@ -74,7 +74,7 @@ const QuoteMakeMethodTools = () => {
const itemLink =
itemType && itemId
- ? getLinkToItemDetails(itemType as MethodItemType, itemId)
+ ? getLinkToItemManufacturing(itemType as MethodItemType, itemId)
: null;
const lineData = useRouteData<{
diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
index 584fdbb21f..d8869e22bb 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -37,12 +37,13 @@ import {
} from "~/modules/items/ui/Item";
import {
getModelByItemId,
+ getTagsList,
type MethodItemType,
type MethodType,
} from "~/modules/shared";
import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
+ const { client, companyId } = await requirePermissions(request, {
view: "parts",
});
@@ -51,11 +52,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!materialId) throw new Error("Could not find materialId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
- const [material, methodMaterials, methodOperations] = await Promise.all([
- getMethodMaterial(client, materialId),
- getMethodMaterialsByMakeMethod(client, makeMethodId),
- getMethodOperationsByMakeMethodId(client, makeMethodId),
- ]);
+ const [material, methodMaterials, methodOperations, tags] = await Promise.all(
+ [
+ getMethodMaterial(client, materialId),
+ getMethodMaterialsByMakeMethod(client, makeMethodId),
+ getMethodOperationsByMakeMethodId(client, makeMethodId),
+ getTagsList(client, companyId, "operation"),
+ ]
+ );
if (material.error) {
throw redirect(
@@ -113,16 +117,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
workCenterId: operation.workCenterId ?? undefined,
operationSupplierProcessId:
operation.operationSupplierProcessId ?? undefined,
+ tags: operation.tags ?? [],
workInstruction: operation.workInstruction as JSONContent | null,
})) ?? [],
model: getModelByItemId(client, material.data.itemId),
+ tags: tags.data ?? [],
});
}
export default function MethodMaterialMakePage() {
const loaderData = useLoaderData<typeof loader>();
const permissions = usePermissions();
- const { item, methodMaterials, methodOperations } = loaderData;
+ const { item, methodMaterials, methodOperations, tags } = loaderData;
const { itemId, makeMethodId, materialId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
@@ -155,6 +161,7 @@ export default function MethodMaterialMakePage() {
configurable={routeData?.partManufacturing.requiresConfiguration}
configurationRules={routeData?.configurationRules}
parameters={routeData?.configurationParametersAndGroups.parameters}
+ tags={tags}
/>
<BillOfMaterial
key={`bom:${itemId}`}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.method.tsx b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.method.tsx
index 83eeaabc74..0e7b35ec33 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.method.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.method.tsx
@@ -3,9 +3,9 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import { validationError, validator } from "@carbon/form";
import { VStack } from "@carbon/react";
-import { useParams } from "@remix-run/react";
-import type { ActionFunctionArgs } from "@vercel/remix";
-import { redirect } from "@vercel/remix";
+import { useLoaderData, useParams } from "@remix-run/react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json, redirect } from "@vercel/remix";
import type { z } from "zod";
import CadModel from "~/components/CadModel";
import { usePermissions, useRouteData } from "~/hooks";
@@ -31,9 +31,24 @@ import {
ConfigurationParametersForm,
PartManufacturingForm,
} from "~/modules/items/ui/Parts";
+import { getTagsList } from "~/modules/shared";
import { getCustomFields, setCustomFields } from "~/utils/form";
import { path } from "~/utils/path";
+// loader
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ });
+
+ const tags = await getTagsList(client, companyId, "operation");
+
+ return json({ tags: tags.data ?? [] });
+}
+
+// action
+
export async function action({ request, params }: ActionFunctionArgs) {
assertIsPost(request);
const { client, userId } = await requirePermissions(request, {
@@ -82,6 +97,8 @@ export default function MakeMethodRoute() {
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
+ const { tags } = useLoaderData<typeof loader>();
+
const itemRouteData = useRouteData<{
partSummary: PartSummary;
}>(path.to.part(itemId));
@@ -143,6 +160,7 @@ export default function MakeMethodRoute() {
parameters={
manufacturingRouteData?.configurationParametersAndGroups.parameters
}
+ tags={tags}
/>
<BillOfMaterial
key={`bom:${itemId}`}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
index 7400ef9f47..46721b5109 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
@@ -26,11 +26,11 @@ import {
QuoteMakeMethodTools,
QuoteMaterialForm,
} from "~/modules/sales/ui/Quotes";
-import { getModelByItemId } from "~/modules/shared";
+import { getModelByItemId, getTagsList } from "~/modules/shared";
import { path } from "~/utils/path";
export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
+ const { client, companyId } = await requirePermissions(request, {
view: "sales",
});
@@ -40,10 +40,11 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!methodId) throw new Error("Could not find methodId");
if (!materialId) throw new Error("Could not find materialId");
- const [material, materials, operations] = await Promise.all([
+ const [material, materials, operations, tags] = await Promise.all([
getQuoteMaterial(client, materialId),
getQuoteMaterialsByMethodId(client, methodId),
getQuoteOperationsByMethodId(client, methodId),
+ getTagsList(client, companyId, "operation"),
]);
if (material.error) {
@@ -110,7 +111,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
operationSupplierProcessId: o.operationSupplierProcessId ?? undefined,
quoteMakeMethodId: o.quoteMakeMethodId ?? methodId,
workInstruction: o.workInstruction as JSONContent | null,
+ tags: o.tags ?? [],
})) ?? [],
+ tags: tags.data ?? [],
model: getModelByItemId(client, material.data.itemId!),
});
}
@@ -121,7 +124,7 @@ export default function QuoteMakeMethodRoute() {
if (!methodId) throw new Error("Could not find methodId");
const loaderData = useLoaderData<typeof loader>();
- const { material, materials, operations } = loaderData;
+ const { material, materials, operations, tags } = loaderData;
return (
<VStack spacing={2}>
@@ -135,6 +138,7 @@ export default function QuoteMakeMethodRoute() {
key={`bop:${methodId}`}
quoteMakeMethodId={methodId}
operations={operations}
+ tags={tags}
/>
<QuoteBillOfMaterial
key={`bom:${methodId}`}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
index e93c0f887f..18e2ed3aa2 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
@@ -28,6 +28,7 @@ import type { LoaderFunctionArgs } from "@vercel/remix";
import { Suspense } from "react";
import { CadModel } from "~/components";
import { usePermissions } from "~/hooks";
+import { getTagsList } from "~/modules/shared";
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId } = await requirePermissions(request, {
@@ -39,9 +40,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!lineId) throw new Error("Could not find lineId");
if (!methodId) throw new Error("Could not find methodId");
- const [materials, operations] = await Promise.all([
+ const [materials, operations, tags] = await Promise.all([
getQuoteMaterialsByMethodId(client, methodId),
getQuoteOperationsByMethodId(client, methodId),
+ getTagsList(client, companyId, "operation"),
]);
if (materials.error) {
@@ -82,6 +84,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
operationSupplierProcessId: o.operationSupplierProcessId ?? undefined,
quoteMakeMethodId: o.quoteMakeMethodId ?? methodId,
workInstruction: o.workInstruction as JSONContent,
+ tags: o.tags ?? [],
})) ?? [],
configurationParameters: getConfigurationParametersByQuoteLineId(
client,
@@ -89,6 +92,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
companyId
),
model: getModelByQuoteLineId(client, lineId),
+ tags: tags.data ?? [],
});
}
@@ -101,7 +105,7 @@ export default function QuoteMakeMethodRoute() {
const permissions = usePermissions();
const loaderData = useLoaderData<typeof loader>();
- const { materials, operations } = loaderData;
+ const { materials, operations, tags } = loaderData;
return (
<VStack spacing={2}>
@@ -110,6 +114,7 @@ export default function QuoteMakeMethodRoute() {
key={`bop:${methodId}`}
quoteMakeMethodId={methodId}
operations={operations}
+ tags={tags ?? []}
/>
<QuoteBillOfMaterial
key={`bom:${methodId}`}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
index a7b3f55bef..47f0d097c5 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -29,12 +29,14 @@ import {
} from "~/modules/items/ui/Item";
import {
getModelByItemId,
+ getTagsList,
type MethodItemType,
type MethodType,
} from "~/modules/shared";
import { path } from "~/utils/path";
+
export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client } = await requirePermissions(request, {
+ const { client, companyId } = await requirePermissions(request, {
view: "parts",
});
@@ -43,11 +45,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!materialId) throw new Error("Could not find materialId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
- const [material, methodMaterials, methodOperations] = await Promise.all([
- getMethodMaterial(client, materialId),
- getMethodMaterialsByMakeMethod(client, makeMethodId),
- getMethodOperationsByMakeMethodId(client, makeMethodId),
- ]);
+ const [material, methodMaterials, methodOperations, tags] = await Promise.all(
+ [
+ getMethodMaterial(client, materialId),
+ getMethodMaterialsByMakeMethod(client, makeMethodId),
+ getMethodOperationsByMakeMethodId(client, makeMethodId),
+ getTagsList(client, companyId, "operation"),
+ ]
+ );
if (material.error) {
throw redirect(
@@ -105,16 +110,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
workCenterId: operation.workCenterId ?? undefined,
operationSupplierProcessId:
operation.operationSupplierProcessId ?? undefined,
+ tags: operation.tags ?? [],
workInstruction: operation.workInstruction as JSONContent | null,
})) ?? [],
model: getModelByItemId(client, material.data.itemId),
+ tags: tags.data ?? [],
});
}
export default function MethodMaterialMakePage() {
const permissions = usePermissions();
const loaderData = useLoaderData<typeof loader>();
- const { item, methodMaterials, methodOperations } = loaderData;
+ const { item, methodMaterials, methodOperations, tags } = loaderData;
const { itemId, makeMethodId, materialId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
@@ -133,6 +140,7 @@ export default function MethodMaterialMakePage() {
key={`bop:${itemId}`}
makeMethodId={makeMethodId}
operations={methodOperations}
+ tags={tags}
/>
<BillOfMaterial
key={`bom:${itemId}`}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.method.tsx b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.method.tsx
index 8b5048b8ea..e0cf6a1737 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.method.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.method.tsx
@@ -1,7 +1,11 @@
+import { requirePermissions } from "@carbon/auth/auth.server";
import { VStack } from "@carbon/react";
-import { useParams } from "@remix-run/react";
+import { useLoaderData, useParams } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
import { CadModel } from "~/components";
import { usePermissions, useRouteData } from "~/hooks";
+import { getTagsList } from "~/modules/shared";
import type {
MakeMethod,
@@ -17,11 +21,23 @@ import {
import { path } from "~/utils/path";
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ });
+
+ const tags = await getTagsList(client, companyId, "operation");
+
+ return json({ tags: tags.data ?? [] });
+}
+
export default function MakeMethodRoute() {
const permissions = usePermissions();
const { itemId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
+ const { tags } = useLoaderData<typeof loader>();
+
const manufacturingRouteData = useRouteData<{
makeMethod: MakeMethod;
methodMaterials: Material[];
@@ -43,6 +59,7 @@ export default function MakeMethodRoute() {
makeMethodId={makeMethodId}
// @ts-ignore
operations={manufacturingRouteData?.methodOperations ?? []}
+ tags={tags}
/>
<BillOfMaterial
key={`bom:${itemId}`}
@@ -53,7 +70,7 @@ export default function MakeMethodRoute() {
operations={manufacturingRouteData?.methodOperations}
/>
<CadModel
- isReadOnly={!permissions.can("update", "parts")}
+ isReadOnly={!permissions.can("update", "tools")}
metadata={{ itemId }}
modelPath={itemRouteData?.toolSummary?.modelPath ?? null}
title="CAD Model"