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: consumable and material routes to remove view from path

Brad Barbin0b2796713215
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx
index 833fd836ec..e35c6ab0d6 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceExplorer.tsx
@@ -189,7 +189,7 @@ function PurchaseInvoiceLineItem({
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
"border-b border-border",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
>
<HStack spacing={2} className="flex-grow min-w-0 pr-10">
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx
index 8a9f881230..3213d27cdd 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceExplorer.tsx
@@ -186,7 +186,7 @@ function SalesInvoiceLineItem({
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
"border-b border-border",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
>
<HStack spacing={2} className="flex-grow min-w-0 pr-10">
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 1b0b579b4b..bcb6a7cd75 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -208,11 +208,16 @@ const BillOfMaterial = ({
materialsById.set(id, material);
});
+ const rulesByField = new Map(
+ configurationRules?.map((rule) => [rule.field, rule]) ?? []
+ );
+
const materials = makeItems(
items,
Array.from(materialsById.values()),
orderState,
- checkedState
+ checkedState,
+ rulesByField
).sort((a, b) => a.data.order - b.data.order);
const onToggleItem = (id: string) => {
@@ -478,10 +483,6 @@ const BillOfMaterial = ({
configuratorDisclosure.onOpen();
};
- const rulesByField = new Map(
- configurationRules?.map((rule) => [rule.field, rule]) ?? []
- );
-
return (
<Card>
<HStack className="justify-between">
@@ -1035,23 +1036,40 @@ function makeItems(
items: ItemType[],
materials: Material[],
orderState: OrderState,
- checkedState: CheckedState
+ checkedState: CheckedState,
+ rulesByField?: Map<string, ConfigurationRule>
): ItemWithData[] {
return materials.map((material) => {
const order = material.id
? (orderState[material.id] ?? material.order)
: material.order;
const checked = material.id ? (checkedState[material.id] ?? false) : false;
- return makeItem(items, material, order, checked);
+ return makeItem(items, material, order, checked, rulesByField);
});
}
+function materialHasRules(
+ materialId: string,
+ rulesByField?: Map<string, ConfigurationRule>
+): boolean {
+ if (!rulesByField) return false;
+ const fields = ["itemId", "quantity", "unitOfMeasureCode", "methodType"];
+ return fields.some((field) =>
+ rulesByField.has(getFieldKey(field, materialId))
+ );
+}
+
function makeItem(
items: ItemType[],
material: Material,
order: number,
- checked: boolean
+ checked: boolean,
+ rulesByField?: Map<string, ConfigurationRule>
): ItemWithData {
+ const hasRules = material.id
+ ? materialHasRules(material.id, rulesByField)
+ : false;
+
return {
id: material.id!,
title: (
@@ -1060,6 +1078,9 @@ function makeItem(
<h3 className="font-semibold truncate">
{getItemReadableId(items, material.itemId) ?? ""}
</h3>
+ {hasRules && (
+ <LuSquareFunction className="h-3.5 w-3.5 text-emerald-500 shrink-0" />
+ )}
{material.itemId && material.itemType && (
<Link to={getLinkToItemDetails(material.itemType, material.itemId)}>
<LuExternalLink className="h-4 w-4 opacity-0 group-hover:opacity-100" />
diff --git a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
index a9fd16a001..c1964c6d02 100644
--- a/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BoMExplorer.tsx
@@ -51,7 +51,8 @@ type BoMExplorerProps = {
itemType: MethodItemType;
makeMethod: MakeMethod;
methods: FlatTreeItem<Method>[];
- operations: MethodOperation[];
+ methodId?: string;
+ operations?: MethodOperation[];
selectedId?: string;
};
@@ -59,6 +60,7 @@ const BoMExplorer = ({
itemType,
makeMethod,
methods,
+ methodId: methodIdProp,
selectedId
}: BoMExplorerProps) => {
const [filterText, setFilterText] = useState("");
@@ -114,8 +116,9 @@ const BoMExplorer = ({
const navigate = useNavigate();
const location = useOptimisticLocation();
- const { itemId, methodId } = params;
+ const { itemId } = params;
if (!itemId) throw new Error("itemId not found");
+ const methodId = methodIdProp ?? params.methodId;
if (!methodId) throw new Error("methodId not found");
const [searchParams, setSearchParams] = useSearchParams();
@@ -283,17 +286,20 @@ const BoMExplorer = ({
methodId,
node.data.methodType === "Make"
? node.data.materialMakeMethodId
- : node.data.makeMethodId
+ : node.data.makeMethodId,
+ node
);
- if (location.pathname !== nodePath) {
- navigate(
- `${nodePath}?materialId=${node.data.methodMaterialId}`,
- { replace: true }
- );
+ const separator = nodePath.includes("?") ? "&" : "?";
+ const fullPath = `${nodePath}${separator}materialId=${node.data.methodMaterialId}`;
+ const nodePathname = nodePath.split("?")[0];
+
+ if (location.pathname !== nodePathname) {
+ navigate(fullPath, { replace: true });
} else {
- setSearchParams({
- materialId: node.data.methodMaterialId
+ setSearchParams((prev) => {
+ prev.set("materialId", node.data.methodMaterialId);
+ return prev;
});
}
}}
@@ -513,9 +519,9 @@ function getRootLink(
) {
switch (itemType) {
case "Part":
- return path.to.partMakeMethod(itemId, methodId);
+ return `${path.to.partDetails(itemId)}?methodId=${methodId}`;
case "Tool":
- return path.to.toolMakeMethod(itemId, methodId);
+ return `${path.to.toolDetails(itemId)}?methodId=${methodId}`;
default:
throw new Error(`Unimplemented BoMExplorer itemType: ${itemType}`);
}
@@ -525,13 +531,14 @@ function getMaterialLink(
itemType: MethodItemType,
itemId: string,
methodId: string,
- makeMethodId: string
+ makeMethodId: string,
+ node: FlatTreeItem<Method>
) {
switch (itemType) {
case "Part":
- return path.to.partManufacturingMaterial(itemId, methodId, makeMethodId);
+ return `${path.to.partMake(itemId, makeMethodId)}?methodId=${methodId}`;
case "Tool":
- return path.to.toolManufacturingMaterial(itemId, methodId, makeMethodId);
+ return `${path.to.toolMake(itemId, makeMethodId)}?methodId=${methodId}`;
default:
throw new Error(`Unimplemented BoMExplorer itemType: ${itemType}`);
}
diff --git a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
index a8af7293ff..d1b07b1821 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
@@ -196,9 +196,9 @@ export function getLinkToItemDetails(type: MethodItemType, id: string) {
export function getLinkToItemManufacturing(type: MethodItemType, id: string) {
switch (type) {
case "Part":
- return path.to.partManufacturing(id);
+ return path.to.partDetails(id);
case "Tool":
- return path.to.toolManufacturing(id);
+ return path.to.toolDetails(id);
default:
return getLinkToItemDetails(type, id);
}
diff --git a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
index 7bb2b0f9b9..88b710ea1e 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
@@ -19,7 +19,7 @@ import {
} from "~/components/Form";
import { usePermissions } from "~/hooks";
-import type { action } from "~/routes/x+/part+/$itemId.manufacturing.$methodId.method";
+import type { action } from "~/routes/x+/part+/$itemId.details";
import { itemManufacturingValidator } from "../../items.models";
type ItemManufacturingFormProps = {
@@ -49,6 +49,7 @@ const ItemManufacturingForm = ({
<CardTitle>Manufacturing</CardTitle>
</CardHeader>
<CardContent>
+ <Hidden name="intent" value="manufacturing" />
<Hidden name="itemId" />
<div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Number name="lotSize" label="Batch Size" />
diff --git a/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx b/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx
index d97c68578a..4b053a94e0 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemNotes.tsx
@@ -76,7 +76,7 @@ const ItemNotes = ({
<>
<Card>
<CardHeader>
- <CardTitle>{title}</CardTitle>
+ <CardTitle>Notes</CardTitle>
<CardDescription>{subTitle}</CardDescription>
</CardHeader>
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
index 0d38fd7df3..cc18b52e04 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
@@ -11,7 +11,6 @@ import {
} from "@carbon/react";
import { useState } from "react";
import type { z } from "zod";
-
import {
CustomFormFields,
Hidden,
@@ -27,6 +26,7 @@ import {
itemPlanningValidator,
itemReorderingPolicies
} from "../../items.models";
+import { ItemReorderPolicy } from "./ItemReorderPolicy";
type ItemPlanningFormProps = {
initialValues: z.infer<typeof itemPlanningValidator>;
@@ -83,7 +83,7 @@ const ItemPlanningForm = ({
name="reorderingPolicy"
label="Reordering Policy"
options={itemReorderingPolicies.map((policy) => ({
- label: policy,
+ label: <ItemReorderPolicy reorderingPolicy={policy} />,
value: policy
}))}
onChange={(selected) => {
diff --git a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
index 88581fec46..bac6be2c3d 100644
--- a/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
+++ b/apps/erp/app/modules/items/ui/Item/MakeMethodTools.tsx
@@ -38,11 +38,9 @@ import {
LuChevronDown,
LuCirclePlus,
LuCopy,
- LuEye,
LuGitBranch,
LuGitFork,
LuGitMerge,
- LuPencil,
LuStar,
LuTriangleAlert
} from "react-icons/lu";
@@ -65,17 +63,20 @@ type MakeMethodToolsProps = {
itemId: string;
type: MethodItemType;
makeMethods: MakeMethod[];
+ currentMethodId?: string;
};
const MakeMethodTools = ({
itemId,
makeMethods,
- type
+ type,
+ currentMethodId
}: MakeMethodToolsProps) => {
const permissions = usePermissions();
const fetcher = useFetcher<{ error: string | null }>();
const params = useParams();
const { methodId, makeMethodId } = params;
+ const activeMethodId = currentMethodId ?? makeMethodId ?? methodId;
const isGetMethodLoading =
fetcher.state !== "idle" && fetcher.formAction === path.to.makeMethodGet;
@@ -97,7 +98,6 @@ const MakeMethodTools = ({
const activeMethodModal = useDisclosure();
const itemLink = type && itemId ? getLinkToItemDetails(type, itemId) : null;
- const activeMethodId = makeMethodId ?? methodId;
const activeMethod =
makeMethods.find((m) => m.id === activeMethodId) ?? makeMethods[0];
@@ -154,46 +154,36 @@ const MakeMethodTools = ({
{makeMethods
.sort((a, b) => b.version - a.version)
.map((makeMethod) => {
- const isCurrent =
- (makeMethod.id === methodId &&
- makeMethodId === undefined) ||
- makeMethod.id === makeMethodId;
-
- const isReadOnly = makeMethod.status !== "Draft";
+ const isCurrent = makeMethod.id === activeMethodId;
return (
<DropdownMenuSub key={makeMethod.id}>
- <DropdownMenuSubTrigger className="flex items-center justify-between gap-4">
- <div className="flex items-center gap-2">
- <LuCheck
- className={cn(!isCurrent && "opacity-0")}
+ <DropdownMenuSubTrigger>
+ <Link
+ to={getPathToMakeMethod(
+ type,
+ itemId,
+ makeMethod.id
+ )}
+ className="flex items-center justify-between gap-4"
+ >
+ <div className="flex items-center gap-2">
+ <LuCheck
+ className={cn(!isCurrent && "opacity-0")}
+ />
+ <span>Version {makeMethod.version}</span>
+ </div>
+ <MakeMethodVersionStatus
+ status={makeMethod.status}
+ isActive={
+ makeMethod.status === "Active" ||
+ makeMethods.length === 1
+ }
/>
- <span>Version {makeMethod.version}</span>
- </div>
- <MakeMethodVersionStatus
- status={makeMethod.status}
- isActive={
- makeMethod.status === "Active" ||
- makeMethods.length === 1
- }
- />
+ </Link>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
- <DropdownMenuItem asChild>
- <Link
- to={getPathToMakeMethod(
- type,
- itemId,
- makeMethod.id
- )}
- >
- <DropdownMenuIcon
- icon={isReadOnly ? <LuEye /> : <LuPencil />}
- />
- {isReadOnly ? "View Version" : "Edit Version"}
- </Link>
- </DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
flushSync(() => {
@@ -205,7 +195,7 @@ const MakeMethodTools = ({
<DropdownMenuIcon icon={<LuCopy />} />
Copy Version
</DropdownMenuItem>
- <DropdownMenuSeparator />
+
{/* <DropdownMenuItem
destructive
disabled={
diff --git a/apps/erp/app/modules/items/ui/Methods/utils.ts b/apps/erp/app/modules/items/ui/Methods/utils.ts
index ad6869f786..e482c3dad1 100644
--- a/apps/erp/app/modules/items/ui/Methods/utils.ts
+++ b/apps/erp/app/modules/items/ui/Methods/utils.ts
@@ -8,9 +8,9 @@ export function getPathToMakeMethod(
) {
switch (type) {
case "Part":
- return path.to.partMakeMethod(id, methodId);
+ return `${path.to.partDetails(id)}?methodId=${methodId}`;
case "Tool":
- return path.to.toolMakeMethod(id, methodId);
+ return `${path.to.toolDetails(id)}?methodId=${methodId}`;
default:
return "#";
}
diff --git a/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx b/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx
index 4447879a74..0f6cf3ecbc 100644
--- a/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/ConfigurationParameters.tsx
@@ -177,7 +177,7 @@ export default function ConfigurationParametersForm({
return (
<>
- <Card isCollapsible defaultCollapsed>
+ <Card isCollapsible>
<CardHeader>
<CardTitle>Configuration Parameters</CardTitle>
</CardHeader>
diff --git a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
index 4e47719996..4c28c54d70 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
@@ -453,7 +453,7 @@ const PartProperties = () => {
key={method.id}
type={isActive ? "Make" : "Make Inactive"}
text={`Version ${method.version}`}
- to={path.to.partMakeMethod(itemId, method.id)}
+ to={`${path.to.partDetails(itemId)}?methodId=${method.id}`}
/>
);
})
diff --git a/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx b/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx
index d4ee875061..e929e84522 100644
--- a/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx
@@ -1,7 +1,6 @@
import {
LuBox,
LuChartLine,
- LuFactory,
LuFileText,
LuReceipt,
LuShoppingCart,
@@ -45,15 +44,6 @@ export function usePartNavigation() {
icon: LuShoppingCart,
shortcut: "Command+Shift+p"
},
- {
- name: "Manufacturing",
- to: path.to.partManufacturing(itemId),
- isDisabled: replenishment === "Buy",
- role: ["employee"],
- icon: LuFactory,
- shortcut: "Command+Shift+m",
- isActive: (pathname: string) => pathname.includes("manufacturing")
- },
{
name: "Accounting",
to: path.to.partCosting(itemId),
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
index 97caf3faf9..6f3ccc9cce 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -417,7 +417,7 @@ const ToolProperties = () => {
key={method.id}
type={isActive ? "Make" : "Make Inactive"}
text={`Version ${method.version}`}
- to={path.to.partMakeMethod(itemId, method.id)}
+ to={`${path.to.toolDetails(itemId)}?methodId=${method.id}`}
/>
);
})
diff --git a/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx b/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx
index 06f58cd9b8..70b0c68f67 100644
--- a/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx
@@ -1,7 +1,6 @@
import {
LuBox,
LuChartLine,
- LuFactory,
LuFileText,
LuShoppingCart,
LuTags
@@ -44,15 +43,6 @@ export function useToolNavigation() {
icon: LuShoppingCart,
shortcut: "Command+Shift+p"
},
- {
- name: "Manufacturing",
- to: path.to.toolManufacturing(itemId),
- isDisabled: replenishment === "Buy",
- role: ["employee"],
- icon: LuFactory,
- shortcut: "Command+Shift+m",
- isActive: (pathname: string) => pathname.includes("manufacturing")
- },
{
name: "Accounting",
to: path.to.toolCosting(itemId),
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx b/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
index 1c9d169956..5466ccbe8d 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobEstimatesVsActuals.tsx
@@ -4,7 +4,6 @@ import {
Card,
CardAction,
CardContent,
- CardDescription,
CardHeader,
CardTitle,
cn,
@@ -259,25 +258,26 @@ const JobEstimatesVsActuals = ({
<HStack className="justify-between items-start">
<CardHeader>
<CardTitle>Estimates vs Actual</CardTitle>
- <CardDescription>
- <div className="flex items-center gap-2">
- <Switch
- variant="small"
- checked={detailsDisclosure.isOpen}
- onCheckedChange={detailsDisclosure.onToggle}
- id="cost-details"
- />
- <label className="text-sm" htmlFor="cost-details">
- Show Details
- </label>
- </div>
- </CardDescription>
</CardHeader>
- <CardAction>
+ <CardAction className="flex flex-col gap-2">
<TabsList className="grid grid-cols-2">
<TabsTrigger value="processes">Processes</TabsTrigger>
<TabsTrigger value="materials">Material</TabsTrigger>
</TabsList>
+ <div className="flex items-center justify-start flex-row-reverse gap-2">
+ <Switch
+ variant="small"
+ checked={detailsDisclosure.isOpen}
+ onCheckedChange={detailsDisclosure.onToggle}
+ id="cost-details"
+ />
+ <label
+ className="text-xs text-muted-foreground"
+ htmlFor="cost-details"
+ >
+ Show Details
+ </label>
+ </div>
</CardAction>
</HStack>
<CardContent>
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx b/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx
index fea471528b..8f8cf2bdbc 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobNotes.tsx
@@ -76,7 +76,7 @@ const JobNotes = ({
<>
<Card>
<CardHeader>
- <CardTitle>{title}</CardTitle>
+ <CardTitle>Notes</CardTitle>
<CardDescription>{subTitle}</CardDescription>
</CardHeader>
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx
index 5980798d44..eab43715ff 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderExplorer.tsx
@@ -188,7 +188,7 @@ function PurchaseOrderLineItem({
<HStack
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
>
<HStack spacing={2} className="flex-grow min-w-0 pr-10">
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
index 39dc4e9283..f1383f10fd 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteExplorer.tsx
@@ -188,7 +188,7 @@ function SupplierQuoteLineItem({
<HStack
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
>
<HStack spacing={2} className="flex-grow min-w-0 pr-10">
diff --git a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx
index 0a40f3bf70..2e45bfdd9e 100644
--- a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx
+++ b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineNotes.tsx
@@ -109,7 +109,7 @@ const OpportunityLineNotes = ({
<Tabs value={tab} onValueChange={setTab}>
<HStack className="w-full justify-between">
<CardHeader>
- <CardTitle>{title}</CardTitle>
+ <CardTitle>Notes</CardTitle>
<CardDescription>
{subTitle} -{" "}
{tab === "internal" ? "Internal Notes" : "External Notes"}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
index 976462262a..d36efc96ee 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
@@ -380,7 +380,7 @@ function QuoteLineItem({
<HStack
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
onClick={() => onLineClick(line)}
>
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
index 59fc0a41a9..5d959bb8d1 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
@@ -277,7 +277,7 @@ function SalesOrderLineItem({
<HStack
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
onClick={onLineClick}
>
diff --git a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
index 85d98c6ec7..37090bc40e 100644
--- a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
@@ -279,7 +279,7 @@ function SalesRFQLineItem({
<HStack
className={cn(
"group w-full p-2 items-center hover:bg-accent/30 cursor-pointer relative",
- isSelected && "bg-accent/60 hover:bg-accent/50 shadow-inner"
+ isSelected && "bg-accent/60 hover:bg-accent/50"
)}
>
<HStack spacing={2} className="flex-grow min-w-0 pr-10">
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.costing.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.costing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/consumable+/$itemId.view.costing.tsx
rename to apps/erp/app/routes/x+/consumable+/$itemId.costing.tsx
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.details.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx
rename to apps/erp/app/routes/x+/consumable+/$itemId.details.tsx
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsx
rename to apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.planning.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/consumable+/$itemId.view.planning.tsx
rename to apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.new.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.new.tsx
rename to apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.tsx
rename to apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
index 252ffe49d1..989a723df0 100644
--- a/apps/erp/app/routes/x+/consumable+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/consumable+/$itemId.tsx
@@ -1,15 +1,31 @@
-import { error, getCarbonServiceRole } from "@carbon/auth";
+import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import { useRouteData } from "@carbon/remix";
+import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, redirect } from "react-router";
+import {
+ Await,
+ Outlet,
+ redirect,
+ useLoaderData,
+ useParams
+} from "react-router";
+import { ResizablePanels } from "~/components/Layout";
+import type { ConsumableSummary, ItemFile } from "~/modules/items";
import {
getConsumable,
getItemFiles,
+ getMaterialUsedIn,
getPickMethods,
getSupplierParts
} from "~/modules/items";
-import { ConsumableHeader } from "~/modules/items/ui/Consumables";
+import {
+ ConsumableHeader,
+ ConsumableProperties
+} from "~/modules/items/ui/Consumables";
+import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
+import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
import { getTagsList } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -21,21 +37,20 @@ export const handle: Handle = {
};
export async function loader({ request, params }: LoaderFunctionArgs) {
- const { companyId } = await requirePermissions(request, {
- view: "parts"
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ bypassRls: true
});
- const serviceRole = await getCarbonServiceRole();
-
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
const [consumableSummary, supplierParts, pickMethods, tags] =
await Promise.all([
- getConsumable(serviceRole, itemId, companyId),
- getSupplierParts(serviceRole, itemId, companyId),
- getPickMethods(serviceRole, itemId, companyId),
- getTagsList(serviceRole, companyId, "consumable")
+ getConsumable(client, itemId, companyId),
+ getSupplierParts(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ getTagsList(client, companyId, "consumable")
]);
if (consumableSummary.error) {
@@ -50,18 +65,153 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return {
consumableSummary: consumableSummary.data,
- files: getItemFiles(serviceRole, itemId, companyId),
+ files: getItemFiles(client, itemId, companyId),
supplierParts: supplierParts.data ?? [],
pickMethods: pickMethods.data ?? [],
- tags: tags.data ?? []
+ tags: tags.data ?? [],
+ usedIn: getMaterialUsedIn(client, itemId, companyId)
};
}
export default function ConsumableRoute() {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const consumableData = useRouteData<{
+ consumableSummary: ConsumableSummary;
+ files: Promise<ItemFile[]>;
+ }>(path.to.consumable(itemId));
+
+ if (!consumableData) throw new Error("Could not find consumable data");
+
+ const { usedIn } = useLoaderData<typeof loader>();
+
return (
<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
<ConsumableHeader />
- <Outlet />
+ <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
+ <div className="flex flex-grow overflow-hidden">
+ <ResizablePanels
+ explorer={
+ <Suspense fallback={<UsedInSkeleton />}>
+ <Await resolve={usedIn}>
+ {(resolvedUsedIn) => {
+ const {
+ issues,
+ jobMaterials,
+ maintenanceDispatchItems,
+ methodMaterials,
+ purchaseOrderLines,
+ receiptLines,
+ quoteMaterials,
+ salesOrderLines,
+ shipmentLines,
+ supplierQuotes
+ } = resolvedUsedIn;
+
+ const tree: UsedInNode[] = [
+ {
+ key: "issues",
+ name: "Issues",
+ module: "quality",
+ children: issues
+ },
+ {
+ key: "jobMaterials",
+ name: "Job Materials",
+ module: "production",
+ children: jobMaterials
+ },
+ {
+ key: "maintenanceDispatchItems",
+ name: "Maintenance",
+ module: "resources",
+ children: maintenanceDispatchItems
+ },
+ {
+ key: "methodMaterials",
+ name: "Method Materials",
+ module: "parts",
+ // @ts-expect-error
+ children: methodMaterials
+ },
+ {
+ key: "purchaseOrderLines",
+ name: "Purchase Orders",
+ module: "purchasing",
+ children: purchaseOrderLines.map((po) => ({
+ ...po,
+ methodType: "Buy"
+ }))
+ },
+ {
+ key: "receiptLines",
+ name: "Receipts",
+ module: "inventory",
+ children: receiptLines.map((receipt) => ({
+ ...receipt,
+ methodType: "Pick"
+ }))
+ },
+
+ {
+ key: "quoteMaterials",
+ name: "Quote Materials",
+ module: "sales",
+ children: quoteMaterials?.map((qm) => ({
+ ...qm,
+ documentReadableId: qm.documentReadableId ?? ""
+ }))
+ },
+ {
+ key: "salesOrderLines",
+ name: "Sales Orders",
+ module: "sales",
+ children: salesOrderLines
+ },
+ {
+ key: "shipmentLines",
+ name: "Shipments",
+ module: "inventory",
+ children: shipmentLines.map((shipment) => ({
+ ...shipment,
+ methodType: "Shipment"
+ }))
+ },
+ {
+ key: "supplierQuotes",
+ name: "Supplier Quotes",
+ module: "purchasing",
+ children: supplierQuotes
+ }
+ ];
+
+ return (
+ <UsedInTree
+ tree={tree}
+ revisions={consumableData.consumableSummary?.revisions}
+ itemReadableId={
+ consumableData.consumableSummary?.readableId ?? ""
+ }
+ itemReadableIdWithRevision={
+ consumableData.consumableSummary
+ ?.readableIdWithRevision ?? ""
+ }
+ />
+ );
+ }}
+ </Await>
+ </Suspense>
+ }
+ content={
+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
+ <Outlet />
+ </div>
+ }
+ properties={<ConsumableProperties />}
+ />
+ </div>
+ </div>
</div>
);
}
diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.tsx
deleted file mode 100644
index bf7d0c9781..0000000000
--- a/apps/erp/app/routes/x+/consumable+/$itemId.view.tsx
+++ /dev/null
@@ -1,164 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { useRouteData } from "@carbon/remix";
-import { Suspense } from "react";
-import type { LoaderFunctionArgs } from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
-import { ResizablePanels } from "~/components/Layout";
-import type { ConsumableSummary, ItemFile } from "~/modules/items";
-import { getMaterialUsedIn } from "~/modules/items";
-import ConsumableProperties from "~/modules/items/ui/Consumables/ConsumableProperties";
-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- bypassRls: true
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return { usedIn: getMaterialUsedIn(client, itemId, companyId) };
-}
-
-export default function ConsumableViewRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const consumableData = useRouteData<{
- consumableSummary: ConsumableSummary;
- files: Promise<ItemFile[]>;
- }>(path.to.consumable(itemId));
-
- if (!consumableData) throw new Error("Could not find material data");
-
- const { usedIn } = useLoaderData<typeof loader>();
-
- return (
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <ResizablePanels
- explorer={
- <Suspense fallback={<UsedInSkeleton />}>
- <Await resolve={usedIn}>
- {(resolvedUsedIn) => {
- const {
- issues,
- jobMaterials,
- maintenanceDispatchItems,
- methodMaterials,
- purchaseOrderLines,
- receiptLines,
- quoteMaterials,
- salesOrderLines,
- shipmentLines,
- supplierQuotes
- } = resolvedUsedIn;
-
- const tree: UsedInNode[] = [
- {
- key: "issues",
- name: "Issues",
- module: "quality",
- children: issues
- },
- {
- key: "jobMaterials",
- name: "Job Materials",
- module: "production",
- children: jobMaterials
- },
- {
- key: "maintenanceDispatchItems",
- name: "Maintenance",
- module: "resources",
- children: maintenanceDispatchItems
- },
- {
- key: "methodMaterials",
- name: "Method Materials",
- module: "parts",
- // @ts-expect-error
- children: methodMaterials
- },
- {
- key: "purchaseOrderLines",
- name: "Purchase Orders",
- module: "purchasing",
- children: purchaseOrderLines.map((po) => ({
- ...po,
- methodType: "Buy"
- }))
- },
- {
- key: "receiptLines",
- name: "Receipts",
- module: "inventory",
- children: receiptLines.map((receipt) => ({
- ...receipt,
- methodType: "Pick"
- }))
- },
-
- {
- key: "quoteMaterials",
- name: "Quote Materials",
- module: "sales",
- children: quoteMaterials?.map((qm) => ({
- ...qm,
- documentReadableId: qm.documentReadableId ?? ""
- }))
- },
- {
- key: "salesOrderLines",
- name: "Sales Orders",
- module: "sales",
- children: salesOrderLines
- },
- {
- key: "shipmentLines",
- name: "Shipments",
- module: "inventory",
- children: shipmentLines.map((shipment) => ({
- ...shipment,
- methodType: "Shipment"
- }))
- },
- {
- key: "supplierQuotes",
- name: "Supplier Quotes",
- module: "purchasing",
- children: supplierQuotes
- }
- ];
-
- return (
- <UsedInTree
- tree={tree}
- revisions={consumableData.consumableSummary?.revisions}
- itemReadableId={
- consumableData.consumableSummary?.readableId ?? ""
- }
- itemReadableIdWithRevision={
- consumableData.consumableSummary
- ?.readableIdWithRevision ?? ""
- }
- />
- );
- }}
- </Await>
- </Suspense>
- }
- content={
- <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
- </div>
- }
- properties={<ConsumableProperties />}
- />
- </div>
- </div>
- );
-}
diff --git a/apps/erp/app/routes/x+/customer+/new.tsx b/apps/erp/app/routes/x+/customer+/new.tsx
index 447fa4ce18..c07f475715 100644
--- a/apps/erp/app/routes/x+/customer+/new.tsx
+++ b/apps/erp/app/routes/x+/customer+/new.tsx
@@ -73,8 +73,7 @@ export default function CustomersNewRoute() {
phone: "",
fax: "",
website: "",
- taxPercent: 0,
- defaultCC: []
+ taxPercent: 0
};
return (
diff --git a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
index 92638d54b3..584aad4b96 100644
--- a/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
+++ b/apps/erp/app/routes/x+/inventory+/quantities+/$itemId.details.tsx
@@ -1,6 +1,8 @@
import { error, notFound } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import type { JSONContent } from "@carbon/react";
+import { VStack } from "@carbon/react";
import type { LoaderFunctionArgs } from "react-router";
import { redirect, useLoaderData } from "react-router";
import { useShelves } from "~/components/Form/Shelf";
@@ -9,10 +11,17 @@ import {
getItem,
getItemQuantities,
getItemShelfQuantities,
+ getMakeMethodById,
+ getMakeMethods,
+ getMethodMaterialsByMakeMethod,
+ getMethodOperationsByMakeMethodId,
getPickMethod,
upsertPickMethod
} from "~/modules/items";
+import { BillOfMaterial, BillOfProcess } from "~/modules/items/ui/Item";
import { getLocationsList } from "~/modules/resources";
+import type { MethodItemType, MethodType } from "~/modules/shared";
+import { getTagsList } from "~/modules/shared";
import { getUserDefaults } from "~/modules/users/users.server";
import { useItems } from "~/stores/items";
import { path } from "~/utils/path";
@@ -130,17 +139,72 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
+ // Load manufacturing data for manufactured parts
+ let methodData = null;
+ let tags: { name: string }[] = [];
+
+ if (item.data.replenishmentSystem !== "Buy") {
+ const makeMethods = await getMakeMethods(client, itemId, companyId);
+ const makeMethod =
+ makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0];
+
+ if (makeMethod) {
+ const fullMethod = await getMakeMethodById(
+ client,
+ makeMethod.id,
+ companyId
+ );
+ if (!fullMethod.error && fullMethod.data) {
+ const [methodMaterials, methodOperations, operationTags] =
+ await Promise.all([
+ getMethodMaterialsByMakeMethod(client, fullMethod.data.id),
+ getMethodOperationsByMakeMethodId(client, fullMethod.data.id),
+ getTagsList(client, companyId, "operation")
+ ]);
+
+ methodData = {
+ makeMethod: fullMethod.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,
+ workCenterId: operation.workCenterId ?? undefined,
+ operationSupplierProcessId:
+ operation.operationSupplierProcessId ?? undefined,
+ workInstruction: operation.workInstruction as JSONContent | null
+ })) ?? []
+ };
+ tags = operationTags.data ?? [];
+ }
+ }
+ }
+
return {
pickMethod: pickMethod.data,
quantities: quantities.data,
itemShelfQuantities: itemShelfQuantities.data,
- item: item.data
+ item: item.data,
+ methodData,
+ tags
};
}
export default function ItemInventoryRoute() {
- const { pickMethod, quantities, itemShelfQuantities, item } =
- useLoaderData<typeof loader>();
+ const {
+ pickMethod,
+ quantities,
+ itemShelfQuantities,
+ item,
+ methodData,
+ tags
+ } = useLoaderData<typeof loader>();
const [items] = useItems();
const itemTrackingType = items.find(
@@ -150,16 +214,37 @@ export default function ItemInventoryRoute() {
const shelves = useShelves(pickMethod?.locationId);
return (
- <InventoryDetails
- itemShelfQuantities={itemShelfQuantities}
- itemUnitOfMeasureCode={item.unitOfMeasureCode ?? "EA"}
- itemTrackingType={itemTrackingType ?? "Inventory"}
- pickMethod={{
- ...pickMethod,
- defaultShelfId: pickMethod.defaultShelfId ?? undefined
- }}
- quantities={quantities}
- shelves={shelves.options}
- />
+ <VStack spacing={2}>
+ <InventoryDetails
+ itemShelfQuantities={itemShelfQuantities}
+ itemUnitOfMeasureCode={item.unitOfMeasureCode ?? "EA"}
+ itemTrackingType={itemTrackingType ?? "Inventory"}
+ pickMethod={{
+ ...pickMethod,
+ defaultShelfId: pickMethod.defaultShelfId ?? undefined
+ }}
+ quantities={quantities}
+ shelves={shelves.options}
+ />
+ {methodData && (
+ <>
+ <BillOfMaterial
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ materials={methodData.methodMaterials}
+ // @ts-ignore
+ operations={methodData.methodOperations}
+ />
+ <BillOfProcess
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ operations={methodData.methodOperations}
+ // @ts-ignore
+ materials={methodData.methodMaterials}
+ tags={tags}
+ />
+ </>
+ )}
+ </VStack>
);
}
diff --git a/apps/erp/app/routes/x+/job+/$jobId.details.tsx b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
index 0bd8d7cfb8..0618754be7 100644
--- a/apps/erp/app/routes/x+/job+/$jobId.details.tsx
+++ b/apps/erp/app/routes/x+/job+/$jobId.details.tsx
@@ -226,12 +226,6 @@ export default function JobDetailsRoute() {
<div className="h-[calc(100dvh-49px)] w-full items-start overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent">
<VStack spacing={2} className="p-2">
<JobMakeMethodTools makeMethod={makeMethod ?? undefined} />
- <JobNotes
- id={jobId}
- title={jobData?.job.jobId ?? ""}
- subTitle={jobData?.job.itemReadableIdWithRevision ?? ""}
- notes={notes}
- />
{methodId && (
<>
@@ -258,6 +252,15 @@ export default function JobDetailsRoute() {
/>
</>
)}
+ <Suspense>
+ <Await resolve={purchaseOrderLines}>
+ {(purchaseOrderLines) => (
+ <JobPurchaseOrderLines
+ purchaseOrderLines={purchaseOrderLines.data ?? []}
+ />
+ )}
+ </Await>
+ </Suspense>
<Suspense
fallback={
@@ -281,6 +284,13 @@ export default function JobDetailsRoute() {
</Await>
</Suspense>
+ <JobNotes
+ id={jobId}
+ title={jobData?.job.jobId ?? ""}
+ subTitle={jobData?.job.itemReadableIdWithRevision ?? ""}
+ notes={notes}
+ />
+
<Suspense
fallback={
<div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center min-h-[420px] max-h-[70vh]">
@@ -301,15 +311,6 @@ export default function JobDetailsRoute() {
</Await>
</Suspense>
- <Suspense>
- <Await resolve={purchaseOrderLines}>
- {(purchaseOrderLines) => (
- <JobPurchaseOrderLines
- purchaseOrderLines={purchaseOrderLines.data ?? []}
- />
- )}
- </Await>
- </Suspense>
<CadModel
isReadOnly={!permissions.can("update", "production")}
metadata={{
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.costing.tsx b/apps/erp/app/routes/x+/material+/$itemId.costing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/material+/$itemId.view.costing.tsx
rename to apps/erp/app/routes/x+/material+/$itemId.costing.tsx
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/material+/$itemId.details.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/material+/$itemId.view.details.tsx
rename to apps/erp/app/routes/x+/material+/$itemId.details.tsx
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsx
rename to apps/erp/app/routes/x+/material+/$itemId.inventory.tsx
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.planning.tsx b/apps/erp/app/routes/x+/material+/$itemId.planning.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/material+/$itemId.view.planning.tsx
rename to apps/erp/app/routes/x+/material+/$itemId.planning.tsx
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.purchasing.new.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/material+/$itemId.view.purchasing.new.tsx
rename to apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.purchasing.tsx b/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/material+/$itemId.view.purchasing.tsx
rename to apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx
diff --git a/apps/erp/app/routes/x+/material+/$itemId.tsx b/apps/erp/app/routes/x+/material+/$itemId.tsx
index 29bb9cb117..e7cb9c8cde 100644
--- a/apps/erp/app/routes/x+/material+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/material+/$itemId.tsx
@@ -1,16 +1,32 @@
-import { error, getCarbonServiceRole } from "@carbon/auth";
+import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import { useRouteData } from "@carbon/remix";
+import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, redirect } from "react-router";
+import {
+ Await,
+ Outlet,
+ redirect,
+ useLoaderData,
+ useParams
+} from "react-router";
+import { ResizablePanels } from "~/components/Layout";
+import type { ItemFile, MaterialSummary } from "~/modules/items";
import {
getItemFiles,
getMakeMethods,
getMaterial,
+ getMaterialUsedIn,
getPickMethods,
getSupplierParts
} from "~/modules/items";
-import { MaterialHeader } from "~/modules/items/ui/Materials";
+import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
+import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
+import {
+ MaterialHeader,
+ MaterialProperties
+} from "~/modules/items/ui/Materials";
import { getTagsList } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -22,20 +38,20 @@ export const handle: Handle = {
};
export async function loader({ request, params }: LoaderFunctionArgs) {
- const { companyId } = await requirePermissions(request, {
- view: "parts"
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ bypassRls: true
});
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const serviceRole = await getCarbonServiceRole();
const [materialSummary, supplierParts, pickMethods, tags] = await Promise.all(
[
- getMaterial(serviceRole, itemId, companyId),
- getSupplierParts(serviceRole, itemId, companyId),
- getPickMethods(serviceRole, itemId, companyId),
- getTagsList(serviceRole, companyId, "material")
+ getMaterial(client, itemId, companyId),
+ getSupplierParts(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ getTagsList(client, companyId, "material")
]
);
@@ -51,19 +67,155 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return {
materialSummary: materialSummary.data,
- files: getItemFiles(serviceRole, itemId, companyId),
+ files: getItemFiles(client, itemId, companyId),
supplierParts: supplierParts.data ?? [],
pickMethods: pickMethods.data ?? [],
- makeMethods: getMakeMethods(serviceRole, itemId, companyId),
- tags: tags.data ?? []
+ makeMethods: getMakeMethods(client, itemId, companyId),
+ tags: tags.data ?? [],
+ usedIn: getMaterialUsedIn(client, itemId, companyId)
};
}
export default function MaterialRoute() {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const materialData = useRouteData<{
+ materialSummary: MaterialSummary;
+ files: Promise<ItemFile[]>;
+ }>(path.to.material(itemId));
+
+ if (!materialData) throw new Error("Could not find material data");
+
+ const { usedIn } = useLoaderData<typeof loader>();
+
return (
<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
<MaterialHeader />
- <Outlet />
+ <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
+ <div className="flex flex-grow overflow-hidden">
+ <ResizablePanels
+ explorer={
+ <Suspense fallback={<UsedInSkeleton />}>
+ <Await resolve={usedIn}>
+ {(resolvedUsedIn) => {
+ const {
+ issues,
+ jobMaterials,
+ maintenanceDispatchItems,
+ methodMaterials,
+ purchaseOrderLines,
+ receiptLines,
+ quoteMaterials,
+ salesOrderLines,
+ shipmentLines,
+ supplierQuotes
+ } = resolvedUsedIn;
+
+ const tree: UsedInNode[] = [
+ {
+ key: "issues",
+ name: "Issues",
+ module: "quality",
+ children: issues
+ },
+ {
+ key: "jobMaterials",
+ name: "Job Materials",
+ module: "production",
+ children: jobMaterials
+ },
+ {
+ key: "maintenanceDispatchItems",
+ name: "Maintenance",
+ module: "resources",
+ children: maintenanceDispatchItems
+ },
+ {
+ key: "methodMaterials",
+ name: "Method Materials",
+ module: "parts",
+ // @ts-expect-error
+ children: methodMaterials
+ },
+ {
+ key: "purchaseOrderLines",
+ name: "Purchase Orders",
+ module: "purchasing",
+ children: purchaseOrderLines.map((po) => ({
+ ...po,
+ methodType: "Buy"
+ }))
+ },
+ {
+ key: "receiptLines",
+ name: "Receipts",
+ module: "inventory",
+ children: receiptLines.map((receipt) => ({
+ ...receipt,
+ methodType: "Pick"
+ }))
+ },
+
+ {
+ key: "quoteMaterials",
+ name: "Quote Materials",
+ module: "sales",
+ children: quoteMaterials?.map((qm) => ({
+ ...qm,
+ documentReadableId: qm.documentReadableId ?? ""
+ }))
+ },
+ {
+ key: "salesOrderLines",
+ name: "Sales Orders",
+ module: "sales",
+ children: salesOrderLines
+ },
+ {
+ key: "shipmentLines",
+ name: "Shipments",
+ module: "inventory",
+ children: shipmentLines.map((shipment) => ({
+ ...shipment,
+ methodType: "Shipment"
+ }))
+ },
+ {
+ key: "supplierQuotes",
+ name: "Supplier Quotes",
+ module: "purchasing",
+ children: supplierQuotes
+ }
+ ];
+
+ return (
+ <UsedInTree
+ tree={tree}
+ hasSizesInsteadOfRevisions={true}
+ revisions={materialData.materialSummary?.revisions}
+ itemReadableId={
+ materialData.materialSummary?.readableId ?? ""
+ }
+ itemReadableIdWithRevision={
+ materialData.materialSummary
+ ?.readableIdWithRevision ?? ""
+ }
+ />
+ );
+ }}
+ </Await>
+ </Suspense>
+ }
+ content={
+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
+ <Outlet />
+ </div>
+ }
+ properties={<MaterialProperties />}
+ />
+ </div>
+ </div>
</div>
);
}
diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.tsx
deleted file mode 100644
index 69d96cdc9f..0000000000
--- a/apps/erp/app/routes/x+/material+/$itemId.view.tsx
+++ /dev/null
@@ -1,165 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { useRouteData } from "@carbon/remix";
-import { Suspense } from "react";
-import type { LoaderFunctionArgs } from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
-import { ResizablePanels } from "~/components/Layout";
-import type { ItemFile, MaterialSummary } from "~/modules/items";
-import { getMaterialUsedIn } from "~/modules/items";
-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
-import MaterialProperties from "~/modules/items/ui/Materials/MaterialProperties";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- bypassRls: true
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return { usedIn: getMaterialUsedIn(client, itemId, companyId) };
-}
-
-export default function MaterialViewRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const materialData = useRouteData<{
- materialSummary: MaterialSummary;
- files: Promise<ItemFile[]>;
- }>(path.to.material(itemId));
-
- if (!materialData) throw new Error("Could not find material data");
-
- const { usedIn } = useLoaderData<typeof loader>();
-
- return (
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <ResizablePanels
- explorer={
- <Suspense fallback={<UsedInSkeleton />}>
- <Await resolve={usedIn}>
- {(resolvedUsedIn) => {
- const {
- issues,
- jobMaterials,
- maintenanceDispatchItems,
- methodMaterials,
- purchaseOrderLines,
- receiptLines,
- quoteMaterials,
- salesOrderLines,
- shipmentLines,
- supplierQuotes
- } = resolvedUsedIn;
-
- const tree: UsedInNode[] = [
- {
- key: "issues",
- name: "Issues",
- module: "quality",
- children: issues
- },
- {
- key: "jobMaterials",
- name: "Job Materials",
- module: "production",
- children: jobMaterials
- },
- {
- key: "maintenanceDispatchItems",
- name: "Maintenance",
- module: "resources",
- children: maintenanceDispatchItems
- },
- {
- key: "methodMaterials",
- name: "Method Materials",
- module: "parts",
- // @ts-expect-error
- children: methodMaterials
- },
- {
- key: "purchaseOrderLines",
- name: "Purchase Orders",
- module: "purchasing",
- children: purchaseOrderLines.map((po) => ({
- ...po,
- methodType: "Buy"
- }))
- },
- {
- key: "receiptLines",
- name: "Receipts",
- module: "inventory",
- children: receiptLines.map((receipt) => ({
- ...receipt,
- methodType: "Pick"
- }))
- },
-
- {
- key: "quoteMaterials",
- name: "Quote Materials",
- module: "sales",
- children: quoteMaterials?.map((qm) => ({
- ...qm,
- documentReadableId: qm.documentReadableId ?? ""
- }))
- },
- {
- key: "salesOrderLines",
- name: "Sales Orders",
- module: "sales",
- children: salesOrderLines
- },
- {
- key: "shipmentLines",
- name: "Shipments",
- module: "inventory",
- children: shipmentLines.map((shipment) => ({
- ...shipment,
- methodType: "Shipment"
- }))
- },
- {
- key: "supplierQuotes",
- name: "Supplier Quotes",
- module: "purchasing",
- children: supplierQuotes
- }
- ];
-
- return (
- <UsedInTree
- tree={tree}
- hasSizesInsteadOfRevisions={true}
- revisions={materialData.materialSummary?.revisions}
- itemReadableId={
- materialData.materialSummary?.readableId ?? ""
- }
- itemReadableIdWithRevision={
- materialData.materialSummary?.readableIdWithRevision ??
- ""
- }
- />
- );
- }}
- </Await>
- </Suspense>
- }
- content={
- <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
- </div>
- }
- properties={<MaterialProperties />}
- />
- </div>
- </div>
- );
-}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.costing.tsx b/apps/erp/app/routes/x+/part+/$itemId.costing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.costing.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.costing.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
new file mode 100644
index 0000000000..8f8c1e174b
--- /dev/null
+++ b/apps/erp/app/routes/x+/part+/$itemId.details.tsx
@@ -0,0 +1,326 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import type { JSONContent } from "@carbon/react";
+import { Menubar, Spinner, VStack } from "@carbon/react";
+import type { PostgrestResponse } from "@supabase/supabase-js";
+import { Suspense } from "react";
+import type {
+ ActionFunctionArgs,
+ ClientActionFunctionArgs,
+ LoaderFunctionArgs
+} from "react-router";
+import { Await, redirect, useLoaderData, useParams } from "react-router";
+import { CadModel } from "~/components";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { ItemFile, MakeMethod, PartSummary } from "~/modules/items";
+import {
+ getConfigurationParameters,
+ getConfigurationRules,
+ getItemManufacturing,
+ getMakeMethodById,
+ getMakeMethods,
+ getMethodMaterialsByMakeMethod,
+ getMethodOperationsByMakeMethodId,
+ itemManufacturingValidator,
+ partValidator,
+ upsertItemManufacturing,
+ upsertPart
+} from "~/modules/items";
+import {
+ BillOfMaterial,
+ BillOfProcess,
+ ItemDocuments,
+ ItemNotes,
+ ItemRiskRegister,
+ MakeMethodTools
+} from "~/modules/items/ui/Item";
+import ItemManufacturingForm from "~/modules/items/ui/Item/ItemManufacturingForm";
+import { ConfigurationParametersForm } from "~/modules/items/ui/Parts";
+import type { MethodItemType, MethodType } from "~/modules/shared";
+import { getTagsList } from "~/modules/shared";
+import { getCustomFields, setCustomFields } from "~/utils/form";
+import { path } from "~/utils/path";
+import { configurableItemsQuery, getCompanyId } from "~/utils/react-query";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ bypassRls: true
+ });
+
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const url = new URL(request.url);
+ const requestedMethodId = url.searchParams.get("methodId");
+
+ const makeMethods = await getMakeMethods(client, itemId, companyId);
+ const makeMethod = requestedMethodId
+ ? (makeMethods.data?.find((m) => m.id === requestedMethodId) ??
+ makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0])
+ : (makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0]);
+
+ if (!makeMethod) {
+ return { methodData: null, tags: [] };
+ }
+
+ const fullMethod = await getMakeMethodById(client, makeMethod.id, companyId);
+ if (fullMethod.error || !fullMethod.data) {
+ return { methodData: null, tags: [] };
+ }
+
+ const [methodMaterials, methodOperations, tags, partManufacturing] =
+ await Promise.all([
+ getMethodMaterialsByMakeMethod(client, fullMethod.data.id),
+ getMethodOperationsByMakeMethodId(client, fullMethod.data.id),
+ getTagsList(client, companyId, "operation"),
+ getItemManufacturing(client, itemId, companyId)
+ ]);
+
+ const configData = partManufacturing.data?.requiresConfiguration
+ ? {
+ configurationParametersAndGroups: await getConfigurationParameters(
+ client,
+ itemId,
+ companyId
+ ),
+ configurationRules: await getConfigurationRules(
+ client,
+ itemId,
+ companyId
+ )
+ }
+ : {
+ configurationParametersAndGroups: { groups: [], parameters: [] },
+ configurationRules: []
+ };
+
+ return {
+ methodData: {
+ makeMethod: fullMethod.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,
+ workCenterId: operation.workCenterId ?? undefined,
+ operationSupplierProcessId:
+ operation.operationSupplierProcessId ?? undefined,
+ workInstruction: operation.workInstruction as JSONContent | null
+ })) ?? [],
+ partManufacturing: partManufacturing.data,
+ ...configData
+ },
+ tags: tags.data ?? []
+ };
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "parts"
+ });
+
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const formData = await request.formData();
+ const intent = formData.get("intent");
+
+ if (intent === "manufacturing") {
+ const validation = await validator(itemManufacturingValidator).validate(
+ formData
+ );
+
+ if (validation.error) {
+ console.error(validation.error);
+ return validationError(validation.error);
+ }
+
+ const updatePartManufacturing = await upsertItemManufacturing(client, {
+ ...validation.data,
+ requiresConfiguration: validation.data.requiresConfiguration ?? false,
+ itemId,
+ updatedBy: userId,
+ customFields: setCustomFields(formData)
+ });
+ if (updatePartManufacturing.error) {
+ throw redirect(
+ path.to.part(itemId),
+ await flash(
+ request,
+ error(
+ updatePartManufacturing.error,
+ "Failed to update part manufacturing"
+ )
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.partDetails(itemId),
+ await flash(request, success("Updated part manufacturing"))
+ );
+ }
+
+ const validation = await validator(partValidator).validate(formData);
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const updatePart = await upsertPart(client, {
+ ...validation.data,
+ id: itemId,
+ customFields: setCustomFields(formData),
+ updatedBy: userId
+ });
+ if (updatePart.error) {
+ throw redirect(
+ path.to.part(itemId),
+ await flash(request, error(updatePart.error, "Failed to update part"))
+ );
+ }
+
+ throw redirect(
+ path.to.part(itemId),
+ await flash(request, success("Updated part"))
+ );
+}
+
+export async function clientAction({ serverAction }: ClientActionFunctionArgs) {
+ window.clientCache?.setQueryData(
+ configurableItemsQuery(getCompanyId()).queryKey,
+ null
+ );
+ return await serverAction();
+}
+
+export default function PartDetailsRoute() {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const permissions = usePermissions();
+ const { methodData, tags } = useLoaderData<typeof loader>();
+
+ const partData = useRouteData<{
+ partSummary: PartSummary;
+ files: Promise<ItemFile[]>;
+ makeMethods: Promise<PostgrestResponse<MakeMethod>>;
+ }>(path.to.part(itemId));
+
+ if (!partData) throw new Error("Could not find part data");
+
+ const manufacturingInitialValues = methodData?.partManufacturing
+ ? {
+ ...methodData.partManufacturing,
+ lotSize: methodData.partManufacturing.lotSize ?? 0,
+ ...getCustomFields(methodData.partManufacturing.customFields)
+ }
+ : null;
+
+ return (
+ <VStack spacing={2} className="p-2">
+ {permissions.is("employee") && methodData && (
+ <>
+ <Suspense fallback={<Menubar />}>
+ <Await resolve={partData?.makeMethods}>
+ {(makeMethods) => (
+ <MakeMethodTools
+ itemId={methodData.makeMethod.itemId}
+ makeMethods={makeMethods?.data ?? []}
+ type="Part"
+ currentMethodId={methodData.makeMethod.id}
+ />
+ )}
+ </Await>
+ </Suspense>
+ {manufacturingInitialValues && (
+ <ItemManufacturingForm
+ key={itemId}
+ // @ts-ignore
+ initialValues={manufacturingInitialValues}
+ />
+ )}
+ {methodData.partManufacturing?.requiresConfiguration && (
+ <ConfigurationParametersForm
+ key={`options:${itemId}`}
+ parameters={
+ methodData.configurationParametersAndGroups.parameters
+ }
+ groups={methodData.configurationParametersAndGroups.groups}
+ />
+ )}
+ <BillOfMaterial
+ key={`bom:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ materials={methodData.methodMaterials ?? []}
+ // @ts-ignore
+ operations={methodData.methodOperations}
+ configurable={methodData.partManufacturing?.requiresConfiguration}
+ configurationRules={methodData.configurationRules}
+ parameters={methodData.configurationParametersAndGroups.parameters}
+ />
+ <BillOfProcess
+ key={`bop:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ operations={methodData.methodOperations ?? []}
+ configurable={methodData.partManufacturing?.requiresConfiguration}
+ // @ts-ignore
+ materials={methodData.methodMaterials ?? []}
+ configurationRules={methodData.configurationRules}
+ parameters={methodData.configurationParametersAndGroups.parameters}
+ tags={tags}
+ />
+ </>
+ )}
+ {permissions.is("employee") && (
+ <>
+ <ItemNotes
+ id={partData.partSummary?.id ?? null}
+ title={partData.partSummary?.name ?? ""}
+ subTitle={partData.partSummary?.readableIdWithRevision ?? ""}
+ notes={partData.partSummary?.notes as JSONContent}
+ />
+ <Suspense
+ fallback={
+ <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
+ <Spinner className="h-10 w-10" />
+ </div>
+ }
+ >
+ <Await resolve={partData?.files}>
+ {(resolvedFiles) => (
+ <ItemDocuments
+ files={resolvedFiles}
+ itemId={itemId}
+ modelUpload={partData.partSummary ?? undefined}
+ type="Part"
+ />
+ )}
+ </Await>
+ </Suspense>
+
+ <CadModel
+ isReadOnly={!permissions.can("update", "parts")}
+ metadata={{ itemId }}
+ modelPath={partData?.partSummary?.modelPath ?? null}
+ title="CAD Model"
+ />
+ <ItemRiskRegister itemId={itemId} />
+ </>
+ )}
+ </VStack>
+ );
+}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.inventory.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.make.$makeMethodId.tsx b/apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx
similarity index 71%
rename from apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.make.$makeMethodId.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx
index 9acfce9511..4f718323af 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.make.$makeMethodId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.make.$makeMethodId.tsx
@@ -3,20 +3,15 @@ import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
import type { JSONContent } from "@carbon/react";
import { Menubar, VStack } from "@carbon/react";
-import { useRouteData } from "@carbon/remix";
import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
import { Await, redirect, useLoaderData, useParams } from "react-router";
-import type { z } from "zod";
import { CadModel } from "~/components";
import { usePermissions } from "~/hooks/usePermissions";
-import type {
- ConfigurationParameter,
- ConfigurationParameterGroup,
- ConfigurationRule,
- itemManufacturingValidator
-} from "~/modules/items";
import {
+ getConfigurationParameters,
+ getConfigurationRules,
+ getItemManufacturing,
getMakeMethodById,
getMakeMethods,
getMethodMaterialsByMakeMethod,
@@ -44,13 +39,19 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
if (!itemId) throw new Error("Could not find itemId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
- const [makeMethod, methodMaterials, methodOperations, tags] =
- await Promise.all([
- getMakeMethodById(client, makeMethodId, companyId),
- getMethodMaterialsByMakeMethod(client, makeMethodId),
- getMethodOperationsByMakeMethodId(client, makeMethodId),
- getTagsList(client, companyId, "operation")
- ]);
+ const [
+ makeMethod,
+ methodMaterials,
+ methodOperations,
+ tags,
+ partManufacturing
+ ] = await Promise.all([
+ getMakeMethodById(client, makeMethodId, companyId),
+ getMethodMaterialsByMakeMethod(client, makeMethodId),
+ getMethodOperationsByMakeMethodId(client, makeMethodId),
+ getTagsList(client, companyId, "operation"),
+ getItemManufacturing(client, itemId, companyId)
+ ]);
if (makeMethod.error) {
throw redirect(
@@ -81,9 +82,26 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
+ const configData = partManufacturing.data?.requiresConfiguration
+ ? {
+ configurationParametersAndGroups: await getConfigurationParameters(
+ client,
+ itemId,
+ companyId
+ ),
+ configurationRules: await getConfigurationRules(
+ client,
+ itemId,
+ companyId
+ )
+ }
+ : {
+ configurationParametersAndGroups: { groups: [], parameters: [] },
+ configurationRules: []
+ };
+
return {
makeMethod: makeMethod.data,
-
methodMaterials:
methodMaterials.data?.map((m) => ({
...m,
@@ -106,34 +124,32 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
workCenterId: operation.workCenterId ?? undefined,
workInstruction: operation.workInstruction as JSONContent | null
})) ?? [],
- makeMethods: getMakeMethods(client, makeMethod.data.itemId, companyId),
+ partManufacturing: partManufacturing.data,
+ ...configData,
model: getModelByItemId(client, makeMethod.data.itemId),
+ makeMethods: getMakeMethods(client, makeMethod.data.itemId, companyId),
tags: tags.data ?? []
};
}
-export default function MethodMaterialMakePage() {
+export default function PartMakeMethodPage() {
const loaderData = useLoaderData<typeof loader>();
const permissions = usePermissions();
- const { makeMethod, makeMethods, methodMaterials, methodOperations, tags } =
- loaderData;
+ const {
+ makeMethod,
+ makeMethods,
+ methodMaterials,
+ methodOperations,
+ partManufacturing,
+ configurationParametersAndGroups,
+ configurationRules,
+ tags
+ } = loaderData;
- const { itemId, methodId, makeMethodId } = useParams();
+ const { itemId, makeMethodId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
- const routeData = useRouteData<{
- partManufacturing: z.infer<typeof itemManufacturingValidator> & {
- customFields: Record<string, string>;
- };
- configurationParametersAndGroups: {
- groups: ConfigurationParameterGroup[];
- parameters: ConfigurationParameter[];
- };
- configurationRules: ConfigurationRule[];
- }>(path.to.partMethod(itemId, methodId));
-
return (
<VStack spacing={2} className="p-2">
<Suspense fallback={<Menubar />}>
@@ -143,30 +159,30 @@ export default function MethodMaterialMakePage() {
itemId={makeMethod.itemId}
makeMethods={makeMethods.data ?? []}
type="Part"
+ currentMethodId={makeMethod.id}
/>
)}
</Await>
</Suspense>
<BillOfMaterial
- key={`bom:${itemId}`}
+ key={`bom:${makeMethodId}`}
makeMethod={makeMethod}
- // @ts-ignore
materials={methodMaterials}
operations={methodOperations}
- configurable={routeData?.partManufacturing.requiresConfiguration}
- configurationRules={routeData?.configurationRules}
- parameters={routeData?.configurationParametersAndGroups.parameters}
+ configurable={partManufacturing?.requiresConfiguration}
+ configurationRules={configurationRules}
+ parameters={configurationParametersAndGroups.parameters}
/>
<BillOfProcess
- key={`bop:${itemId}`}
+ key={`bop:${makeMethodId}`}
makeMethod={makeMethod}
materials={methodMaterials}
// @ts-ignore
operations={methodOperations}
- configurable={routeData?.partManufacturing.requiresConfiguration}
- configurationRules={routeData?.configurationRules}
- parameters={routeData?.configurationParametersAndGroups.parameters}
+ configurable={partManufacturing?.requiresConfiguration}
+ configurationRules={configurationRules}
+ parameters={configurationParametersAndGroups.parameters}
tags={tags}
/>
<Suspense fallback={null}>
diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.method.tsx b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.method.tsx
deleted file mode 100644
index 9974258dd2..0000000000
--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.method.tsx
+++ /dev/null
@@ -1,216 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { Menubar, VStack } from "@carbon/react";
-import type { PostgrestResponse } from "@supabase/supabase-js";
-import { Suspense } from "react";
-import type {
- ActionFunctionArgs,
- ClientActionFunctionArgs,
- LoaderFunctionArgs
-} from "react-router";
-import { Await, redirect, useLoaderData, useParams } from "react-router";
-import type { z } from "zod";
-import CadModel from "~/components/CadModel";
-import { usePermissions, useRouteData } from "~/hooks";
-import type {
- ConfigurationParameter,
- ConfigurationParameterGroup,
- ConfigurationRule,
- MakeMethod,
- Material,
- MethodOperation,
- PartSummary
-} from "~/modules/items";
-import {
- itemManufacturingValidator,
- upsertItemManufacturing
-} from "~/modules/items";
-import {
- BillOfMaterial,
- BillOfProcess,
- MakeMethodTools
-} from "~/modules/items/ui/Item";
-import ItemManufacturingForm from "~/modules/items/ui/Item/ItemManufacturingForm";
-import { ConfigurationParametersForm } from "~/modules/items/ui/Parts";
-import { getTagsList } from "~/modules/shared";
-import { getCustomFields, setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-import { configurableItemsQuery, getCompanyId } from "~/utils/react-query";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts"
- });
-
- const tags = await getTagsList(client, companyId, "operation");
-
- return { tags: tags.data ?? [] };
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts"
- });
-
- const { itemId, methodId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
-
- const formData = await request.formData();
- const validation = await validator(itemManufacturingValidator).validate(
- formData
- );
-
- if (validation.error) {
- console.error(validation.error);
- return validationError(validation.error);
- }
-
- const updatePartManufacturing = await upsertItemManufacturing(client, {
- ...validation.data,
- requiresConfiguration: validation.data.requiresConfiguration ?? false,
- itemId,
- updatedBy: userId,
- customFields: setCustomFields(formData)
- });
- if (updatePartManufacturing.error) {
- throw redirect(
- path.to.part(itemId),
- await flash(
- request,
- error(
- updatePartManufacturing.error,
- "Failed to update part manufacturing"
- )
- )
- );
- }
-
- throw redirect(
- path.to.partMakeMethod(itemId, methodId),
- await flash(request, success("Updated part manufacturing"))
- );
-}
-
-export async function clientAction({ serverAction }: ClientActionFunctionArgs) {
- window.clientCache?.setQueryData(
- configurableItemsQuery(getCompanyId()).queryKey,
- null
- );
- return await serverAction();
-}
-
-export default function MakeMethodRoute() {
- const permissions = usePermissions();
- const { itemId, methodId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
-
- const { tags } = useLoaderData<typeof loader>();
-
- const itemRouteData = useRouteData<{
- partSummary: PartSummary;
- makeMethods: Promise<PostgrestResponse<MakeMethod>>;
- }>(path.to.part(itemId));
-
- const manufacturingRouteData = useRouteData<{
- partManufacturing: z.infer<typeof itemManufacturingValidator> & {
- customFields: Record<string, string>;
- };
- configurationParametersAndGroups: {
- groups: ConfigurationParameterGroup[];
- parameters: ConfigurationParameter[];
- };
- configurationRules: ConfigurationRule[];
- makeMethod: MakeMethod;
- methodMaterials: Material[];
- methodOperations: MethodOperation[];
- }>(path.to.partMethod(itemId, methodId));
-
- if (!manufacturingRouteData) throw new Error("Could not find route data");
-
- const makeMethodId = manufacturingRouteData?.makeMethod?.id;
- if (!makeMethodId) throw new Error("Could not find makeMethodId");
-
- const manufacturingInitialValues = {
- ...manufacturingRouteData?.partManufacturing,
- lotSize: manufacturingRouteData?.partManufacturing.lotSize ?? 0,
- ...getCustomFields(manufacturingRouteData?.partManufacturing.customFields)
- };
-
- return (
- <VStack spacing={2} className="p-2">
- <Suspense fallback={<Menubar />}>
- <Await resolve={itemRouteData?.makeMethods}>
- {(makeMethods) => (
- <MakeMethodTools
- itemId={manufacturingRouteData?.makeMethod.itemId}
- makeMethods={makeMethods?.data ?? []}
- type="Part"
- />
- )}
- </Await>
- </Suspense>
- <ItemManufacturingForm
- key={itemId}
- // @ts-ignore
- initialValues={manufacturingInitialValues}
- />
- {manufacturingRouteData?.partManufacturing.requiresConfiguration && (
- <ConfigurationParametersForm
- key={`options:${itemId}`}
- parameters={
- manufacturingRouteData?.configurationParametersAndGroups.parameters
- }
- groups={
- manufacturingRouteData?.configurationParametersAndGroups.groups
- }
- />
- )}
-
- <BillOfMaterial
- key={`bom:${itemId}`}
- makeMethod={manufacturingRouteData?.makeMethod}
- // @ts-ignore
- materials={manufacturingRouteData?.methodMaterials ?? []}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations}
- configurable={
- manufacturingRouteData?.partManufacturing.requiresConfiguration
- }
- configurationRules={manufacturingRouteData?.configurationRules}
- parameters={
- manufacturingRouteData?.configurationParametersAndGroups.parameters
- }
- />
- <BillOfProcess
- key={`bop:${itemId}`}
- makeMethod={manufacturingRouteData?.makeMethod}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations ?? []}
- configurable={
- manufacturingRouteData?.partManufacturing.requiresConfiguration
- }
- // @ts-ignore
- materials={manufacturingRouteData?.methodMaterials ?? []}
- configurationRules={manufacturingRouteData?.configurationRules}
- parameters={
- manufacturingRouteData?.configurationParametersAndGroups.parameters
- }
- tags={tags}
- />
-
- <CadModel
- isReadOnly={!permissions.can("update", "parts")}
- metadata={{ itemId }}
- modelPath={itemRouteData?.partSummary?.modelPath ?? null}
- title="CAD Model"
- uploadClassName="aspect-square min-h-[420px] max-h-[70vh]"
- viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
- />
- </VStack>
- );
-}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsx b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsx
deleted file mode 100644
index d298abb762..0000000000
--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { type JSONContent } from "@carbon/react";
-import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, redirect, useLoaderData, useParams } from "react-router";
-import { ResizablePanels } from "~/components/Layout";
-import type { FlatTreeItem } from "~/components/TreeView";
-import { flattenTree } from "~/components/TreeView";
-import type { Method } from "~/modules/items";
-import {
- getConfigurationParameters,
- getConfigurationRules,
- getItemManufacturing,
- getMakeMethodById,
- getMethodMaterialsByMakeMethod,
- getMethodOperationsByMakeMethodId,
- getMethodTree
-} from "~/modules/items";
-import { BoMExplorer } from "~/modules/items/ui/Item";
-import { PartProperties } from "~/modules/items/ui/Parts";
-import type { MethodItemType, MethodType } from "~/modules/shared";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- bypassRls: true
- });
-
- const { itemId, methodId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
-
- const makeMethod = await getMakeMethodById(client, methodId, companyId);
-
- if (makeMethod.error) {
- throw redirect(
- path.to.partDetails(itemId),
- await flash(
- request,
- error(makeMethod.error, "Failed to load make methods")
- )
- );
- }
-
- if (companyId !== makeMethod.data.companyId) {
- throw redirect(
- path.to.authenticatedRoot,
- await flash(request, error("Access denied"))
- );
- }
-
- if (companyId !== makeMethod.data.companyId) {
- throw redirect(
- path.to.authenticatedRoot,
- await flash(request, error("Access denied"))
- );
- }
-
- const [methodTree, methodMaterials, methodOperations, partManufacturing] =
- await Promise.all([
- getMethodTree(client, makeMethod.data.id),
- getMethodMaterialsByMakeMethod(client, makeMethod.data.id),
- getMethodOperationsByMakeMethodId(client, makeMethod.data.id),
- getItemManufacturing(client, itemId, companyId)
- ]);
- if (methodTree?.error) {
- throw redirect(
- path.to.partDetails(itemId),
- await flash(
- request,
- error(methodTree.error, "Failed to load method tree")
- )
- );
- }
-
- 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")
- )
- );
- }
-
- return {
- makeMethod: makeMethod.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,
- workCenterId: operation.workCenterId ?? undefined,
- operationSupplierProcessId:
- operation.operationSupplierProcessId ?? undefined,
- workInstruction: operation.workInstruction as JSONContent | null
- })) ?? [],
- methods: (methodTree.data.length > 0
- ? flattenTree(methodTree.data[0])
- : []) satisfies FlatTreeItem<Method>[],
- partManufacturing: partManufacturing.data,
- configurationParametersAndGroups: partManufacturing.data
- ?.requiresConfiguration
- ? await getConfigurationParameters(client, itemId, companyId)
- : { groups: [], parameters: [] },
- configurationRules: partManufacturing.data?.requiresConfiguration
- ? await getConfigurationRules(client, itemId, companyId)
- : []
- };
-}
-
-export default function PartManufacturing() {
- const { makeMethod, methods } = useLoaderData<typeof loader>();
-
- const params = useParams();
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return (
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <ResizablePanels
- explorer={
- <div className="w-full h-full p-2">
- <BoMExplorer
- itemType="Part"
- makeMethod={makeMethod}
- makeMethodStatus={makeMethod.status}
- // @ts-ignore
- methods={methods}
- />
- </div>
- }
- content={
- <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
- </div>
- }
- properties={<PartProperties />}
- />
- </div>
- </div>
- );
-}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.methods.tsx b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.methods.tsx
deleted file mode 100644
index 2caaab946c..0000000000
--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.methods.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import type { LoaderFunctionArgs } from "react-router";
-import { redirect } from "react-router";
-import { getMakeMethods } from "~/modules/items";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts"
- });
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const makeMethods = await getMakeMethods(client, itemId, companyId);
- const makeMethod =
- makeMethods.data?.find((m) => m.status === "Active") ??
- makeMethods.data?.[0];
- if (!makeMethod) throw new Error("Could not find make method");
-
- throw redirect(path.to.partMakeMethod(itemId, makeMethod.id));
-}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.planning.tsx b/apps/erp/app/routes/x+/part+/$itemId.planning.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.planning.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.planning.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.purchasing.new.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.purchasing.new.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.purchasing.tsx b/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.purchasing.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.$customerPartToItemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.$customerPartToItemId.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.delete.$customerPartToItemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.delete.$customerPartToItemId.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.delete.$customerPartToItemId.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.delete.$customerPartToItemId.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.new.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.new.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.sales.tsx b/apps/erp/app/routes/x+/part+/$itemId.sales.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/part+/$itemId.view.sales.tsx
rename to apps/erp/app/routes/x+/part+/$itemId.sales.tsx
diff --git a/apps/erp/app/routes/x+/part+/$itemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.tsx
index c717b0aa27..2e527aa7db 100644
--- a/apps/erp/app/routes/x+/part+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/part+/$itemId.tsx
@@ -1,16 +1,40 @@
import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import {
+ Spinner,
+ Tabs,
+ TabsContent,
+ TabsList,
+ TabsTrigger
+} from "@carbon/react";
+import { useRouteData } from "@carbon/remix";
+import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, redirect } from "react-router";
+import {
+ Await,
+ Outlet,
+ redirect,
+ useLoaderData,
+ useParams
+} from "react-router";
+import { ResizablePanels } from "~/components/Layout";
+import { flattenTree } from "~/components/TreeView";
+import type { ItemFile, PartSummary } from "~/modules/items";
import {
getItemFiles,
+ getMakeMethodById,
getMakeMethods,
+ getMethodTree,
getPart,
+ getPartUsedIn,
getPickMethods,
getSupplierParts
} from "~/modules/items";
-import { PartHeader } from "~/modules/items/ui/Parts";
+import { BoMExplorer } from "~/modules/items/ui/Item";
+import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
+import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
+import { PartHeader, PartProperties } from "~/modules/items/ui/Parts";
import { getTagsList } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -51,21 +75,252 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
+ const url = new URL(request.url);
+ const requestedMethodId = url.searchParams.get("methodId");
+
+ const methodTree = getMakeMethods(client, itemId, companyId).then(
+ async (makeMethods) => {
+ const makeMethod = requestedMethodId
+ ? (makeMethods.data?.find((m) => m.id === requestedMethodId) ??
+ makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0])
+ : (makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0]);
+ if (!makeMethod) return null;
+
+ const fullMethod = await getMakeMethodById(
+ client,
+ makeMethod.id,
+ companyId
+ );
+ if (fullMethod.error || !fullMethod.data) return null;
+
+ const tree = await getMethodTree(client, fullMethod.data.id);
+ if (tree.error) return null;
+
+ const methods = tree.data.length > 0 ? flattenTree(tree.data[0]) : [];
+
+ return {
+ makeMethod: fullMethod.data,
+ methods
+ };
+ }
+ );
+
return {
partSummary: partSummary.data,
files: getItemFiles(client, itemId, companyId),
supplierParts: supplierParts.data ?? [],
pickMethods: pickMethods.data ?? [],
makeMethods: getMakeMethods(client, itemId, companyId),
- tags: tags.data ?? []
+ tags: tags.data ?? [],
+ usedIn: getPartUsedIn(client, itemId, companyId),
+ methodTree
};
}
export default function PartRoute() {
+ const { itemId, makeMethodId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const partData = useRouteData<{
+ partSummary: PartSummary;
+ files: Promise<ItemFile[]>;
+ }>(path.to.part(itemId));
+
+ if (!partData) throw new Error("Could not find part data");
+
+ const { usedIn, methodTree } = useLoaderData<typeof loader>();
+
+ const isManufactured = partData.partSummary?.replenishmentSystem !== "Buy";
+
+ const defaultTab = makeMethodId ? "manufacturing" : "used-in";
+
return (
<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
<PartHeader />
- <Outlet />
+ <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
+ <div className="flex flex-grow overflow-hidden">
+ <ResizablePanels
+ explorer={
+ <Tabs defaultValue={defaultTab} className="flex flex-col h-full">
+ {isManufactured && (
+ <div className="p-2 pb-0">
+ <TabsList className="grid w-full grid-cols-2">
+ <TabsTrigger value="used-in">Used In</TabsTrigger>
+ <TabsTrigger value="manufacturing">
+ Manufacturing
+ </TabsTrigger>
+ </TabsList>
+ </div>
+ )}
+ <TabsContent value="used-in" className="flex-1 overflow-y-auto">
+ <Suspense fallback={<UsedInSkeleton />}>
+ <Await resolve={usedIn}>
+ {(resolvedUsedIn) => {
+ const {
+ issues,
+ jobMaterials,
+ jobs,
+ maintenanceDispatchItems,
+ methodMaterials,
+ purchaseOrderLines,
+ receiptLines,
+ quoteLines,
+ quoteMaterials,
+ salesOrderLines,
+ shipmentLines,
+ supplierQuotes
+ } = resolvedUsedIn;
+
+ const tree: UsedInNode[] = [
+ {
+ key: "issues",
+ name: "Issues",
+ module: "quality",
+ children: issues
+ },
+ {
+ key: "jobs",
+ name: "Jobs",
+ module: "production",
+ children: jobs.map((job) => ({
+ ...job,
+ methodType: "Make"
+ }))
+ },
+ {
+ key: "jobMaterials",
+ name: "Job Materials",
+ module: "production",
+ children: jobMaterials
+ },
+ {
+ key: "maintenanceDispatchItems",
+ name: "Maintenance",
+ module: "resources",
+ children: maintenanceDispatchItems
+ },
+ {
+ key: "methodMaterials",
+ name: "Method Materials",
+ module: "parts",
+ // @ts-expect-error
+ children: methodMaterials
+ },
+ {
+ key: "purchaseOrderLines",
+ name: "Purchase Orders",
+ module: "purchasing",
+ children: purchaseOrderLines.map((po) => ({
+ ...po,
+ methodType: "Buy"
+ }))
+ },
+ {
+ key: "receiptLines",
+ name: "Receipts",
+ module: "inventory",
+ children: receiptLines.map((receipt) => ({
+ ...receipt,
+ methodType: "Pick"
+ }))
+ },
+ {
+ key: "quoteLines",
+ name: "Quotes",
+ module: "sales",
+ children: quoteLines
+ },
+ {
+ key: "quoteMaterials",
+ name: "Quote Materials",
+ module: "sales",
+ children: quoteMaterials?.map((qm) => ({
+ ...qm,
+ documentReadableId: qm.documentReadableId ?? ""
+ }))
+ },
+ {
+ key: "salesOrderLines",
+ name: "Sales Orders",
+ module: "sales",
+ children: salesOrderLines
+ },
+ {
+ key: "shipmentLines",
+ name: "Shipments",
+ module: "inventory",
+ children: shipmentLines.map((shipment) => ({
+ ...shipment,
+ methodType: "Shipment"
+ }))
+ },
+ {
+ key: "supplierQuotes",
+ name: "Supplier Quotes",
+ module: "purchasing",
+ children: supplierQuotes
+ }
+ ];
+
+ return (
+ <UsedInTree
+ tree={tree}
+ revisions={partData.partSummary?.revisions}
+ itemReadableId={
+ partData.partSummary?.readableId ?? ""
+ }
+ itemReadableIdWithRevision={
+ partData.partSummary?.readableIdWithRevision ?? ""
+ }
+ />
+ );
+ }}
+ </Await>
+ </Suspense>
+ </TabsContent>
+ {isManufactured && (
+ <TabsContent
+ value="manufacturing"
+ className="flex-1 overflow-y-auto"
+ >
+ <Suspense
+ fallback={
+ <div className="flex w-full h-full items-center justify-center p-4">
+ <Spinner className="h-6 w-6" />
+ </div>
+ }
+ >
+ <Await resolve={methodTree}>
+ {(resolved) =>
+ resolved ? (
+ <div className="w-full h-full p-2">
+ <BoMExplorer
+ itemType="Part"
+ makeMethod={resolved.makeMethod}
+ // @ts-ignore
+ methods={resolved.methods}
+ methodId={resolved.makeMethod.id}
+ />
+ </div>
+ ) : null
+ }
+ </Await>
+ </Suspense>
+ </TabsContent>
+ )}
+ </Tabs>
+ }
+ content={
+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
+ <Outlet />
+ </div>
+ }
+ properties={<PartProperties />}
+ />
+ </div>
+ </div>
</div>
);
}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx
deleted file mode 100644
index ab65b827ce..0000000000
--- a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import type { JSONContent } from "@carbon/react";
-import { Spinner, VStack } from "@carbon/react";
-import { Suspense } from "react";
-import type { ActionFunctionArgs } from "react-router";
-import { Await, redirect, useParams } from "react-router";
-import { CadModel } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { ItemFile, PartSummary } from "~/modules/items";
-import { partValidator, upsertPart } from "~/modules/items";
-import {
- ItemDocuments,
- ItemNotes,
- ItemRiskRegister
-} from "~/modules/items/ui/Item";
-import { setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts"
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const formData = await request.formData();
- const validation = await validator(partValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const updatePart = await upsertPart(client, {
- ...validation.data,
- id: itemId,
- customFields: setCustomFields(formData),
- updatedBy: userId
- });
- if (updatePart.error) {
- throw redirect(
- path.to.part(itemId),
- await flash(request, error(updatePart.error, "Failed to update part"))
- );
- }
-
- throw redirect(
- path.to.part(itemId),
- await flash(request, success("Updated part"))
- );
-}
-
-export default function PartDetailsRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const partData = useRouteData<{
- partSummary: PartSummary;
- files: Promise<ItemFile[]>;
- }>(path.to.part(itemId));
-
- if (!partData) throw new Error("Could not find part data");
- const permissions = usePermissions();
-
- return (
- <VStack spacing={2} className="p-2">
- <ItemNotes
- id={partData.partSummary?.id ?? null}
- title={partData.partSummary?.name ?? ""}
- subTitle={partData.partSummary?.readableIdWithRevision ?? ""}
- notes={partData.partSummary?.notes as JSONContent}
- />
- {permissions.is("employee") && (
- <>
- <Suspense
- fallback={
- <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
- <Spinner className="h-10 w-10" />
- </div>
- }
- >
- <Await resolve={partData?.files}>
- {(resolvedFiles) => (
- <ItemDocuments
- files={resolvedFiles}
- itemId={itemId}
- modelUpload={partData.partSummary ?? undefined}
- type="Part"
- />
- )}
- </Await>
- </Suspense>
-
- <CadModel
- isReadOnly={!permissions.can("update", "parts")}
- metadata={{ itemId }}
- modelPath={partData?.partSummary?.modelPath ?? null}
- title="CAD Model"
- />
- <ItemRiskRegister itemId={itemId} />
- </>
- )}
- </VStack>
- );
-}
diff --git a/apps/erp/app/routes/x+/part+/$itemId.view.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.tsx
deleted file mode 100644
index c5933a55e9..0000000000
--- a/apps/erp/app/routes/x+/part+/$itemId.view.tsx
+++ /dev/null
@@ -1,177 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { useRouteData } from "@carbon/remix";
-import { Suspense } from "react";
-import type { LoaderFunctionArgs } from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
-import { ResizablePanels } from "~/components/Layout";
-import type { ItemFile, PartSummary } from "~/modules/items";
-import { getPartUsedIn } from "~/modules/items";
-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
-import { PartProperties } from "~/modules/items/ui/Parts";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- bypassRls: true
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return { usedIn: getPartUsedIn(client, itemId, companyId) };
-}
-
-export default function PartViewRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const partData = useRouteData<{
- partSummary: PartSummary;
- files: Promise<ItemFile[]>;
- }>(path.to.part(itemId));
-
- if (!partData) throw new Error("Could not find part data");
-
- const { usedIn } = useLoaderData<typeof loader>();
-
- return (
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <ResizablePanels
- explorer={
- <Suspense fallback={<UsedInSkeleton />}>
- <Await resolve={usedIn}>
- {(resolvedUsedIn) => {
- const {
- issues,
- jobMaterials,
- jobs,
- maintenanceDispatchItems,
- methodMaterials,
- purchaseOrderLines,
- receiptLines,
- quoteLines,
- quoteMaterials,
- salesOrderLines,
- shipmentLines,
- supplierQuotes
- } = resolvedUsedIn;
-
- const tree: UsedInNode[] = [
- {
- key: "issues",
- name: "Issues",
- module: "quality",
- children: issues
- },
- {
- key: "jobs",
- name: "Jobs",
- module: "production",
- children: jobs.map((job) => ({
- ...job,
- methodType: "Make"
- }))
- },
- {
- key: "jobMaterials",
- name: "Job Materials",
- module: "production",
- children: jobMaterials
- },
- {
- key: "maintenanceDispatchItems",
- name: "Maintenance",
- module: "resources",
- children: maintenanceDispatchItems
- },
- {
- key: "methodMaterials",
- name: "Method Materials",
- module: "parts",
- // @ts-expect-error
- children: methodMaterials
- },
- {
- key: "purchaseOrderLines",
- name: "Purchase Orders",
- module: "purchasing",
- children: purchaseOrderLines.map((po) => ({
- ...po,
- methodType: "Buy"
- }))
- },
- {
- key: "receiptLines",
- name: "Receipts",
- module: "inventory",
- children: receiptLines.map((receipt) => ({
- ...receipt,
- methodType: "Pick"
- }))
- },
- {
- key: "quoteLines",
- name: "Quotes",
- module: "sales",
- children: quoteLines
- },
- {
- key: "quoteMaterials",
- name: "Quote Materials",
- module: "sales",
- children: quoteMaterials?.map((qm) => ({
- ...qm,
- documentReadableId: qm.documentReadableId ?? ""
- }))
- },
- {
- key: "salesOrderLines",
- name: "Sales Orders",
- module: "sales",
- children: salesOrderLines
- },
- {
- key: "shipmentLines",
- name: "Shipments",
- module: "inventory",
- children: shipmentLines.map((shipment) => ({
- ...shipment,
- methodType: "Shipment"
- }))
- },
- {
- key: "supplierQuotes",
- name: "Supplier Quotes",
- module: "purchasing",
- children: supplierQuotes
- }
- ];
-
- return (
- <UsedInTree
- tree={tree}
- revisions={partData.partSummary?.revisions}
- itemReadableId={partData.partSummary?.readableId ?? ""}
- itemReadableIdWithRevision={
- partData.partSummary?.readableIdWithRevision ?? ""
- }
- />
- );
- }}
- </Await>
- </Suspense>
- }
- content={
- <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
- </div>
- }
- properties={<PartProperties />}
- />
- </div>
- </div>
- );
-}
diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index 0fe39a3dff..35e244b4d8 100644
--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -241,14 +241,6 @@ export default function QuoteLine() {
<Fragment key={lineId}>
<QuoteMakeMethodTools />
<QuoteLineForm key={lineId} initialValues={initialValues} />
- <OpportunityLineNotes
- id={line.id}
- table="quoteLine"
- title="Notes"
- subTitle={line.itemReadableId ?? ""}
- internalNotes={line.internalNotes as JSONContent}
- externalNotes={line.externalNotes as JSONContent}
- />
{methodData && (
<VStack spacing={2}>
@@ -316,7 +308,14 @@ export default function QuoteLine() {
/>
</>
)}
-
+ <OpportunityLineNotes
+ id={line.id}
+ table="quoteLine"
+ title="Notes"
+ subTitle={line.itemReadableId ?? ""}
+ internalNotes={line.internalNotes as JSONContent}
+ externalNotes={line.externalNotes as JSONContent}
+ />
<Suspense
fallback={
<div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.costing.tsx b/apps/erp/app/routes/x+/tool+/$itemId.costing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/tool+/$itemId.view.costing.tsx
rename to apps/erp/app/routes/x+/tool+/$itemId.costing.tsx
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.details.tsx b/apps/erp/app/routes/x+/tool+/$itemId.details.tsx
new file mode 100644
index 0000000000..e20529d575
--- /dev/null
+++ b/apps/erp/app/routes/x+/tool+/$itemId.details.tsx
@@ -0,0 +1,275 @@
+import { assertIsPost, error, success } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import { validationError, validator } from "@carbon/form";
+import type { JSONContent } from "@carbon/react";
+import { Menubar, Spinner, VStack } from "@carbon/react";
+import type { PostgrestResponse } from "@supabase/supabase-js";
+import { Suspense } from "react";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
+import { Await, redirect, useLoaderData, useParams } from "react-router";
+import { CadModel } from "~/components";
+import { usePermissions, useRouteData } from "~/hooks";
+import type { ItemFile, MakeMethod, ToolSummary } from "~/modules/items";
+import {
+ getItemManufacturing,
+ getMakeMethodById,
+ getMakeMethods,
+ getMethodMaterialsByMakeMethod,
+ getMethodOperationsByMakeMethodId,
+ itemManufacturingValidator,
+ toolValidator,
+ upsertItemManufacturing,
+ upsertTool
+} from "~/modules/items";
+import {
+ BillOfMaterial,
+ BillOfProcess,
+ ItemDocuments,
+ ItemNotes,
+ ItemRiskRegister,
+ MakeMethodTools
+} from "~/modules/items/ui/Item";
+import ItemManufacturingForm from "~/modules/items/ui/Item/ItemManufacturingForm";
+import type { MethodItemType, MethodType } from "~/modules/shared";
+import { getTagsList } from "~/modules/shared";
+import { getCustomFields, setCustomFields } from "~/utils/form";
+import { path } from "~/utils/path";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ bypassRls: true
+ });
+
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const url = new URL(request.url);
+ const requestedMethodId = url.searchParams.get("methodId");
+
+ const makeMethods = await getMakeMethods(client, itemId, companyId);
+ const makeMethod = requestedMethodId
+ ? (makeMethods.data?.find((m) => m.id === requestedMethodId) ??
+ makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0])
+ : (makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0]);
+
+ if (!makeMethod) {
+ return { methodData: null, tags: [] };
+ }
+
+ const fullMethod = await getMakeMethodById(client, makeMethod.id, companyId);
+ if (fullMethod.error || !fullMethod.data) {
+ return { methodData: null, tags: [] };
+ }
+
+ const [methodMaterials, methodOperations, tags, toolManufacturing] =
+ await Promise.all([
+ getMethodMaterialsByMakeMethod(client, fullMethod.data.id),
+ getMethodOperationsByMakeMethodId(client, fullMethod.data.id),
+ getTagsList(client, companyId, "operation"),
+ getItemManufacturing(client, itemId, companyId)
+ ]);
+
+ return {
+ methodData: {
+ makeMethod: fullMethod.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,
+ workCenterId: operation.workCenterId ?? undefined,
+ operationSupplierProcessId:
+ operation.operationSupplierProcessId ?? undefined,
+ workInstruction: operation.workInstruction as JSONContent | null
+ })) ?? [],
+ toolManufacturing: toolManufacturing.data
+ },
+ tags: tags.data ?? []
+ };
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ update: "parts"
+ });
+
+ const { itemId } = params;
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const formData = await request.formData();
+ const intent = formData.get("intent");
+
+ if (intent === "manufacturing") {
+ const validation = await validator(itemManufacturingValidator).validate(
+ formData
+ );
+
+ if (validation.error) {
+ console.error(validation.error);
+ return validationError(validation.error);
+ }
+
+ const updateToolManufacturing = await upsertItemManufacturing(client, {
+ ...validation.data,
+ itemId,
+ updatedBy: userId,
+ customFields: setCustomFields(formData)
+ });
+ if (updateToolManufacturing.error) {
+ throw redirect(
+ path.to.tool(itemId),
+ await flash(
+ request,
+ error(
+ updateToolManufacturing.error,
+ "Failed to update tool manufacturing"
+ )
+ )
+ );
+ }
+
+ throw redirect(
+ path.to.toolDetails(itemId),
+ await flash(request, success("Updated tool manufacturing"))
+ );
+ }
+
+ const validation = await validator(toolValidator).validate(formData);
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const updateTool = await upsertTool(client, {
+ ...validation.data,
+ id: itemId,
+ customFields: setCustomFields(formData),
+ updatedBy: userId
+ });
+ if (updateTool.error) {
+ throw redirect(
+ path.to.tool(itemId),
+ await flash(request, error(updateTool.error, "Failed to update tool"))
+ );
+ }
+
+ throw redirect(
+ path.to.tool(itemId),
+ await flash(request, success("Updated tool"))
+ );
+}
+
+export default function ToolDetailsRoute() {
+ const { itemId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const permissions = usePermissions();
+ const { methodData, tags } = useLoaderData<typeof loader>();
+
+ const toolData = useRouteData<{
+ toolSummary: ToolSummary;
+ files: Promise<ItemFile[]>;
+ makeMethods: Promise<PostgrestResponse<MakeMethod>>;
+ }>(path.to.tool(itemId));
+
+ if (!toolData) throw new Error("Could not find tool data");
+
+ const manufacturingInitialValues = methodData?.toolManufacturing
+ ? {
+ ...methodData.toolManufacturing,
+ lotSize: methodData.toolManufacturing.lotSize ?? 0,
+ ...getCustomFields(methodData.toolManufacturing.customFields)
+ }
+ : null;
+
+ return (
+ <VStack spacing={2} className="p-2">
+ {permissions.is("employee") && methodData && (
+ <>
+ <Suspense fallback={<Menubar />}>
+ <Await resolve={toolData?.makeMethods}>
+ {(makeMethods) => (
+ <MakeMethodTools
+ itemId={methodData.makeMethod.itemId}
+ makeMethods={makeMethods?.data ?? []}
+ type="Tool"
+ currentMethodId={methodData.makeMethod.id}
+ />
+ )}
+ </Await>
+ </Suspense>
+ {manufacturingInitialValues && (
+ <ItemManufacturingForm
+ key={itemId}
+ // @ts-ignore
+ initialValues={manufacturingInitialValues}
+ withConfiguration={false}
+ />
+ )}
+ <BillOfMaterial
+ key={`bom:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ materials={methodData.methodMaterials ?? []}
+ // @ts-ignore
+ operations={methodData.methodOperations}
+ />
+ <BillOfProcess
+ key={`bop:${itemId}`}
+ makeMethod={methodData.makeMethod}
+ // @ts-ignore
+ operations={methodData.methodOperations ?? []}
+ tags={tags}
+ />
+ </>
+ )}
+ {permissions.is("employee") && (
+ <>
+ <ItemNotes
+ id={toolData.toolSummary?.id ?? null}
+ title={toolData.toolSummary?.name ?? ""}
+ subTitle={toolData.toolSummary?.readableIdWithRevision ?? ""}
+ notes={toolData.toolSummary?.notes as JSONContent}
+ />
+ <Suspense
+ fallback={
+ <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
+ <Spinner className="h-10 w-10" />
+ </div>
+ }
+ >
+ <Await resolve={toolData?.files}>
+ {(resolvedFiles) => (
+ <ItemDocuments
+ files={resolvedFiles}
+ itemId={itemId}
+ modelUpload={toolData.toolSummary ?? undefined}
+ type="Tool"
+ />
+ )}
+ </Await>
+ </Suspense>
+
+ <CadModel
+ isReadOnly={!permissions.can("update", "parts")}
+ metadata={{ itemId }}
+ modelPath={toolData?.toolSummary?.modelPath ?? null}
+ title="CAD Model"
+ />
+
+ <ItemRiskRegister itemId={itemId} />
+ </>
+ )}
+ </VStack>
+ );
+}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsx b/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsx
rename to apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.make.$makeMethodId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx
similarity index 87%
rename from apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.make.$makeMethodId.tsx
rename to apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx
index 538ba86c4c..cdf12adc0c 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.make.$makeMethodId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.make.$makeMethodId.tsx
@@ -75,7 +75,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
return {
makeMethod: makeMethod.data,
-
methodMaterials:
methodMaterials.data?.map((m) => ({
...m,
@@ -104,15 +103,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
};
}
-export default function MethodMaterialMakePage() {
+export default function ToolMakeMethodPage() {
const loaderData = useLoaderData<typeof loader>();
const permissions = usePermissions();
const { makeMethod, makeMethods, methodMaterials, methodOperations, tags } =
loaderData;
- const { itemId, methodId, makeMethodId } = useParams();
+ const { itemId, makeMethodId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
return (
@@ -124,29 +122,24 @@ export default function MethodMaterialMakePage() {
itemId={makeMethod.itemId}
makeMethods={makeMethods.data ?? []}
type="Tool"
+ currentMethodId={makeMethod.id}
/>
)}
</Await>
</Suspense>
<BillOfMaterial
- key={`bom:${itemId}`}
+ key={`bom:${makeMethodId}`}
makeMethod={makeMethod}
materials={methodMaterials}
operations={methodOperations}
- // configurable={routeData?.toolManufacturing.requiresConfiguration}
- // configurationRules={routeData?.configurationRules}
- // parameters={routeData?.configurationParametersAndGroups.parameters}
/>
<BillOfProcess
- key={`bop:${itemId}`}
+ key={`bop:${makeMethodId}`}
makeMethod={makeMethod}
materials={methodMaterials}
// @ts-ignore
operations={methodOperations}
- // configurable={routeData?.toolManufacturing.requiresConfiguration}
- // configurationRules={routeData?.configurationRules}
- // parameters={routeData?.configurationParametersAndGroups.parameters}
tags={tags}
/>
<Suspense fallback={null}>
@@ -154,7 +147,7 @@ export default function MethodMaterialMakePage() {
{(model) => (
<CadModel
key={`cad:${model.itemId}`}
- isReadOnly={!permissions.can("update", "sales")}
+ isReadOnly={!permissions.can("update", "parts")}
metadata={{
itemId: model?.itemId ?? undefined
}}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.method.tsx b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.method.tsx
deleted file mode 100644
index d7b1b54008..0000000000
--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.method.tsx
+++ /dev/null
@@ -1,163 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import { Menubar, VStack } from "@carbon/react";
-import type { PostgrestResponse } from "@supabase/supabase-js";
-import { Suspense } from "react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";
-import { Await, redirect, useLoaderData, useParams } from "react-router";
-import type { z } from "zod";
-import CadModel from "~/components/CadModel";
-import { usePermissions, useRouteData } from "~/hooks";
-import {
- itemManufacturingValidator,
- type MakeMethod,
- type Material,
- type MethodOperation,
- type ToolSummary,
- upsertItemManufacturing
-} from "~/modules/items";
-import {
- BillOfMaterial,
- BillOfProcess,
- MakeMethodTools
-} from "~/modules/items/ui/Item";
-import ItemManufacturingForm from "~/modules/items/ui/Item/ItemManufacturingForm";
-import { getTagsList } from "~/modules/shared";
-import { getCustomFields, setCustomFields } from "~/utils/form";
-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 { tags: tags.data ?? [] };
-}
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts"
- });
-
- const { itemId, methodId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
-
- const formData = await request.formData();
- const validation = await validator(itemManufacturingValidator).validate(
- formData
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const updateToolManufacturing = await upsertItemManufacturing(client, {
- ...validation.data,
- itemId,
- updatedBy: userId,
- customFields: setCustomFields(formData)
- });
- if (updateToolManufacturing.error) {
- throw redirect(
- path.to.tool(itemId),
- await flash(
- request,
- error(
- updateToolManufacturing.error,
- "Failed to update tool manufacturing"
- )
- )
- );
- }
-
- throw redirect(
- path.to.toolMakeMethod(itemId, methodId),
- await flash(request, success("Updated part manufacturing"))
- );
-}
-
-export default function MakeMethodRoute() {
- const permissions = usePermissions();
- const { itemId, methodId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
-
- const { tags } = useLoaderData<typeof loader>();
-
- const itemRouteData = useRouteData<{
- toolSummary: ToolSummary;
- makeMethods: Promise<PostgrestResponse<MakeMethod>>;
- }>(path.to.tool(itemId));
-
- const manufacturingRouteData = useRouteData<{
- toolManufacturing: z.infer<typeof itemManufacturingValidator> & {
- customFields: Record<string, string>;
- };
- makeMethod: MakeMethod;
- methodMaterials: Material[];
- methodOperations: MethodOperation[];
- }>(path.to.toolMethod(itemId, methodId));
-
- if (!manufacturingRouteData) throw new Error("Could not find route data");
-
- const makeMethodId = manufacturingRouteData?.makeMethod?.id;
- if (!makeMethodId) throw new Error("Could not find makeMethodId");
-
- const manufacturingInitialValues = {
- ...manufacturingRouteData?.toolManufacturing,
- lotSize: manufacturingRouteData?.toolManufacturing.lotSize ?? 0,
- ...getCustomFields(manufacturingRouteData?.toolManufacturing.customFields)
- };
-
- return (
- <VStack spacing={2} className="p-2">
- <Suspense fallback={<Menubar />}>
- <Await resolve={itemRouteData?.makeMethods}>
- {(makeMethods) => (
- <MakeMethodTools
- itemId={manufacturingRouteData?.makeMethod.itemId}
- makeMethods={makeMethods?.data ?? []}
- type="Tool"
- />
- )}
- </Await>
- </Suspense>
- <ItemManufacturingForm
- key={itemId}
- // @ts-ignore
- initialValues={manufacturingInitialValues}
- withConfiguration={false}
- />
- <BillOfMaterial
- key={`bom:${itemId}`}
- makeMethod={manufacturingRouteData?.makeMethod}
- // @ts-ignore
- materials={manufacturingRouteData?.methodMaterials ?? []}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations}
- />
- <BillOfProcess
- key={`bop:${itemId}`}
- makeMethod={manufacturingRouteData?.makeMethod}
- // @ts-ignore
- operations={manufacturingRouteData?.methodOperations ?? []}
- tags={tags}
- />
-
- <CadModel
- isReadOnly={!permissions.can("update", "parts")}
- metadata={{ itemId }}
- modelPath={itemRouteData?.toolSummary?.modelPath ?? null}
- title="CAD Model"
- uploadClassName="aspect-square min-h-[420px] max-h-[70vh]"
- viewerClassName="aspect-square min-h-[420px] max-h-[70vh]"
- />
- </VStack>
- );
-}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsx
deleted file mode 100644
index d3699f2468..0000000000
--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsx
+++ /dev/null
@@ -1,151 +0,0 @@
-import { error } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import type { JSONContent } from "@carbon/react";
-import { VStack } from "@carbon/react";
-import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, redirect, useLoaderData, useParams } from "react-router";
-import { ResizablePanels } from "~/components/Layout/Panels";
-import type { FlatTreeItem } from "~/components/TreeView";
-import { flattenTree } from "~/components/TreeView";
-import type { Method } from "~/modules/items";
-import {
- getItemManufacturing,
- getMakeMethodById,
- getMethodMaterialsByMakeMethod,
- getMethodOperationsByMakeMethodId,
- getMethodTree
-} from "~/modules/items";
-import { BoMExplorer } from "~/modules/items/ui/Item";
-import { ToolProperties } from "~/modules/items/ui/Tools";
-import type { MethodItemType, MethodType } from "~/modules/shared";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- bypassRls: true
- });
-
- const { itemId, methodId } = params;
- if (!itemId) throw new Error("Could not find itemId");
- if (!methodId) throw new Error("Could not find methodId");
-
- const makeMethod = await getMakeMethodById(client, methodId, companyId);
-
- if (makeMethod.error) {
- throw redirect(
- path.to.toolDetails(itemId),
- await flash(
- request,
- error(makeMethod.error, "Failed to load make method")
- )
- );
- }
-
- if (companyId !== makeMethod.data.companyId) {
- throw redirect(
- path.to.authenticatedRoot,
- await flash(request, error("Access denied"))
- );
- }
-
- const [methodTree, methodMaterials, methodOperations, toolManufacturing] =
- await Promise.all([
- getMethodTree(client, makeMethod.data.id),
- getMethodMaterialsByMakeMethod(client, makeMethod.data.id),
- getMethodOperationsByMakeMethodId(client, makeMethod.data.id),
- getItemManufacturing(client, itemId, companyId)
- ]);
- if (methodTree?.error) {
- throw redirect(
- path.to.partDetails(itemId),
- await flash(
- request,
- error(methodTree.error, "Failed to load method tree")
- )
- );
- }
-
- 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")
- )
- );
- }
-
- return {
- makeMethod: makeMethod.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,
- workCenterId: operation.workCenterId ?? undefined,
- operationSupplierProcessId:
- operation.operationSupplierProcessId ?? undefined,
- workInstruction: operation.workInstruction as JSONContent | null
- })) ?? [],
- methods: (methodTree.data.length > 0
- ? flattenTree(methodTree.data[0])
- : []) satisfies FlatTreeItem<Method>[],
- toolManufacturing: toolManufacturing.data
- // configurationParametersAndGroups: toolManufacturing.data
- // ?.requiresConfiguration
- // ? await getConfigurationParameters(client, itemId, companyId)
- // : { groups: [], parameters: [] },
- // configurationRules: toolManufacturing.data?.requiresConfiguration
- // ? await getConfigurationRules(client, itemId, companyId)
- // : [],
- };
-}
-export default function ToolManufacturing() {
- const { makeMethod, methods } = useLoaderData<typeof loader>();
-
- const params = useParams();
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return (
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <ResizablePanels
- explorer={
- <VStack className="w-full p-2">
- <BoMExplorer
- itemType="Tool"
- makeMethod={makeMethod}
- makeMethodStatus={makeMethod.status}
- // @ts-ignore
- methods={methods}
- />
- </VStack>
- }
- content={
- <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
- </div>
- }
- properties={<ToolProperties />}
- />
- </div>
- </div>
- );
-}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.methods.tsx b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.methods.tsx
deleted file mode 100644
index 41ee351e9d..0000000000
--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.methods.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import type { LoaderFunctionArgs } from "react-router";
-import { redirect } from "react-router";
-import { getMakeMethods } from "~/modules/items";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts"
- });
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const makeMethods = await getMakeMethods(client, itemId, companyId);
- const makeMethod =
- makeMethods.data?.find((m) => m.status === "Active") ??
- makeMethods.data?.[0];
- if (!makeMethod) throw new Error("Could not find make method");
-
- throw redirect(path.to.toolMakeMethod(itemId, makeMethod.id));
-}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.planning.tsx b/apps/erp/app/routes/x+/tool+/$itemId.planning.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/tool+/$itemId.view.planning.tsx
rename to apps/erp/app/routes/x+/tool+/$itemId.planning.tsx
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.new.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.new.tsx
rename to apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.tsx b/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx
similarity index 100%
rename from apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.tsx
rename to apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.tsx
index 769b834094..5b56406275 100644
--- a/apps/erp/app/routes/x+/tool+/$itemId.tsx
+++ b/apps/erp/app/routes/x+/tool+/$itemId.tsx
@@ -1,16 +1,40 @@
-import { error, getCarbonServiceRole } from "@carbon/auth";
+import { error } from "@carbon/auth";
import { requirePermissions } from "@carbon/auth/auth.server";
import { flash } from "@carbon/auth/session.server";
+import {
+ Spinner,
+ Tabs,
+ TabsContent,
+ TabsList,
+ TabsTrigger
+} from "@carbon/react";
+import { useRouteData } from "@carbon/remix";
+import { Suspense } from "react";
import type { LoaderFunctionArgs } from "react-router";
-import { Outlet, redirect } from "react-router";
+import {
+ Await,
+ Outlet,
+ redirect,
+ useLoaderData,
+ useParams
+} from "react-router";
+import { ResizablePanels } from "~/components/Layout";
+import { flattenTree } from "~/components/TreeView";
+import type { ItemFile, ToolSummary } from "~/modules/items";
import {
getItemFiles,
+ getMakeMethodById,
getMakeMethods,
+ getMethodTree,
+ getPartUsedIn,
getPickMethods,
getSupplierParts,
getTool
} from "~/modules/items";
-import { ToolHeader } from "~/modules/items/ui/Tools";
+import { BoMExplorer } from "~/modules/items/ui/Item";
+import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
+import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
+import { ToolHeader, ToolProperties } from "~/modules/items/ui/Tools";
import { getTagsList } from "~/modules/shared";
import type { Handle } from "~/utils/handle";
import { path } from "~/utils/path";
@@ -22,19 +46,19 @@ export const handle: Handle = {
};
export async function loader({ request, params }: LoaderFunctionArgs) {
- const { companyId } = await requirePermissions(request, {
- view: "parts"
+ const { client, companyId } = await requirePermissions(request, {
+ view: "parts",
+ bypassRls: true
});
const { itemId } = params;
if (!itemId) throw new Error("Could not find itemId");
- const serviceRole = await getCarbonServiceRole();
const [toolSummary, supplierParts, pickMethods, tags] = await Promise.all([
- getTool(serviceRole, itemId, companyId),
- getSupplierParts(serviceRole, itemId, companyId),
- getPickMethods(serviceRole, itemId, companyId),
- getTagsList(serviceRole, companyId, "tool")
+ getTool(client, itemId, companyId),
+ getSupplierParts(client, itemId, companyId),
+ getPickMethods(client, itemId, companyId),
+ getTagsList(client, companyId, "tool")
]);
if (toolSummary.error) {
@@ -47,21 +71,252 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
);
}
+ const url = new URL(request.url);
+ const requestedMethodId = url.searchParams.get("methodId");
+
+ const methodTree = getMakeMethods(client, itemId, companyId).then(
+ async (makeMethods) => {
+ const makeMethod = requestedMethodId
+ ? (makeMethods.data?.find((m) => m.id === requestedMethodId) ??
+ makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0])
+ : (makeMethods.data?.find((m) => m.status === "Active") ??
+ makeMethods.data?.[0]);
+ if (!makeMethod) return null;
+
+ const fullMethod = await getMakeMethodById(
+ client,
+ makeMethod.id,
+ companyId
+ );
+ if (fullMethod.error || !fullMethod.data) return null;
+
+ const tree = await getMethodTree(client, fullMethod.data.id);
+ if (tree.error) return null;
+
+ const methods = tree.data.length > 0 ? flattenTree(tree.data[0]) : [];
+
+ return {
+ makeMethod: fullMethod.data,
+ methods
+ };
+ }
+ );
+
return {
toolSummary: toolSummary.data,
- files: getItemFiles(serviceRole, itemId, companyId),
+ files: getItemFiles(client, itemId, companyId),
supplierParts: supplierParts.data ?? [],
pickMethods: pickMethods.data ?? [],
- makeMethods: getMakeMethods(serviceRole, itemId, companyId),
- tags: tags.data ?? []
+ makeMethods: getMakeMethods(client, itemId, companyId),
+ tags: tags.data ?? [],
+ usedIn: getPartUsedIn(client, itemId, companyId),
+ methodTree
};
}
export default function ToolRoute() {
+ const { itemId, makeMethodId } = useParams();
+ if (!itemId) throw new Error("Could not find itemId");
+
+ const toolData = useRouteData<{
+ toolSummary: ToolSummary;
+ files: Promise<ItemFile[]>;
+ }>(path.to.tool(itemId));
+
+ if (!toolData) throw new Error("Could not find tool data");
+
+ const { usedIn, methodTree } = useLoaderData<typeof loader>();
+
+ const isManufactured = toolData.toolSummary?.replenishmentSystem !== "Buy";
+
+ const defaultTab = makeMethodId ? "manufacturing" : "used-in";
+
return (
<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full">
<ToolHeader />
- <Outlet />
+ <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
+ <div className="flex flex-grow overflow-hidden">
+ <ResizablePanels
+ explorer={
+ <Tabs defaultValue={defaultTab} className="flex flex-col h-full">
+ {isManufactured && (
+ <div className="p-2 pb-0">
+ <TabsList className="grid w-full grid-cols-2">
+ <TabsTrigger value="used-in">Used In</TabsTrigger>
+ <TabsTrigger value="manufacturing">
+ Manufacturing
+ </TabsTrigger>
+ </TabsList>
+ </div>
+ )}
+ <TabsContent value="used-in" className="flex-1 overflow-y-auto">
+ <Suspense fallback={<UsedInSkeleton />}>
+ <Await resolve={usedIn}>
+ {(resolvedUsedIn) => {
+ const {
+ issues,
+ jobMaterials,
+ jobs,
+ maintenanceDispatchItems,
+ methodMaterials,
+ purchaseOrderLines,
+ receiptLines,
+ quoteLines,
+ quoteMaterials,
+ salesOrderLines,
+ shipmentLines,
+ supplierQuotes
+ } = resolvedUsedIn;
+
+ const tree: UsedInNode[] = [
+ {
+ key: "issues",
+ name: "Issues",
+ module: "quality",
+ children: issues
+ },
+ {
+ key: "jobs",
+ name: "Jobs",
+ module: "production",
+ children: jobs.map((job) => ({
+ ...job,
+ methodType: "Make"
+ }))
+ },
+ {
+ key: "jobMaterials",
+ name: "Job Materials",
+ module: "production",
+ children: jobMaterials
+ },
+ {
+ key: "maintenanceDispatchItems",
+ name: "Maintenance",
+ module: "resources",
+ children: maintenanceDispatchItems
+ },
+ {
+ key: "methodMaterials",
+ name: "Method Materials",
+ module: "parts",
+ // @ts-expect-error
+ children: methodMaterials
+ },
+ {
+ key: "purchaseOrderLines",
+ name: "Purchase Orders",
+ module: "purchasing",
+ children: purchaseOrderLines.map((po) => ({
+ ...po,
+ methodType: "Buy"
+ }))
+ },
+ {
+ key: "receiptLines",
+ name: "Receipts",
+ module: "inventory",
+ children: receiptLines.map((receipt) => ({
+ ...receipt,
+ methodType: "Pick"
+ }))
+ },
+ {
+ key: "quoteLines",
+ name: "Quotes",
+ module: "sales",
+ children: quoteLines
+ },
+ {
+ key: "quoteMaterials",
+ name: "Quote Materials",
+ module: "sales",
+ children: quoteMaterials?.map((qm) => ({
+ ...qm,
+ documentReadableId: qm.documentReadableId ?? ""
+ }))
+ },
+ {
+ key: "salesOrderLines",
+ name: "Sales Orders",
+ module: "sales",
+ children: salesOrderLines
+ },
+ {
+ key: "shipmentLines",
+ name: "Shipments",
+ module: "inventory",
+ children: shipmentLines.map((shipment) => ({
+ ...shipment,
+ methodType: "Shipment"
+ }))
+ },
+ {
+ key: "supplierQuotes",
+ name: "Supplier Quotes",
+ module: "purchasing",
+ children: supplierQuotes
+ }
+ ];
+
+ return (
+ <UsedInTree
+ tree={tree}
+ revisions={toolData.toolSummary?.revisions}
+ itemReadableId={
+ toolData.toolSummary?.readableId ?? ""
+ }
+ itemReadableIdWithRevision={
+ toolData.toolSummary?.readableIdWithRevision ?? ""
+ }
+ />
+ );
+ }}
+ </Await>
+ </Suspense>
+ </TabsContent>
+ {isManufactured && (
+ <TabsContent
+ value="manufacturing"
+ className="flex-1 overflow-y-auto"
+ >
+ <Suspense
+ fallback={
+ <div className="flex w-full h-full items-center justify-center p-4">
+ <Spinner className="h-6 w-6" />
+ </div>
+ }
+ >
+ <Await resolve={methodTree}>
+ {(resolved) =>
+ resolved ? (
+ <div className="w-full h-full p-2">
+ <BoMExplorer
+ itemType="Tool"
+ makeMethod={resolved.makeMethod}
+ // @ts-ignore
+ methods={resolved.methods}
+ methodId={resolved.makeMethod.id}
+ />
+ </div>
+ ) : null
+ }
+ </Await>
+ </Suspense>
+ </TabsContent>
+ )}
+ </Tabs>
+ }
+ content={
+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
+ <Outlet />
+ </div>
+ }
+ properties={<ToolProperties />}
+ />
+ </div>
+ </div>
</div>
);
}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx
deleted file mode 100644
index cfbb49ec9b..0000000000
--- a/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import { assertIsPost, error, success } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import type { JSONContent } from "@carbon/react";
-import { Spinner, VStack } from "@carbon/react";
-import { Suspense } from "react";
-import type { ActionFunctionArgs } from "react-router";
-import { Await, redirect, useParams } from "react-router";
-import { CadModel } from "~/components";
-import { usePermissions, useRouteData } from "~/hooks";
-import type { ItemFile, ToolSummary } from "~/modules/items";
-import { toolValidator, upsertTool } from "~/modules/items";
-import {
- ItemDocuments,
- ItemNotes,
- ItemRiskRegister
-} from "~/modules/items/ui/Item";
-
-import { setCustomFields } from "~/utils/form";
-import { path } from "~/utils/path";
-
-export async function action({ request, params }: ActionFunctionArgs) {
- assertIsPost(request);
- const { client, userId } = await requirePermissions(request, {
- update: "parts"
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- const formData = await request.formData();
- const validation = await validator(toolValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const updateTool = await upsertTool(client, {
- ...validation.data,
- id: itemId,
- customFields: setCustomFields(formData),
- updatedBy: userId
- });
- if (updateTool.error) {
- throw redirect(
- path.to.tool(itemId),
- await flash(request, error(updateTool.error, "Failed to update part"))
- );
- }
-
- throw redirect(
- path.to.tool(itemId),
- await flash(request, success("Updated tool"))
- );
-}
-
-export default function ToolDetailsRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const toolData = useRouteData<{
- toolSummary: ToolSummary;
- files: Promise<ItemFile[]>;
- }>(path.to.tool(itemId));
-
- if (!toolData) throw new Error("Could not find tool data");
- const permissions = usePermissions();
-
- return (
- <VStack spacing={2} className="p-2">
- <ItemNotes
- id={toolData.toolSummary?.id ?? null}
- title={toolData.toolSummary?.name ?? ""}
- subTitle={toolData.toolSummary?.readableIdWithRevision ?? ""}
- notes={toolData.toolSummary?.notes as JSONContent}
- />
- {permissions.is("employee") && (
- <>
- <Suspense
- fallback={
- <div className="flex w-full h-full rounded bg-gradient-to-tr from-background to-card items-center justify-center">
- <Spinner className="h-10 w-10" />
- </div>
- }
- >
- <Await resolve={toolData?.files}>
- {(resolvedFiles) => (
- <ItemDocuments
- files={resolvedFiles}
- itemId={itemId}
- modelUpload={toolData.toolSummary ?? undefined}
- type="Tool"
- />
- )}
- </Await>
- </Suspense>
-
- <CadModel
- isReadOnly={!permissions.can("update", "parts")}
- metadata={{ itemId }}
- modelPath={toolData?.toolSummary?.modelPath ?? null}
- title="CAD Model"
- />
-
- <ItemRiskRegister itemId={itemId} />
- </>
- )}
- </VStack>
- );
-}
diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.tsx
deleted file mode 100644
index ac2ab401be..0000000000
--- a/apps/erp/app/routes/x+/tool+/$itemId.view.tsx
+++ /dev/null
@@ -1,177 +0,0 @@
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { useRouteData } from "@carbon/remix";
-import { Suspense } from "react";
-import type { LoaderFunctionArgs } from "react-router";
-import { Await, Outlet, useLoaderData, useParams } from "react-router";
-import { ResizablePanels } from "~/components/Layout";
-import type { ItemFile, ToolSummary } from "~/modules/items";
-import { getPartUsedIn } from "~/modules/items";
-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";
-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";
-import ToolProperties from "~/modules/items/ui/Tools/ToolProperties";
-import { path } from "~/utils/path";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
- view: "parts",
- bypassRls: true
- });
-
- const { itemId } = params;
- if (!itemId) throw new Error("Could not find itemId");
-
- return { usedIn: getPartUsedIn(client, itemId, companyId) };
-}
-
-export default function ToolViewRoute() {
- const { itemId } = useParams();
- if (!itemId) throw new Error("Could not find itemId");
-
- const toolData = useRouteData<{
- toolSummary: ToolSummary;
- files: Promise<ItemFile[]>;
- }>(path.to.tool(itemId));
-
- if (!toolData) throw new Error("Could not find tool data");
-
- const { usedIn } = useLoaderData<typeof loader>();
-
- return (
- <div className="flex h-[calc(100dvh-99px)] overflow-hidden w-full">
- <div className="flex flex-grow overflow-hidden">
- <ResizablePanels
- explorer={
- <Suspense fallback={<UsedInSkeleton />}>
- <Await resolve={usedIn}>
- {(resolvedUsedIn) => {
- const {
- issues,
- jobMaterials,
- jobs,
- maintenanceDispatchItems,
- methodMaterials,
- purchaseOrderLines,
- receiptLines,
- quoteLines,
- quoteMaterials,
- salesOrderLines,
- shipmentLines,
- supplierQuotes
- } = resolvedUsedIn;
-
- const tree: UsedInNode[] = [
- {
- key: "issues",
- name: "Issues",
- module: "quality",
- children: issues
- },
- {
- key: "jobs",
- name: "Jobs",
- module: "production",
- children: jobs.map((job) => ({
- ...job,
- methodType: "Make"
- }))
- },
- {
- key: "jobMaterials",
- name: "Job Materials",
- module: "production",
- children: jobMaterials
- },
- {
- key: "maintenanceDispatchItems",
- name: "Maintenance",
- module: "resources",
- children: maintenanceDispatchItems
- },
- {
- key: "methodMaterials",
- name: "Method Materials",
- module: "parts",
- // @ts-expect-error
- children: methodMaterials
- },
- {
- key: "purchaseOrderLines",
- name: "Purchase Orders",
- module: "purchasing",
- children: purchaseOrderLines.map((po) => ({
- ...po,
- methodType: "Buy"
- }))
- },
- {
- key: "receiptLines",
- name: "Receipts",
- module: "inventory",
- children: receiptLines.map((receipt) => ({
- ...receipt,
- methodType: "Pick"
- }))
- },
- {
- key: "quoteLines",
- name: "Quotes",
- module: "sales",
- children: quoteLines
- },
- {
- key: "quoteMaterials",
- name: "Quote Materials",
- module: "sales",
- children: quoteMaterials?.map((qm) => ({
- ...qm,
- documentReadableId: qm.documentReadableId ?? ""
- }))
- },
- {
- key: "salesOrderLines",
- name: "Sales Orders",
- module: "sales",
- children: salesOrderLines
- },
- {
- key: "shipmentLines",
- name: "Shipments",
- module: "inventory",
- children: shipmentLines.map((shipment) => ({
- ...shipment,
- methodType: "Shipment"
- }))
- },
- {
- key: "supplierQuotes",
- name: "Supplier Quotes",
- module: "purchasing",
- children: supplierQuotes
- }
- ];
-
- return (
- <UsedInTree
- tree={tree}
- revisions={toolData.toolSummary?.revisions}
- itemReadableId={toolData.toolSummary?.readableId ?? ""}
- itemReadableIdWithRevision={
- toolData.toolSummary?.readableIdWithRevision ?? ""
- }
- />
- );
- }}
- </Await>
- </Suspense>
- }
- content={
- <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">
- <Outlet />
- </div>
- }
- properties={<ToolProperties />}
- />
- </div>
- </div>
- );
-}
diff --git a/apps/erp/app/utils/path.ts b/apps/erp/app/utils/path.ts
index 84859f5197..30742e9cc2 100644
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@ -461,28 +461,24 @@ export const path = {
consumable: (id: string) => generatePath(`${x}/consumable/${id}`),
consumables: `${x}/items/consumables`,
consumableCosting: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/costing`),
+ generatePath(`${x}/consumable/${id}/costing`),
consumableDetails: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/details`),
+ generatePath(`${x}/consumable/${id}/details`),
consumableInventory: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/inventory`),
+ generatePath(`${x}/consumable/${id}/inventory`),
consumableInventoryLocation: (id: string, locationId: string) =>
- generatePath(
- `${x}/consumable/${id}/view/inventory?location=${locationId}`
- ),
+ generatePath(`${x}/consumable/${id}/inventory?location=${locationId}`),
consumablePlanning: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/planning`),
+ generatePath(`${x}/consumable/${id}/planning`),
consumablePlanningLocation: (id: string, locationId: string) =>
- generatePath(
- `${x}/consumable/${id}/view/planning?location=${locationId}`
- ),
+ generatePath(`${x}/consumable/${id}/planning?location=${locationId}`),
consumablePurchasing: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/purchasing`),
+ generatePath(`${x}/consumable/${id}/purchasing`),
consumableRoot: `${x}/consumable`,
consumableSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/consumable/${itemId}/view/suppliers/${id}`),
+ generatePath(`${x}/consumable/${itemId}/suppliers/${id}`),
consumableSuppliers: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/suppliers`),
+ generatePath(`${x}/consumable/${id}/suppliers`),
convertQuoteToOrder: (id: string) =>
generatePath(`${x}/quote/${id}/convert`),
convertSupplierQuoteToOrder: (id: string) =>
@@ -939,9 +935,9 @@ export const path = {
markTrainingComplete: `${x}/resources/assignments/complete`,
material: (id: string) => generatePath(`${x}/material/${id}`),
materialCosting: (id: string) =>
- generatePath(`${x}/material/${id}/view/costing`),
+ generatePath(`${x}/material/${id}/costing`),
materialDetails: (id: string) =>
- generatePath(`${x}/material/${id}/view/details`),
+ generatePath(`${x}/material/${id}/details`),
materialDimension: (id: string) =>
generatePath(`${x}/items/dimensions/${id}`),
materialDimensions: `${x}/items/dimensions`,
@@ -954,22 +950,22 @@ export const path = {
materialType: (id: string) => generatePath(`${x}/items/types/${id}`),
materialTypes: `${x}/items/types`,
materialInventory: (id: string) =>
- generatePath(`${x}/material/${id}/view/inventory`),
+ generatePath(`${x}/material/${id}/inventory`),
materialInventoryLocation: (id: string, locationId: string) =>
- generatePath(`${x}/material/${id}/view/inventory?location=${locationId}`),
+ generatePath(`${x}/material/${id}/inventory?location=${locationId}`),
materialPlanning: (id: string) =>
- generatePath(`${x}/material/${id}/view/planning`),
+ generatePath(`${x}/material/${id}/planning`),
materialPlanningLocation: (id: string, locationId: string) =>
- generatePath(`${x}/material/${id}/view/planning?location=${locationId}`),
+ generatePath(`${x}/material/${id}/planning?location=${locationId}`),
materialPricing: (id: string) =>
- generatePath(`${x}/material/${id}/view/pricing`),
+ generatePath(`${x}/material/${id}/pricing`),
materialPurchasing: (id: string) =>
- generatePath(`${x}/material/${id}/view/purchasing`),
+ generatePath(`${x}/material/${id}/purchasing`),
materialRoot: `${x}/material`,
materialSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/material/${itemId}/view/suppliers/${id}`),
+ generatePath(`${x}/material/${itemId}/suppliers/${id}`),
materialSuppliers: (id: string) =>
- generatePath(`${x}/material/${id}/view/suppliers`),
+ generatePath(`${x}/material/${id}/suppliers`),
materials: `${x}/items/materials`,
materialSubstance: (id: string) =>
generatePath(`${x}/items/substances/${id}`),
@@ -1006,7 +1002,7 @@ export const path = {
newCompany: `${x}/settings/company/new`,
newConsumable: `${x}/consumable/new`,
newConsumableSupplier: (id: string) =>
- generatePath(`${x}/consumable/${id}/view/purchasing/new`),
+ generatePath(`${x}/consumable/${id}/purchasing/new`),
newContractor: `${x}/resources/contractors/new`,
newCurrency: `${x}/accounting/currencies/new`,
newCustomer: `${x}/customer/new`,
@@ -1071,7 +1067,7 @@ export const path = {
newMaterialGrade: `${x}/items/grades/new`,
newMaterialSubstance: `${x}/items/substances/new`,
newMaterialSupplier: (id: string) =>
- generatePath(`${x}/material/${id}/view/purchasing/new`),
+ generatePath(`${x}/material/${id}/purchasing/new`),
newNote: `${x}/shared/notes/new`,
newPart: `${x}/part/new`,
newPartSupplier: (id: string) =>
@@ -1165,34 +1161,20 @@ export const path = {
generatePath(`${x}/sales/no-quote-reasons/${id}`),
notificationSettings: `${x}/account/notifications`,
part: (id: string) => generatePath(`${x}/part/${id}`),
- partCosting: (id: string) => generatePath(`${x}/part/${id}/view/costing`),
- partDetails: (id: string) => generatePath(`${x}/part/${id}/view/details`),
- partInventory: (id: string) =>
- generatePath(`${x}/part/${id}/view/inventory`),
+ partCosting: (id: string) => generatePath(`${x}/part/${id}/costing`),
+ partDetails: (id: string) => generatePath(`${x}/part/${id}/details`),
+ partMake: (id: string, makeMethodId: string) =>
+ generatePath(`${x}/part/${id}/make/${makeMethodId}`),
+ partInventory: (id: string) => generatePath(`${x}/part/${id}/inventory`),
partInventoryLocation: (id: string, locationId: string) =>
- generatePath(`${x}/part/${id}/view/inventory?location=${locationId}`),
- partMethod: (id: string, methodId: string) =>
- generatePath(`${x}/part/${id}/manufacturing/${methodId}`),
- partMakeMethod: (id: string, methodId: string) =>
- generatePath(`${x}/part/${id}/manufacturing/${methodId}/method`),
- partManufacturing: (id: string) =>
- generatePath(`${x}/part/${id}/manufacturing/methods`),
- partManufacturingMaterial: (
- itemId: string,
- methodId: string,
- makeMethodId: string
- ) =>
- generatePath(
- `${x}/part/${itemId}/manufacturing/${methodId}/make/${makeMethodId}`
- ),
- partPlanning: (id: string) => generatePath(`${x}/part/${id}/view/planning`),
+ generatePath(`${x}/part/${id}/inventory?location=${locationId}`),
+ partPlanning: (id: string) => generatePath(`${x}/part/${id}/planning`),
partPlanningLocation: (id: string, locationId: string) =>
- generatePath(`${x}/part/${id}/view/planning?location=${locationId}`),
- partPricing: (id: string) => generatePath(`${x}/part/${id}/view/pricing`),
- partPurchasing: (id: string) =>
- generatePath(`${x}/part/${id}/view/purchasing`),
+ generatePath(`${x}/part/${id}/planning?location=${locationId}`),
+ partPricing: (id: string) => generatePath(`${x}/part/${id}/pricing`),
+ partPurchasing: (id: string) => generatePath(`${x}/part/${id}/purchasing`),
partRoot: `${x}/part`,
- partSales: (id: string) => generatePath(`${x}/part/${id}/view/sales`),
+ partSales: (id: string) => generatePath(`${x}/part/${id}/sales`),
partSupplier: (itemId: string, id: string) =>
generatePath(`${x}/part/${itemId}/suppliers/${id}`),
parts: `${x}/items/parts`,
@@ -1571,32 +1553,18 @@ export const path = {
theme: `${x}/account/theme`,
timecards: `${x}/timecards`,
tool: (id: string) => generatePath(`${x}/tool/${id}`),
- toolCosting: (id: string) => generatePath(`${x}/tool/${id}/view/costing`),
- toolDetails: (id: string) => generatePath(`${x}/tool/${id}/view/details`),
- toolInventory: (id: string) =>
- generatePath(`${x}/tool/${id}/view/inventory`),
+ toolCosting: (id: string) => generatePath(`${x}/tool/${id}/costing`),
+ toolDetails: (id: string) => generatePath(`${x}/tool/${id}/details`),
+ toolInventory: (id: string) => generatePath(`${x}/tool/${id}/inventory`),
toolInventoryLocation: (id: string, locationId: string) =>
- generatePath(`${x}/tool/${id}/view/inventory?location=${locationId}`),
- toolMethod: (id: string, methodId: string) =>
- generatePath(`${x}/tool/${id}/manufacturing/${methodId}`),
- toolMakeMethod: (id: string, methodId: string) =>
- generatePath(`${x}/tool/${id}/manufacturing/${methodId}/method`),
- toolManufacturing: (id: string) =>
- generatePath(`${x}/tool/${id}/manufacturing/methods`),
- toolManufacturingMaterial: (
- itemId: string,
- methodId: string,
- makeMethodId: string
- ) =>
- generatePath(
- `${x}/tool/${itemId}/manufacturing/${methodId}/make/${makeMethodId}`
- ),
- toolPlanning: (id: string) => generatePath(`${x}/tool/${id}/view/planning`),
+ generatePath(`${x}/tool/${id}/inventory?location=${locationId}`),
+ toolMake: (id: string, makeMethodId: string) =>
+ generatePath(`${x}/tool/${id}/make/${makeMethodId}`),
+ toolPlanning: (id: string) => generatePath(`${x}/tool/${id}/planning`),
toolPlanningLocation: (id: string, locationId: string) =>
- generatePath(`${x}/tool/${id}/view/planning?location=${locationId}`),
- toolPricing: (id: string) => generatePath(`${x}/tool/${id}/view/pricing`),
- toolPurchasing: (id: string) =>
- generatePath(`${x}/tool/${id}/view/purchasing`),
+ generatePath(`${x}/tool/${id}/planning?location=${locationId}`),
+ toolPricing: (id: string) => generatePath(`${x}/tool/${id}/pricing`),
+ toolPurchasing: (id: string) => generatePath(`${x}/tool/${id}/purchasing`),
toolRoot: `${x}/tool`,
toolSupplier: (itemId: string, id: string) =>
generatePath(`${x}/tool/${itemId}/view/suppliers/${id}`),
diff --git a/packages/react/src/Tabs.tsx b/packages/react/src/Tabs.tsx
index 8bb6a6f82e..1724b7da2e 100644
--- a/packages/react/src/Tabs.tsx
+++ b/packages/react/src/Tabs.tsx
@@ -36,7 +36,7 @@ const TabsTrigger = forwardRef<
variant === "primary" &&
"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow",
variant === "secondary" &&
- "data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
+ "data-[state=active]:bg-background data-[state=active]:text-foreground",
className
)}
{...props}