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: bom tree navigation

Brad Barbinc08b5972e030
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.ts
index 65a04e08c5..30b873ff11 100644
--- a/apps/carbon/app/modules/items/items.models.ts
+++ b/apps/carbon/app/modules/items/items.models.ts
@@ -140,7 +140,7 @@ export const methodMaterialValidator = z.object({
}),
itemId: z.string().min(20, { message: "Item is required" }),
itemReadableId: z.string().min(1, { message: "Item ID is required" }),
- description: z.string().min(1, { message: "Description is required" }),
+ // description: z.string().min(1, { message: "Description is required" }),
quantity: zfd.numeric(z.number().min(0)),
unitOfMeasureCode: z
.string()
diff --git a/apps/carbon/app/modules/items/items.service.ts b/apps/carbon/app/modules/items/items.service.ts
index e896c0f9bc..d555f63f81 100644
--- a/apps/carbon/app/modules/items/items.service.ts
+++ b/apps/carbon/app/modules/items/items.service.ts
@@ -200,6 +200,10 @@ export async function getFixturesList(
return query.order("name");
}
+export async function getItem(client: SupabaseClient<Database>, id: string) {
+ return client.from("item").select("*").eq("id", id).single();
+}
+
export async function getItemCost(
client: SupabaseClient<Database>,
itemId: string,
@@ -482,13 +486,24 @@ export async function getMaterialSubstancesList(
.order("name");
}
+export async function getMethodMaterial(
+ client: SupabaseClient<Database>,
+ materialId: string
+) {
+ return client
+ .from("methodMaterial")
+ .select("*, item(name)")
+ .eq("id", materialId)
+ .single();
+}
+
export async function getMethodMaterials(
client: SupabaseClient<Database>,
makeMethodId: string
) {
return client
.from("methodMaterial")
- .select("*")
+ .select("*, item(name)")
.eq("makeMethodId", makeMethodId)
.order("order", { ascending: true });
}
@@ -540,8 +555,8 @@ function getMethodTreeArrayToTree(items: Method[]): MethodTreeItem[] {
const lookup: { [id: string]: MethodTreeItem } = {};
for (const item of items) {
- const itemId = item.materialMakeMethodId ?? item.methodMaterialId;
- const parentId = item.makeMethodId;
+ const itemId = item.methodMaterialId;
+ const parentId = item.parentMaterialId;
if (!Object.prototype.hasOwnProperty.call(lookup, itemId)) {
// @ts-ignore
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
index 7368ab965f..8a8254abf7 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -43,7 +43,9 @@ import { methodItemType, methodMaterialValidator } from "../../items.models";
import type { MethodItemType, MethodType } from "../../types";
import { MethodIcon, MethodItemTypeIcon } from "./MethodIcon";
-type Material = z.infer<typeof methodMaterialValidator>;
+type Material = z.infer<typeof methodMaterialValidator> & {
+ description: string;
+};
type ItemWithData = SortableItem & {
data: Material;
@@ -88,7 +90,9 @@ function makeItem(material: Material): ItemWithData {
};
}
-const initialMethodMaterial: Omit<Material, "makeMethodId" | "order"> = {
+const initialMethodMaterial: Omit<Material, "makeMethodId" | "order"> & {
+ description: string;
+} = {
itemId: "",
itemReadableId: "",
itemType: "Part" as const,
@@ -471,7 +475,7 @@ function MaterialForm({
prevItems.map((i) =>
i.id === item.id
? {
- ...makeItem(values),
+ ...makeItem({ ...values, description: itemData.description }),
id: item.id,
}
: i
@@ -508,6 +512,7 @@ function MaterialForm({
<InputControlled
name="description"
label="Description"
+ isReadOnly
value={itemData.description}
onChange={(newValue) => {
setItemData((d) => ({ ...d, description: newValue }));
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
index 76dffb8145..cce81ea98e 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -70,7 +70,14 @@ function makeItem(operation: Operation): ItemWithData {
title: operation.description ?? "",
checked: false,
order: operation.operationOrder,
- details: <Badge variant="secondary">{operation.operationOrder}</Badge>,
+ details: (
+ <HStack spacing={1}>
+ <Badge variant="secondary">
+ {operation.productionStandard} {operation.standardFactor}
+ </Badge>
+ <Badge variant="secondary">{operation.operationOrder}</Badge>
+ </HStack>
+ ),
data: operation,
};
}
diff --git a/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx b/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx
new file mode 100644
index 0000000000..40290d6612
--- /dev/null
+++ b/apps/carbon/app/modules/items/ui/Item/BoMExplorer.tsx
@@ -0,0 +1,221 @@
+import {
+ Badge,
+ HStack,
+ Input,
+ InputGroup,
+ InputLeftElement,
+ VStack,
+ cn,
+ useMount,
+} from "@carbon/react";
+import { useNavigate, useParams } from "@remix-run/react";
+import { useRef, useState } from "react";
+import { LuChevronDown, LuChevronUp, LuSearch } from "react-icons/lu";
+import type { FlatTreeItem } from "~/components/TreeView/TreeView";
+import { TreeView, useTree } from "~/components/TreeView/TreeView";
+import { path } from "~/utils/path";
+import type { Method } from "../../types";
+import { MethodIcon } from "./MethodIcon";
+
+type BoMExplorerProps = {
+ methods: FlatTreeItem<Method>[];
+ selectedId?: string;
+};
+
+const BoMExplorer = ({ methods, selectedId }: BoMExplorerProps) => {
+ const [filterText, setFilterText] = useState("");
+ const parentRef = useRef<HTMLDivElement>(null);
+
+ const {
+ nodes,
+ getTreeProps,
+ getNodeProps,
+ // toggleNodeSelection,
+ toggleExpandNode,
+ expandAllBelowDepth,
+ // toggleExpandLevel,
+ collapseAllBelowDepth,
+ selectNode,
+ scrollToNode,
+ virtualizer,
+ } = useTree({
+ tree: methods,
+ selectedId,
+ // collapsedIds,
+ onSelectedIdChanged: () => {},
+ estimatedRowHeight: () => 32,
+ parentRef,
+ filter: {
+ value: { text: filterText },
+ fn: (value, node) => {
+ if (value.text === "") return true;
+ if (
+ node.data.itemReadableId
+ .toLowerCase()
+ .includes(value.text.toLowerCase())
+ ) {
+ return true;
+ }
+ return false;
+ },
+ },
+ isEager: true,
+ });
+
+ const navigate = useNavigate();
+ const params = useParams();
+ const { itemId } = params;
+ if (!itemId) throw new Error("itemId not found");
+
+ useMount(() => {
+ if (params.materialId) {
+ selectNode(params.materialId);
+ } else if (methods?.length > 0) {
+ selectNode(methods[0].id);
+ }
+ });
+
+ return (
+ <VStack>
+ <HStack className="w-full">
+ <InputGroup size="sm" className="flex flex-grow">
+ <InputLeftElement>
+ <LuSearch className="h-4 w-4" />
+ </InputLeftElement>
+ <Input
+ placeholder="Search..."
+ value={filterText}
+ onChange={(e) => setFilterText(e.target.value)}
+ />
+ </InputGroup>
+ </HStack>
+ <TreeView
+ parentRef={parentRef}
+ virtualizer={virtualizer}
+ autoFocus
+ tree={methods}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ renderNode={({ node, state }) => (
+ <>
+ <div
+ className={cn(
+ "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
+ state.selected
+ ? "bg-muted hover:bg-muted/90"
+ : "bg-transparent hover:bg-muted/90"
+ )}
+ onClick={() => {
+ selectNode(node.id);
+ if (node.data.isRoot) {
+ navigate(path.to.makeMethod(itemId));
+ } else {
+ navigate(
+ path.to.partManufacturingMaterial(
+ itemId,
+ node.data.materialMakeMethodId ??
+ node.data.methodType.toLowerCase(),
+ node.data.methodMaterialId
+ )
+ );
+ }
+ }}
+ >
+ <div className="flex h-8 items-center">
+ {Array.from({ length: node.level }).map((_, index) => (
+ <TaskLine key={index} isSelected={state.selected} />
+ ))}
+ <div
+ className={cn(
+ "flex h-8 w-4 items-center",
+ node.hasChildren && "hover:bg-accent"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (e.altKey) {
+ if (state.expanded) {
+ collapseAllBelowDepth(node.level);
+ } else {
+ expandAllBelowDepth(node.level);
+ }
+ } else {
+ toggleExpandNode(node.id);
+ }
+ scrollToNode(node.id);
+ }}
+ >
+ {node.hasChildren ? (
+ state.expanded ? (
+ <LuChevronDown className="h-4 w-4 text-gray-400" />
+ ) : (
+ <LuChevronUp className="h-4 w-4 text-gray-400" />
+ )
+ ) : (
+ <div className="h-8 w-4" />
+ )}
+ </div>
+ </div>
+
+ <div className="flex w-full items-center justify-between gap-2">
+ <div
+ className={cn(
+ "flex items-center gap-2 overflow-x-hidden",
+ node.level > 1 && "opacity-50"
+ )}
+ >
+ <MethodIcon
+ type={
+ // node.data.isRoot ? "Method" :
+ node.data.methodType
+ }
+ className="h-4 min-h-4 w-4 min-w-4 flex-shrink-0"
+ />
+ <NodeText node={node} />
+ </div>
+ <div className="flex items-center gap-1">
+ {node.data.isRoot ? (
+ <Badge variant="outline" className="text-xs">
+ Method
+ </Badge>
+ ) : (
+ <NodeQuantity node={node} />
+ )}
+ </div>
+ </div>
+ </div>
+ </>
+ )}
+ />
+ </VStack>
+ );
+};
+
+export default BoMExplorer;
+
+function NodeText({ node }: { node: FlatTreeItem<Method> }) {
+ return (
+ <div className="flex items-center gap-1">
+ <span className="text-sm font-mono">{node.data.itemReadableId}</span>
+ </div>
+ );
+}
+
+function NodeQuantity({ node }: { node: FlatTreeItem<Method> }) {
+ return (
+ <Badge className="text-xs" variant="outline">
+ {node.data.quantity}
+ </Badge>
+ );
+}
+
+function TaskLine({ isSelected }: { isSelected: boolean }) {
+ return (
+ <div
+ className={cn(
+ "h-8 w-2 border-r border-border",
+ isSelected && "border-foreground/30"
+ )}
+ />
+ );
+}
diff --git a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
index 1054018a23..75a9bbfff6 100644
--- a/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/ItemForm.tsx
@@ -1,24 +1,37 @@
import type { Database } from "@carbon/database";
import {
+ Button,
Card,
+ CardAction,
CardContent,
CardFooter,
CardHeader,
CardTitle,
+ HStack,
} from "@carbon/react";
import { ValidatedForm } from "@carbon/remix-validated-form";
-import { useFetcher } from "@remix-run/react";
+import { Link, useFetcher } from "@remix-run/react";
+import { useState } from "react";
+import { LuExternalLink } from "react-icons/lu";
import type { z } from "zod";
import {
Boolean,
- CustomFormFields,
+ DefaultMethodType,
Hidden,
Input,
- ItemPostingGroup,
+ Select,
Submit,
+ TextArea,
+ UnitOfMeasure,
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import { itemValidator } from "~/modules/items";
+import type { MethodItemType } from "~/modules/items";
+import {
+ MethodItemTypeIcon,
+ itemReplenishmentSystems,
+ itemTrackingTypes,
+ itemValidator,
+} from "~/modules/items";
import { path } from "~/utils/path";
import { capitalize } from "~/utils/string";
@@ -35,6 +48,24 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
const permissions = usePermissions();
const fetcher = useFetcher();
+ const itemTrackingTypeOptions =
+ itemTrackingTypes.map((itemTrackingType) => ({
+ label: itemTrackingType,
+ value: itemTrackingType,
+ })) ?? [];
+
+ const [replenishmentSystem, setReplenishmentSystem] = useState<string>(
+ initialValues.replenishmentSystem ?? "Buy"
+ );
+ const [defaultMethodType, setDefaultMethodType] = useState<string>(
+ initialValues.defaultMethodType ?? "Buy"
+ );
+ const itemReplenishmentSystemOptions =
+ itemReplenishmentSystems.map((itemReplenishmentSystem) => ({
+ label: itemReplenishmentSystem,
+ value: itemReplenishmentSystem,
+ })) ?? [];
+
return (
<Card>
<ValidatedForm
@@ -44,11 +75,26 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
defaultValues={initialValues}
fetcher={fetcher}
>
- <CardHeader>
- <CardTitle>{getLabel(type)}</CardTitle>
- </CardHeader>
+ <HStack className="w-full justify-between">
+ <CardHeader>
+ <CardTitle>
+ <HStack spacing={2}>
+ <MethodItemTypeIcon type={type} />
+ <span>{getLabel(type)}</span>
+ </HStack>
+ </CardTitle>
+ </CardHeader>
+ <CardAction>
+ <Button isIcon asChild variant="ghost" size="lg">
+ <Link to={getLink(type, initialValues.id)}>
+ <LuExternalLink />
+ </Link>
+ </Button>
+ </CardAction>
+ </HStack>
<CardContent>
<Hidden name="id" />
+ <Hidden name="type" />
<div className="grid w-full gap-x-8 gap-y-4 grid-cols-1 md:grid-cols-3">
<Input
isReadOnly
@@ -57,10 +103,39 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
/>
<Input name="name" label="Name" />
- <ItemPostingGroup name="itemPostingGroupId" label="Posting Group" />
+ <Select
+ name="itemTrackingType"
+ label="Tracking Type"
+ options={itemTrackingTypeOptions}
+ />
+
+ <TextArea name="description" label="Description" />
+
+ <Select
+ name="replenishmentSystem"
+ label="Replenishment System"
+ options={itemReplenishmentSystemOptions}
+ onChange={(newValue) => {
+ setReplenishmentSystem(newValue?.value ?? "Buy");
+ if (newValue?.value === "Buy") {
+ setDefaultMethodType("Buy");
+ } else {
+ setDefaultMethodType("Make");
+ }
+ }}
+ />
+ <DefaultMethodType
+ name="defaultMethodType"
+ label="Default Method Type"
+ replenishmentSystem={replenishmentSystem}
+ value={defaultMethodType}
+ onChange={(newValue) =>
+ setDefaultMethodType(newValue?.value ?? "Buy")
+ }
+ />
+ <UnitOfMeasure name="unitOfMeasureCode" label="Unit of Measure" />
<Boolean name="active" label="Active" />
- <CustomFormFields table="part" />
</div>
</CardContent>
<CardFooter>
@@ -72,3 +147,22 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
};
export default ItemForm;
+
+function getLink(type: MethodItemType, id: string) {
+ switch (type) {
+ case "Part":
+ return path.to.partDetails(id);
+ case "Material":
+ return path.to.materialDetails(id);
+ case "Tool":
+ return path.to.toolDetails(id);
+ case "Consumable":
+ return path.to.consumableDetails(id);
+ case "Service":
+ return path.to.serviceDetails(id);
+ case "Fixture":
+ return path.to.fixtureDetails(id);
+ default:
+ throw new Error("Invalid type");
+ }
+}
diff --git a/apps/carbon/app/modules/items/ui/Item/index.ts b/apps/carbon/app/modules/items/ui/Item/index.ts
index 50b2e6cd1c..a2917a85a8 100644
--- a/apps/carbon/app/modules/items/ui/Item/index.ts
+++ b/apps/carbon/app/modules/items/ui/Item/index.ts
@@ -1,5 +1,6 @@
import BillOfMaterial from "./BillOfMaterial";
import BillOfProcess from "./BillOfProcess";
+import BoMExplorer from "./BoMExplorer";
import BuyMethodForm from "./BuyMethodForm";
import BuyMethods from "./BuyMethods";
import ItemCostingForm from "./ItemCostingForm";
@@ -13,6 +14,7 @@ import PickMethodForm from "./PickMethodForm";
export {
BillOfMaterial,
BillOfProcess,
+ BoMExplorer,
BuyMethodForm,
BuyMethods,
ItemCostingForm,
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
index 23c2820fdc..a9b2169a35 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx
@@ -99,6 +99,7 @@ const PartProperties = () => {
</HStack>
<span className="text-sm">{routeData?.partSummary?.name}</span>
</VStack>
+
<VStack spacing={2}>
<h3 className="text-xs text-muted-foreground">Assignee</h3>
<Assignee id={itemId} table="item" value={assignee ?? ""} />
diff --git a/apps/carbon/app/routes/api+/item.$type.ts b/apps/carbon/app/routes/api+/item.$type.ts
index fdc368a0ec..7a8b59fddc 100644
--- a/apps/carbon/app/routes/api+/item.$type.ts
+++ b/apps/carbon/app/routes/api+/item.$type.ts
@@ -14,16 +14,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
const { type } = params;
if (!type) throw new Error("Could not find type");
+
if (
- ![
- "part",
- "material",
- "tool",
- "hardware",
- "service",
- "consumable",
- "fixture",
- ].includes(type)
+ !["Part", "Material", "Tool", "Service", "Consumable", "Fixture"].includes(
+ type
+ )
) {
throw new Error("Invalid type");
}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
new file mode 100644
index 0000000000..cfb0628f81
--- /dev/null
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -0,0 +1,124 @@
+import type { JSONContent } from "@carbon/react";
+import { VStack } from "@carbon/react";
+import type { LoaderFunctionArgs } from "@remix-run/node";
+import { json, redirect, useLoaderData, useParams } from "@remix-run/react";
+
+import type { MethodItemType, MethodType } from "~/modules/items";
+import {
+ BillOfMaterial,
+ BillOfProcess,
+ ItemForm,
+ getItem,
+ getMethodMaterial,
+ getMethodMaterials,
+ getMethodOperations,
+} from "~/modules/items";
+import { requirePermissions } from "~/services/auth/auth.server";
+import { flash } from "~/services/session.server";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "parts",
+ });
+
+ const { itemId, materialId, makeMethodId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+ 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),
+ getMethodMaterials(client, makeMethodId),
+ getMethodOperations(client, makeMethodId),
+ ]);
+
+ if (material.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, error(material.error, "Failed to load material"))
+ );
+ }
+
+ if (methodOperations.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(
+ request,
+ error(methodOperations.error, "Failed to load method operations")
+ )
+ );
+ }
+ if (methodMaterials.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(
+ request,
+ error(methodMaterials.error, "Failed to load method materials")
+ )
+ );
+ }
+
+ const item = await getItem(client, material.data.itemId);
+ if (item.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, error(item.error, "Failed to load item"))
+ );
+ }
+
+ return json({
+ item: {
+ ...item.data,
+ defaultMethodType: item.data.defaultMethodType ?? "Buy",
+ unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
+ description: item.data.description ?? "",
+ },
+ material: material.data,
+ methodMaterials:
+ methodMaterials.data?.map((m) => ({
+ ...m,
+ description: m.item?.name ?? "",
+ methodType: m.methodType as MethodType,
+ itemType: m.itemType as MethodItemType,
+ })) ?? [],
+ methodOperations:
+ methodOperations.data?.map((operation) => ({
+ ...operation,
+ equipmentTypeId: operation.equipmentTypeId ?? undefined,
+ methodOperationWorkInstruction:
+ operation.methodOperationWorkInstruction as {
+ content: JSONContent | null;
+ },
+ })) ?? [],
+ });
+}
+
+export default function MethodMaterialMakePage() {
+ const { item, methodMaterials, methodOperations } =
+ useLoaderData<typeof loader>();
+ const { itemId, makeMethodId, materialId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ if (!makeMethodId) throw new Error("Could not find makeMethodId");
+ if (!materialId) throw new Error("Could not find materialId");
+
+ return (
+ <VStack spacing={2} className="p-2">
+ <ItemForm
+ key={`item:${itemId}:${makeMethodId}:${materialId}`}
+ type={item.type}
+ initialValues={item}
+ />
+ <BillOfMaterial
+ key={`bom:${itemId}:${makeMethodId}:${materialId}`}
+ makeMethodId={makeMethodId}
+ materials={methodMaterials}
+ />
+ <BillOfProcess
+ key={`bop:${itemId}:${makeMethodId}:${materialId}`}
+ makeMethodId={makeMethodId}
+ operations={methodOperations}
+ />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.buy.$materialId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.buy.$materialId.tsx
new file mode 100644
index 0000000000..458289c534
--- /dev/null
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.buy.$materialId.tsx
@@ -0,0 +1,62 @@
+import { VStack } from "@carbon/react";
+import type { LoaderFunctionArgs } from "@remix-run/node";
+import { json, redirect, useLoaderData, useParams } from "@remix-run/react";
+
+import { ItemForm, getItem, getMethodMaterial } from "~/modules/items";
+import { requirePermissions } from "~/services/auth/auth.server";
+import { flash } from "~/services/session.server";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "parts",
+ });
+
+ const { itemId, materialId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+ if (!materialId) throw new Error("Could not find materialId");
+
+ const [material] = await Promise.all([getMethodMaterial(client, materialId)]);
+
+ if (material.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, error(material.error, "Failed to load material"))
+ );
+ }
+
+ const item = await getItem(client, material.data.itemId);
+ if (item.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, error(item.error, "Failed to load item"))
+ );
+ }
+
+ return json({
+ item: {
+ ...item.data,
+ defaultMethodType: item.data.defaultMethodType ?? "Buy",
+ unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
+ description: item.data.description ?? "",
+ },
+ material: material.data,
+ });
+}
+
+export default function MethodMaterialPickPage() {
+ const { item } = useLoaderData<typeof loader>();
+ const { itemId, materialId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ if (!materialId) throw new Error("Could not find materialId");
+
+ return (
+ <VStack spacing={2} className="p-2">
+ <ItemForm
+ key={`item:${itemId}:${materialId}`}
+ type={item.type}
+ initialValues={item}
+ />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
index 98181bb929..4f561d2373 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
@@ -1,27 +1,11 @@
-import {
- Button,
- HStack,
- ResizableHandle,
- ResizablePanel,
- ScrollArea,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
- VStack,
-} from "@carbon/react";
+import { VStack } from "@carbon/react";
import { validationError, validator } from "@carbon/remix-validated-form";
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { json, useLoaderData, useParams } from "@remix-run/react";
-import { LuCopy, LuLink } from "react-icons/lu";
import { redirect } from "remix-typedjson";
import { useRouteData } from "~/hooks";
-import type {
- MakeMethod,
- Material,
- MethodOperation,
- PartSummary,
-} from "~/modules/items";
+import type { MakeMethod, Material, MethodOperation } from "~/modules/items";
import {
BillOfMaterial,
BillOfProcess,
@@ -127,97 +111,24 @@ export default function MakeMethodRoute() {
...getCustomFields(partManufacturing.customFields),
};
- const routeData = useRouteData<{
- partSummary: PartSummary;
- }>(path.to.part(itemId));
-
return (
- <>
- <ResizablePanel
- order={2}
- minSize={40}
- defaultSize={60}
- className="border-t border-border"
- >
- <ScrollArea className="h-[calc(100vh-99px)]">
- <VStack spacing={2} className="p-2">
- <PartManufacturingForm
- key={itemId}
- initialValues={manufacturingInitialValues}
- />
- <BillOfMaterial
- key={itemId}
- makeMethodId={makeMethodId}
- // @ts-ignore
- materials={manufacturingRouteData?.methodMaterials ?? []}
- />
- <BillOfProcess
- key={itemId}
- makeMethodId={makeMethodId}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations ?? []}
- />
- </VStack>
- </ScrollArea>
- </ResizablePanel>
- <ResizableHandle withHandle />
- <ResizablePanel
- order={3}
- minSize={10}
- defaultSize={20}
- className="bg-card"
- >
- <ScrollArea className="h-[calc(100vh-99px)] px-4 py-2">
- <VStack spacing={2}>
- <HStack className="w-full justify-between">
- <h3 className="text-xs text-muted-foreground">Properties</h3>
- <HStack spacing={1}>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- aria-label="Link"
- size="sm"
- className="p-1"
- onClick={() =>
- navigator.clipboard.writeText(
- window.location.origin + path.to.part(itemId)
- )
- }
- >
- <LuLink className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <span>Copy link to part</span>
- </TooltipContent>
- </Tooltip>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- aria-label="Copy"
- size="sm"
- className="p-1"
- onClick={() =>
- navigator.clipboard.writeText(
- routeData?.partSummary?.id ?? ""
- )
- }
- >
- <LuCopy className="w-3 h-3" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <span>Copy part number</span>
- </TooltipContent>
- </Tooltip>
- </HStack>
- </HStack>
- <span className="text-sm">{routeData?.partSummary?.name}</span>
- </VStack>
- </ScrollArea>
- </ResizablePanel>
- </>
+ <VStack spacing={2} className="p-2">
+ <PartManufacturingForm
+ key={itemId}
+ initialValues={manufacturingInitialValues}
+ />
+ <BillOfMaterial
+ key={itemId}
+ makeMethodId={makeMethodId}
+ // @ts-ignore
+ materials={manufacturingRouteData?.methodMaterials ?? []}
+ />
+ <BillOfProcess
+ key={itemId}
+ makeMethodId={makeMethodId}
+ // @ts-ignore
+ operations={manufacturingRouteData?.methodOperations ?? []}
+ />
+ </VStack>
);
}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.pick.$materialId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.pick.$materialId.tsx
new file mode 100644
index 0000000000..458289c534
--- /dev/null
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.pick.$materialId.tsx
@@ -0,0 +1,62 @@
+import { VStack } from "@carbon/react";
+import type { LoaderFunctionArgs } from "@remix-run/node";
+import { json, redirect, useLoaderData, useParams } from "@remix-run/react";
+
+import { ItemForm, getItem, getMethodMaterial } from "~/modules/items";
+import { requirePermissions } from "~/services/auth/auth.server";
+import { flash } from "~/services/session.server";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "parts",
+ });
+
+ const { itemId, materialId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+ if (!materialId) throw new Error("Could not find materialId");
+
+ const [material] = await Promise.all([getMethodMaterial(client, materialId)]);
+
+ if (material.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, error(material.error, "Failed to load material"))
+ );
+ }
+
+ const item = await getItem(client, material.data.itemId);
+ if (item.error) {
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, error(item.error, "Failed to load item"))
+ );
+ }
+
+ return json({
+ item: {
+ ...item.data,
+ defaultMethodType: item.data.defaultMethodType ?? "Buy",
+ unitOfMeasureCode: item.data.unitOfMeasureCode ?? "EA",
+ description: item.data.description ?? "",
+ },
+ material: material.data,
+ });
+}
+
+export default function MethodMaterialPickPage() {
+ const { item } = useLoaderData<typeof loader>();
+ const { itemId, materialId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+ if (!materialId) throw new Error("Could not find materialId");
+
+ return (
+ <VStack spacing={2} className="p-2">
+ <ItemForm
+ key={`item:${itemId}:${materialId}`}
+ type={item.type}
+ initialValues={item}
+ />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
index 15cb5def3b..eafe42114c 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.tsx
@@ -1,30 +1,38 @@
import type { JSONContent } from "@carbon/react";
import {
- Badge,
+ Button,
ClientOnly,
HStack,
- IconButton,
- Input,
- InputGroup,
- InputLeftElement,
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
ScrollArea,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
VStack,
- cn,
} from "@carbon/react";
-import type { FlatTreeItem } from "~/components/TreeView/TreeView";
-import { TreeView, flattenTree, useTree } from "~/components/TreeView/TreeView";
-
import type { LoaderFunctionArgs } from "@remix-run/node";
-import { Outlet, json, useLoaderData, useParams } from "@remix-run/react";
-import { useRef, useState } from "react";
-import { LuChevronDown, LuChevronUp, LuPlus, LuSearch } from "react-icons/lu";
-import { redirect } from "remix-typedjson";
-import type { Method, MethodItemType, MethodType } from "~/modules/items";
import {
- MethodIcon,
+ Outlet,
+ json,
+ redirect,
+ useLoaderData,
+ useParams,
+} from "@remix-run/react";
+import { LuCopy, LuLink } from "react-icons/lu";
+
+import type { FlatTreeItem } from "~/components/TreeView/TreeView";
+import { flattenTree } from "~/components/TreeView/TreeView";
+import { useRouteData } from "~/hooks";
+import type {
+ Method,
+ MethodItemType,
+ MethodType,
+ PartSummary,
+} from "~/modules/items";
+import {
+ BoMExplorer,
getMakeMethod,
getMethodMaterials,
getMethodOperations,
@@ -94,6 +102,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
methodMaterials:
methodMaterials.data?.map((m) => ({
...m,
+ description: m.item?.name ?? "",
methodType: m.methodType as MethodType,
itemType: m.itemType as MethodItemType,
})) ?? [],
@@ -115,9 +124,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export default function PartManufacturing() {
const { methods } = useLoaderData<typeof loader>();
- const { itemId } = useParams();
+ const params = useParams();
+ const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
+ const routeData = useRouteData<{
+ partSummary: PartSummary;
+ }>(path.to.part(itemId));
+
return (
<div className="flex flex-grow overflow-hidden">
<ClientOnly fallback={null}>
@@ -134,205 +148,86 @@ export default function PartManufacturing() {
<BoMExplorer
// @ts-ignore
methods={methods}
- onSelectedIdChanged={(selectedId) => {
- console.log(selectedId);
- }}
/>
</div>
</ScrollArea>
</ResizablePanel>
<ResizableHandle withHandle />
-
- <Outlet />
+ <ResizablePanel
+ order={2}
+ minSize={40}
+ defaultSize={60}
+ className="border-t border-border"
+ >
+ <ScrollArea className="h-[calc(100vh-99px)]">
+ <Outlet key={JSON.stringify(params)} />
+ </ScrollArea>
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ <ResizablePanel
+ order={3}
+ minSize={10}
+ defaultSize={20}
+ className="bg-card"
+ >
+ <ScrollArea className="h-[calc(100vh-99px)] px-4 py-2">
+ <VStack spacing={2}>
+ <HStack className="w-full justify-between">
+ <h3 className="text-xs text-muted-foreground">
+ Properties
+ </h3>
+ <HStack spacing={1}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Link"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ window.location.origin + path.to.part(itemId)
+ )
+ }
+ >
+ <LuLink className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy link to part</span>
+ </TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ aria-label="Copy"
+ size="sm"
+ className="p-1"
+ onClick={() =>
+ navigator.clipboard.writeText(
+ routeData?.partSummary?.id ?? ""
+ )
+ }
+ >
+ <LuCopy className="w-3 h-3" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <span>Copy part number</span>
+ </TooltipContent>
+ </Tooltip>
+ </HStack>
+ </HStack>
+ <span className="text-sm">
+ {routeData?.partSummary?.name}
+ </span>
+ </VStack>
+ </ScrollArea>
+ </ResizablePanel>
</ResizablePanelGroup>
)}
</ClientOnly>
</div>
);
}
-
-type BoMExplorerProps = {
- methods: FlatTreeItem<Method>[];
- selectedId?: string;
- onSelectedIdChanged: (selectedId: string | undefined) => void;
-};
-
-function BoMExplorer({
- methods,
- selectedId,
- onSelectedIdChanged,
-}: BoMExplorerProps) {
- const [filterText, setFilterText] = useState("");
- const parentRef = useRef<HTMLDivElement>(null);
-
- const {
- nodes,
- getTreeProps,
- getNodeProps,
- // toggleNodeSelection,
- toggleExpandNode,
- expandAllBelowDepth,
- // toggleExpandLevel,
- collapseAllBelowDepth,
- selectNode,
- scrollToNode,
- virtualizer,
- } = useTree({
- tree: methods,
- selectedId,
- // collapsedIds,
- onSelectedIdChanged,
- estimatedRowHeight: () => 32,
- parentRef,
- filter: {
- value: { text: filterText },
- fn: (value, node) => {
- if (value.text === "") return true;
- if (
- node.data.itemReadableId
- .toLowerCase()
- .includes(value.text.toLowerCase())
- ) {
- return true;
- }
- return false;
- },
- },
- isEager: true,
- });
-
- return (
- <VStack>
- <HStack className="w-full">
- <InputGroup size="sm" className="flex flex-grow">
- <InputLeftElement>
- <LuSearch className="h-4 w-4" />
- </InputLeftElement>
- <Input
- placeholder="Search..."
- value={filterText}
- onChange={(e) => setFilterText(e.target.value)}
- />
- </InputGroup>
- <IconButton
- aria-label="Add"
- variant="secondary"
- icon={<LuPlus className="h-4 w-4" />}
- />
- </HStack>
- <TreeView
- parentRef={parentRef}
- virtualizer={virtualizer}
- autoFocus
- tree={methods}
- nodes={nodes}
- getNodeProps={getNodeProps}
- getTreeProps={getTreeProps}
- renderNode={({ node, state }) => (
- <>
- <div
- className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
- state.selected
- ? "bg-muted hover:bg-muted/90"
- : "bg-transparent hover:bg-muted/90"
- )}
- onClick={() => {
- selectNode(node.id);
- }}
- >
- <div className="flex h-8 items-center">
- {Array.from({ length: node.level }).map((_, index) => (
- <TaskLine key={index} isSelected={state.selected} />
- ))}
- <div
- className={cn(
- "flex h-8 w-4 items-center",
- node.hasChildren && "hover:bg-accent"
- )}
- onClick={(e) => {
- e.stopPropagation();
- if (e.altKey) {
- if (state.expanded) {
- collapseAllBelowDepth(node.level);
- } else {
- expandAllBelowDepth(node.level);
- }
- } else {
- toggleExpandNode(node.id);
- }
- scrollToNode(node.id);
- }}
- >
- {node.hasChildren ? (
- state.expanded ? (
- <LuChevronDown className="h-4 w-4 text-gray-400" />
- ) : (
- <LuChevronUp className="h-4 w-4 text-gray-400" />
- )
- ) : (
- <div className="h-8 w-4" />
- )}
- </div>
- </div>
-
- <div className="flex w-full items-center justify-between gap-2">
- <div
- className={cn(
- "flex items-center gap-2 overflow-x-hidden",
- node.level > 1 && "opacity-50"
- )}
- >
- <MethodIcon
- type={
- // node.data.isRoot ? "Method" :
- node.data.methodType
- }
- className="h-4 min-h-4 w-4 min-w-4"
- />
- <NodeText node={node} />
- </div>
- <div className="flex items-center gap-1">
- {node.data.isRoot ? (
- <Badge variant="outline" className="text-xs">
- Method
- </Badge>
- ) : (
- <NodeQuantity node={node} />
- )}
- </div>
- </div>
- </div>
- </>
- )}
- />
- </VStack>
- );
-}
-
-function NodeText({ node }: { node: FlatTreeItem<Method> }) {
- return (
- <div className="flex items-center gap-1">
- <span className="text-sm font-mono">{node.data.itemReadableId}</span>
- </div>
- );
-}
-
-function NodeQuantity({ node }: { node: FlatTreeItem<Method> }) {
- return (
- <Badge className="text-xs" variant="outline">
- {node.data.quantity}
- </Badge>
- );
-}
-
-function TaskLine({ isSelected }: { isSelected: boolean }) {
- return (
- <div
- className={cn(
- "h-8 w-2 border-r border-border",
- isSelected && "border-foreground/30"
- )}
- />
- );
-}
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 89c0844d4b..506fc9cf47 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -483,6 +483,14 @@ export const path = {
generatePath(`${x}/part/${id}/inventory?location=${locationId}`),
partManufacturing: (id: string) =>
generatePath(`${x}/part/${id}/manufacturing`),
+ partManufacturingMaterial: (
+ itemId: string,
+ makeMethodId: string,
+ methodMaterialId: string
+ ) =>
+ generatePath(
+ `${x}/part/${itemId}/manufacturing/${makeMethodId}/${methodMaterialId}`
+ ),
partPlanning: (id: string) => generatePath(`${x}/part/${id}/planning`),
partPlanningLocation: (id: string, locationId: string) =>
generatePath(`${x}/part/${id}/planning?location=${locationId}`),
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index cf97c6e6da..ab51ada80e 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -8177,7 +8177,6 @@ export type Database = {
createdAt: string
createdBy: string
customFields: Json | null
- description: string
id: string
itemId: string
itemReadableId: string
@@ -8196,7 +8195,6 @@ export type Database = {
createdAt?: string
createdBy: string
customFields?: Json | null
- description: string
id?: string
itemId: string
itemReadableId: string
@@ -8215,7 +8213,6 @@ export type Database = {
createdAt?: string
createdBy?: string
customFields?: Json | null
- description?: string
id?: string
itemId?: string
itemReadableId?: string
@@ -8293,6 +8290,20 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "methodMaterial_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodMaterial_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "methodMaterial_materialMakeMethodId_fkey"
columns: ["materialMakeMethodId"]
@@ -23994,6 +24005,8 @@ export type Database = {
itemType: string
quantity: number
methodType: Database["public"]["Enums"]["methodType"]
+ parentMaterialId: string
+ order: number
isRoot: boolean
}[]
}
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index cf97c6e6da..ab51ada80e 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -8177,7 +8177,6 @@ export type Database = {
createdAt: string
createdBy: string
customFields: Json | null
- description: string
id: string
itemId: string
itemReadableId: string
@@ -8196,7 +8195,6 @@ export type Database = {
createdAt?: string
createdBy: string
customFields?: Json | null
- description: string
id?: string
itemId: string
itemReadableId: string
@@ -8215,7 +8213,6 @@ export type Database = {
createdAt?: string
createdBy?: string
customFields?: Json | null
- description?: string
id?: string
itemId?: string
itemReadableId?: string
@@ -8293,6 +8290,20 @@ export type Database = {
referencedRelation: "userDefaults"
referencedColumns: ["userId"]
},
+ {
+ foreignKeyName: "methodMaterial_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "item"
+ referencedColumns: ["id"]
+ },
+ {
+ foreignKeyName: "methodMaterial_itemId_fkey"
+ columns: ["itemId"]
+ isOneToOne: false
+ referencedRelation: "itemQuantities"
+ referencedColumns: ["itemId"]
+ },
{
foreignKeyName: "methodMaterial_materialMakeMethodId_fkey"
columns: ["materialMakeMethodId"]
@@ -23994,6 +24005,8 @@ export type Database = {
itemType: string
quantity: number
methodType: Database["public"]["Enums"]["methodType"]
+ parentMaterialId: string
+ order: number
isRoot: boolean
}[]
}
diff --git a/packages/database/supabase/migrations/20240627093203_method-tree-fix.sql b/packages/database/supabase/migrations/20240627093203_method-tree-fix.sql
new file mode 100644
index 0000000000..5748818cb2
--- /dev/null
+++ b/packages/database/supabase/migrations/20240627093203_method-tree-fix.sql
@@ -0,0 +1,80 @@
+ALTER TABLE "methodMaterial" DROP COLUMN "description";
+ALTER TABLE "methodMaterial" ADD CONSTRAINT "methodMaterial_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "item" ("id") ON UPDATE CASCADE ON DELETE RESTRICT;
+
+
+DROP FUNCTION get_method_tree;
+CREATE OR REPLACE FUNCTION get_method_tree(uid TEXT)
+RETURNS TABLE (
+ "methodMaterialId" TEXT,
+ "makeMethodId" TEXT,
+ "materialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "itemType" TEXT,
+ "quantity" NUMERIC,
+ "methodType" "methodType",
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "isRoot" BOOLEAN
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "id",
+ "makeMethodId",
+ "methodType",
+ "materialMakeMethodId",
+ "itemId",
+ "itemType",
+ "quantity",
+ "makeMethodId" AS "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order"
+ FROM
+ "methodMaterial"
+ WHERE
+ "makeMethodId" = uid
+ UNION
+ SELECT
+ child."id",
+ child."makeMethodId",
+ child."methodType",
+ child."materialMakeMethodId",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ parent."id" AS "parentMaterialId",
+ child."order"
+ FROM
+ "methodMaterial" child
+ INNER JOIN material parent ON parent."materialMakeMethodId" = child."makeMethodId"
+)
+SELECT
+ material.id as "methodMaterialId",
+ material."makeMethodId",
+ material."materialMakeMethodId",
+ material."itemId",
+ item."readableId" AS "itemReadableId",
+ material."itemType",
+ material."quantity",
+ material."methodType",
+ material."parentMaterialId",
+ material."order",
+ false AS "isRoot"
+FROM material INNER JOIN item ON material."itemId" = item.id
+UNION
+SELECT
+ mm."id" AS "methodMaterialId",
+ NULL AS "makeMethodId",
+ mm.id AS "materialMakeMethodId",
+ mm."itemId",
+ i."readableId" AS "itemReadableId",
+ i."type"::text,
+ 1 AS "quantity",
+ 'Make' AS "methodType",
+ NULL AS "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ true AS "isRoot"
+
+FROM "makeMethod" mm INNER JOIN item i ON mm."itemId" = i.id
+WHERE mm.id = uid
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
\ No newline at end of file
diff --git a/packages/react/package.json b/packages/react/package.json
index d83d336362..573229c25e 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -44,7 +44,7 @@
"autoprefixer": "10.4.14",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
- "cmdk": "^0.2.0",
+ "cmdk": "^1.0.0",
"dompurify": "3.0.5",
"is-hotkey": "^0.2.0",
"novel": "^0.4.2",
diff --git a/packages/react/src/Card.tsx b/packages/react/src/Card.tsx
index 6b845b39cd..c3ce2d893f 100644
--- a/packages/react/src/Card.tsx
+++ b/packages/react/src/Card.tsx
@@ -20,7 +20,7 @@ const CardAction = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
- className={cn("flex flex-col space-y-1.5 p-6", className)}
+ className={cn("flex flex-col space-y-1.5 p-4", className)}
{...props}
/>
)