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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: update layout on item master
Brad Barbindbf99a56a58a
diff --git a/apps/erp/app/components/Grid/Grid.tsx b/apps/erp/app/components/Grid/Grid.tsxindex 6dfcc0ff49..bd19e34129 100644--- a/apps/erp/app/components/Grid/Grid.tsx+++ b/apps/erp/app/components/Grid/Grid.tsx@@ -321,16 +321,19 @@ const Grid = <T extends object>({const rows = table.getRowModel().rows;return (- <VStack spacing={0} className="h-full">+ <VStack spacing={0} className="h-full w-full"><div- className="w-full h-full bg-card overflow-x-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"- style={{- contain: contained ? "strict" : undefined,- }}+ className={cn(+ "w-full h-full overflow-x-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent",+ contained ? "bg-card" : "relative"+ )}ref={tableContainerRef}onKeyDown={onKeyDown}>- <Table full={contained} className="absolute border">+ <Table+ full={contained}+ className={cn("border", !contained && "w-full")}+ ><Thead className="sticky top-0 z-10">{table.getHeaderGroups().map((headerGroup) => (<Tr key={headerGroup.id} className="h-10">@@ -342,17 +345,11 @@ const Grid = <T extends object>({accessorKey &&!accessorKey.endsWith(".id") &&header.column.columnDef.enableSorting !== false;- // const sorted = isSorted(accessorKey ?? "");return (<Thkey={header.id}colSpan={header.colSpan}- // onClick={- // sortable- // ? () => toggleSortBy(accessorKey ?? "")- // : undefined- // }className={cn("border-r border-border px-4 py-3 whitespace-nowrap text-sm",sortable && "cursor-pointer"@@ -367,20 +364,6 @@ const Grid = <T extends object>({header.column.columnDef.header,header.getContext())}- {/* <span className="pl-4">- {sorted ? (- sorted === -1 ? (- <FaSortDown aria-label="sorted descending" />- ) : (- <FaSortUp aria-label="sorted ascending" />- )- ) : sortable ? (- <FaSort- aria-label="sort"- style={{ opacity: 0.4 }}- />- ) : null}- </span> */}</div>)}</Th>diff --git a/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx b/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsxindex a72bda18bb..b3d60d2973 100644--- a/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx+++ b/apps/erp/app/components/Layout/Navigation/DetailsTopbar.tsx@@ -19,14 +19,15 @@ type DetailTopbarProps = {icon?: IconType;count?: number;shortcut?: string;+ isActive?: (pathname: string) => boolean;}[];- matchRouteParts?: number;+preserveParams?: boolean;};const DetailTopbar = ({links,- matchRouteParts,+preserveParams = false,}: DetailTopbarProps) => {const navigate = useNavigate();@@ -50,13 +51,8 @@ const DetailTopbar = ({return (<div className="inline-flex h-8 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground">{links.map((route) => {- const isActive = matchRouteParts- ? location.pathname.includes(- route.to- .split("/")- .slice(1, matchRouteParts + 1)- .join("/")- )+ const isActive = route.isActive+ ? route.isActive(location.pathname): location.pathname.includes(route.to);const linkTo = preserveParamsdiff --git a/apps/erp/app/modules/items/ui/Item/CustomerParts/CustomerParts.tsx b/apps/erp/app/modules/items/ui/Item/CustomerParts/CustomerParts.tsxindex c7c8c30e26..4e49c2d7f7 100644--- a/apps/erp/app/modules/items/ui/Item/CustomerParts/CustomerParts.tsx+++ b/apps/erp/app/modules/items/ui/Item/CustomerParts/CustomerParts.tsx@@ -104,7 +104,7 @@ const CustomerParts = ({ customerParts, itemId }: CustomerPartsProps) => {return (<>- <Card className="w-full h-full min-h-[50vh]">+ <Card className="w-full"><HStack className="justify-between items-start"><CardHeader><CardTitle>Customer Parts</CardTitle>diff --git a/apps/erp/app/modules/items/ui/Item/ItemCostHistoryChart.tsx b/apps/erp/app/modules/items/ui/Item/ItemCostHistoryChart.tsxindex 654d6c53ce..624df03a35 100644--- a/apps/erp/app/modules/items/ui/Item/ItemCostHistoryChart.tsx+++ b/apps/erp/app/modules/items/ui/Item/ItemCostHistoryChart.tsx@@ -3,7 +3,6 @@ import {Card,CardAction,CardContent,- CardDescription,CardHeader,CardTitle,DropdownMenu,@@ -161,8 +160,7 @@ export function ItemCostHistoryChart({<Tabs defaultValue="chart"><HStack className="w-full justify-between"><CardHeader>- <CardTitle>Purchase History</CardTitle>- <CardDescription>Purchase cost over the last year</CardDescription>+ <CardTitle>Cost History</CardTitle></CardHeader><CardAction className="flex-row-reverse items-center gap-2"><DropdownMenu>diff --git a/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx b/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsxindex 604b3116df..fa57d1d437 100644--- a/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx+++ b/apps/erp/app/modules/items/ui/Item/ItemPlanningChart.tsx@@ -134,7 +134,7 @@ export const ItemPlanningChart = ({<CardTitle>Demand</CardTitle></CardHeader><CardContent>- <div className="min-h-[200px] max-h-[360px]">+ <div className="w-full h-[360px]"><Loading isLoading={isFetching}><ChartContainer config={chartConfig} className="w-full h-full"><BarChart data={chartData}>diff --git a/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx b/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsxindex 6700e84cc6..7abf53bac2 100644--- a/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx+++ b/apps/erp/app/modules/items/ui/Item/SupplierParts/SupplierParts.tsx@@ -104,7 +104,7 @@ const SupplierParts = ({ supplierParts }: SupplierPartsProps) => {return (<>- <Card className="w-full h-full min-h-[50vh]">+ <Card className="w-full"><HStack className="justify-between items-start"><CardHeader><CardTitle>Supplier Parts</CardTitle>@@ -113,6 +113,7 @@ const SupplierParts = ({ supplierParts }: SupplierPartsProps) => {</HStack><CardContent><Grid<SupplierPart>+ contained={false}data={supplierParts}columns={columns}canEdit={canEdit}diff --git a/apps/erp/app/modules/items/ui/Item/UsedIn.tsx b/apps/erp/app/modules/items/ui/Item/UsedIn.tsxindex 94fdd53dc9..3485e5c663 100644--- a/apps/erp/app/modules/items/ui/Item/UsedIn.tsx+++ b/apps/erp/app/modules/items/ui/Item/UsedIn.tsx@@ -119,7 +119,7 @@ export function UsedInTree({});return (- <VStack>+ <VStack className="w-full p-2"><HStack className="w-full py"><InputGroup size="sm" className="flex flex-grow"><InputLeftElement>diff --git a/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx b/apps/erp/app/modules/items/ui/Parts/PartHeader.tsxindex b2fab9c297..0e2d408dec 100644--- a/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx+++ b/apps/erp/app/modules/items/ui/Parts/PartHeader.tsx@@ -30,7 +30,7 @@ const PartHeader = () => {</HStack></VStack><VStack spacing={0} className="flex-shrink justify-center items-end">- <DetailsTopbar links={links} matchRouteParts={4} />+ <DetailsTopbar links={links} /></VStack></div>);diff --git a/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx b/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsxindex 654b099592..54967b1f8c 100644--- a/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx+++ b/apps/erp/app/modules/items/ui/Parts/usePartNavigation.tsx@@ -53,6 +53,7 @@ export function usePartNavigation() {role: ["employee"],icon: LuFactory,shortcut: "Command+Shift+m",+ isActive: (pathname: string) => pathname.includes("manufacturing"),},{name: "Costing",diff --git a/apps/erp/app/modules/items/ui/Tools/ToolHeader.tsx b/apps/erp/app/modules/items/ui/Tools/ToolHeader.tsxindex cac0948e8a..e02cbc0f1b 100644--- a/apps/erp/app/modules/items/ui/Tools/ToolHeader.tsx+++ b/apps/erp/app/modules/items/ui/Tools/ToolHeader.tsx@@ -28,7 +28,7 @@ const ToolHeader = () => {</HStack></VStack><VStack spacing={0} className="flex-shrink justify-center items-end">- <DetailsTopbar links={links} matchRouteParts={4} />+ <DetailsTopbar links={links} /></VStack></div>);diff --git a/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx b/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsxindex 139c16c44d..c4f7c819b7 100644--- a/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx+++ b/apps/erp/app/modules/items/ui/Tools/useToolNavigation.tsx@@ -52,6 +52,7 @@ export function useToolNavigation() {role: ["employee"],icon: LuFactory,shortcut: "Command+Shift+m",+ isActive: (pathname: string) => pathname.includes("manufacturing"),},{name: "Costing",diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.details.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.details.tsxdeleted file mode 100644index 7e02fc861f..0000000000--- a/apps/erp/app/routes/x+/consumable+/$itemId.details.tsx+++ /dev/null@@ -1,240 +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 {- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- ScrollArea,- Spinner,- VStack,-} from "@carbon/react";-import { Await, useLoaderData, useParams } from "@remix-run/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";-import { defer, redirect } from "@vercel/remix";-import { Suspense } from "react";-import { usePermissions, useRouteData } from "~/hooks";-import type { Consumable, ItemFile } from "~/modules/items";-import {- consumableValidator,- getMaterialUsedIn,- upsertConsumable,-} from "~/modules/items";-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";--import { 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");-- return defer({ usedIn: getMaterialUsedIn(client, itemId, companyId) });-}--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(consumableValidator).validate(formData);-- if (validation.error) {- return validationError(validation.error);- }-- const updateConsumable = await upsertConsumable(client, {- ...validation.data,- id: itemId,- customFields: setCustomFields(formData),- updatedBy: userId,- });- if (updateConsumable.error) {- throw redirect(- path.to.consumable(itemId),- await flash(- request,- error(updateConsumable.error, "Failed to update consumable")- )- );- }-- throw redirect(- path.to.consumable(itemId),- await flash(request, success("Updated consumable"))- );-}--export default function ConsumableDetailsRoute() {- const { usedIn } = useLoaderData<typeof loader>();- const permissions = usePermissions();-- const { itemId } = useParams();- if (!itemId) throw new Error("Could not find itemId");-- const consumableData = useRouteData<{- consumableSummary: Consumable;- files: Promise<ItemFile[]>;- }>(path.to.consumable(itemId));- if (!consumableData) throw new Error("Could not find consumable data");-- return (- <div className="flex flex-grow overflow-hidden">- <ResizablePanelGroup direction="horizontal">- <ResizablePanel- order={1}- minSize={10}- defaultSize={20}- className="bg-card"- >- <ScrollArea className="h-[calc(100dvh-99px)]">- <div className="grid h-full overflow-hidden p-2">- <Suspense fallback={<UsedInSkeleton />}>- <Await resolve={usedIn}>- {(resolvedUsedIn) => {- const {- jobMaterials,- methodMaterials,- purchaseOrderLines,- receiptLines,- quoteMaterials,- salesOrderLines,- shipmentLines,- supplierQuotes,- } = resolvedUsedIn;-- const tree: UsedInNode[] = [- {- key: "jobMaterials",- name: "Job Materials",- module: "production",- children: jobMaterials,- },- {- 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>- </div>- </ScrollArea>- </ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel order={2} minSize={40} defaultSize={60}>- <ScrollArea className="h-[calc(100dvh-99px)]">- <VStack spacing={2} className="p-2">- <ItemNotes- id={consumableData.consumableSummary?.id ?? null}- title={consumableData.consumableSummary?.name ?? ""}- subTitle={- consumableData.consumableSummary?.readableIdWithRevision ?? ""- }- notes={consumableData.consumableSummary?.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={consumableData?.files}>- {(files) => (- <ItemDocuments- files={files ?? []}- itemId={itemId}- type="Consumable"- />- )}- </Await>- </Suspense>- )}- </VStack>- </ScrollArea>- </ResizablePanel>- </ResizablePanelGroup>- </div>- );-}diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.tsxindex e72f19f346..2c985ee3b0 100644--- a/apps/erp/app/routes/x+/consumable+/$itemId.tsx+++ b/apps/erp/app/routes/x+/consumable+/$itemId.tsx@@ -10,10 +10,7 @@ import {getPickMethods,getSupplierParts,} from "~/modules/items";-import {- ConsumableHeader,- ConsumableProperties,-} from "~/modules/items/ui/Consumables";+import { ConsumableHeader } from "~/modules/items/ui/Consumables";import { getTagsList } from "~/modules/shared";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -65,12 +62,7 @@ export default function ConsumableRoute() {return (<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full"><ConsumableHeader />- <div className="flex h-[calc(100dvh-99px)] w-full">- <div className="flex h-full w-full overflow-y-auto scrollbar-hide">- <Outlet />- </div>- <ConsumableProperties />- </div>+ <Outlet /></div>);}diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.costing.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.costing.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/consumable+/$itemId.costing.tsxrename to apps/erp/app/routes/x+/consumable+/$itemId.view.costing.tsxdiff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsxnew file mode 100644index 0000000000..d070e37fe2--- /dev/null+++ b/apps/erp/app/routes/x+/consumable+/$itemId.view.details.tsx@@ -0,0 +1,102 @@+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 { Await, useParams } from "@remix-run/react";+import type { ActionFunctionArgs } from "@vercel/remix";+import { redirect } from "@vercel/remix";+import { Suspense } from "react";+import { usePermissions, useRouteData } from "~/hooks";+import type { ConsumableSummary, ItemFile } from "~/modules/items";+import { consumableValidator, upsertConsumable } from "~/modules/items";+import { ItemDocuments, ItemNotes } 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(consumableValidator).validate(formData);++ if (validation.error) {+ return validationError(validation.error);+ }++ const updateConsumable = await upsertConsumable(client, {+ ...validation.data,+ id: itemId,+ customFields: setCustomFields(formData),+ updatedBy: userId,+ });+ if (updateConsumable.error) {+ throw redirect(+ path.to.consumable(itemId),+ await flash(+ request,+ error(updateConsumable.error, "Failed to update consumable")+ )+ );+ }++ throw redirect(+ path.to.consumable(itemId),+ await flash(request, success("Updated consumable"))+ );+}++export default function ConsumableDetailsRoute() {+ 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 permissions = usePermissions();++ return (+ <VStack spacing={2} className="p-2">+ <ItemNotes+ id={consumableData.consumableSummary?.id ?? null}+ title={consumableData.consumableSummary?.name ?? ""}+ subTitle={+ consumableData.consumableSummary?.readableIdWithRevision ?? ""+ }+ notes={consumableData.consumableSummary?.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={consumableData?.files}>+ {(resolvedFiles) => (+ <ItemDocuments+ files={resolvedFiles}+ itemId={itemId}+ type="Consumable"+ />+ )}+ </Await>+ </Suspense>+ </>+ )}+ </VStack>+ );+}diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsxsimilarity index 95%rename from apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsxrename to apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsxindex 91273e87d8..565c4f76e1 100644--- a/apps/erp/app/routes/x+/consumable+/$itemId.inventory.tsx+++ b/apps/erp/app/routes/x+/consumable+/$itemId.view.inventory.tsx@@ -18,7 +18,6 @@ import {upsertPickMethod,} from "~/modules/items";import { PickMethodForm } from "~/modules/items/ui/Item";-import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";import { useItems } from "~/stores/items";@@ -199,13 +198,8 @@ export default function ConsumableInventoryRoute() {unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.consumableRoot);- const {- consumableInventory,- itemShelfQuantities,- quantities,- itemId,- locationId,- } = useLoaderData<typeof loader>();+ const { consumableInventory, itemShelfQuantities, quantities, itemId } =+ useLoaderData<typeof loader>();const consumableData = useRouteData<{consumableSummary: Consumable;@@ -240,10 +234,6 @@ export default function ConsumableInventoryRoute() {quantities={quantities}shelves={sharedConsumablesData?.shelves ?? []}/>- <ItemPlanningChart- itemId={consumableInventory.itemId}- locationId={locationId}- /></VStack>);}diff --git a/apps/erp/app/routes/x+/consumable+/$itemId.planning.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.planning.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/consumable+/$itemId.planning.tsxrename to apps/erp/app/routes/x+/consumable+/$itemId.view.planning.tsxdiff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.new.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/consumable+/$itemId.purchasing.new.tsxrename to apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.new.tsxdiff --git a/apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/consumable+/$itemId.purchasing.tsxrename to apps/erp/app/routes/x+/consumable+/$itemId.view.purchasing.tsxdiff --git a/apps/erp/app/routes/x+/consumable+/$itemId.view.tsx b/apps/erp/app/routes/x+/consumable+/$itemId.view.tsxnew file mode 100644index 0000000000..5599a356f3--- /dev/null+++ b/apps/erp/app/routes/x+/consumable+/$itemId.view.tsx@@ -0,0 +1,154 @@+import { Await, Outlet, useLoaderData, useParams } from "@remix-run/react";+import { ResizablePanels } from "~/components/Layout";++import { requirePermissions } from "@carbon/auth/auth.server";+import { useRouteData } from "@carbon/remix";+import type { LoaderFunctionArgs } from "@vercel/remix";+import { defer } from "@vercel/remix";+import { Suspense } from "react";+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 defer({ 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 {+ jobMaterials,++ methodMaterials,+ purchaseOrderLines,+ receiptLines,++ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes,+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials,+ },+ {+ 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+/material+/$itemId.details.tsx b/apps/erp/app/routes/x+/material+/$itemId.details.tsxdeleted file mode 100644index aff69ecacb..0000000000--- a/apps/erp/app/routes/x+/material+/$itemId.details.tsx+++ /dev/null@@ -1,240 +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 {- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- ScrollArea,- Spinner,- VStack,-} from "@carbon/react";-import { Await, useLoaderData, useParams } from "@remix-run/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";-import { defer, redirect } from "@vercel/remix";-import { Suspense } from "react";-import { usePermissions, useRouteData } from "~/hooks";-import type { ItemFile, Material } from "~/modules/items";-import {- getMaterialUsedIn,- materialValidator,- upsertMaterial,-} from "~/modules/items";-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";--import { 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");-- return defer({ usedIn: getMaterialUsedIn(client, itemId, companyId) });-}--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(materialValidator).validate(formData);-- if (validation.error) {- return validationError(validation.error);- }-- const updateMaterial = await upsertMaterial(client, {- ...validation.data,- id: itemId,- customFields: setCustomFields(formData),- updatedBy: userId,- });- if (updateMaterial.error) {- throw redirect(- path.to.material(itemId),- await flash(- request,- error(updateMaterial.error, "Failed to update material")- )- );- }-- throw redirect(- path.to.material(itemId),- await flash(request, success("Updated material"))- );-}--export default function MaterialDetailsRoute() {- const { usedIn } = useLoaderData<typeof loader>();- const permissions = usePermissions();-- const { itemId } = useParams();- if (!itemId) throw new Error("Could not find itemId");-- const materialData = useRouteData<{- materialSummary: Material;- files: Promise<ItemFile[]>;- }>(path.to.material(itemId));- if (!materialData) throw new Error("Could not find material data");-- return (- <div className="flex flex-grow overflow-hidden">- <ResizablePanelGroup direction="horizontal">- <ResizablePanel- order={1}- minSize={10}- defaultSize={20}- className="bg-card"- >- <ScrollArea className="h-[calc(100dvh-99px)]">- <div className="grid h-full overflow-hidden p-2">- <Suspense fallback={<UsedInSkeleton />}>- <Await resolve={usedIn}>- {(resolvedUsedIn) => {- const {- jobMaterials,- methodMaterials,- purchaseOrderLines,- receiptLines,- quoteMaterials,- salesOrderLines,- shipmentLines,- supplierQuotes,- } = resolvedUsedIn;-- const tree: UsedInNode[] = [- {- key: "jobMaterials",- name: "Job Materials",- module: "production",- children: jobMaterials,- },- {- 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={materialData.materialSummary?.revisions}- itemReadableId={- materialData.materialSummary?.readableId ?? ""- }- itemReadableIdWithRevision={- materialData.materialSummary- ?.readableIdWithRevision ?? ""- }- />- );- }}- </Await>- </Suspense>- </div>- </ScrollArea>- </ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel order={2} minSize={40} defaultSize={60}>- <ScrollArea className="h-[calc(100dvh-99px)]">- <VStack spacing={2} className="p-2">- <ItemNotes- id={materialData.materialSummary?.id ?? null}- title={materialData.materialSummary?.name ?? ""}- subTitle={- materialData.materialSummary?.readableIdWithRevision ?? ""- }- notes={materialData.materialSummary?.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={materialData?.files}>- {(files) => (- <ItemDocuments- files={files ?? []}- itemId={itemId}- type="Material"- />- )}- </Await>- </Suspense>- )}- </VStack>- </ScrollArea>- </ResizablePanel>- </ResizablePanelGroup>- </div>- );-}diff --git a/apps/erp/app/routes/x+/material+/$itemId.tsx b/apps/erp/app/routes/x+/material+/$itemId.tsxindex 59f4742ee1..cbfe3b1761 100644--- a/apps/erp/app/routes/x+/material+/$itemId.tsx+++ b/apps/erp/app/routes/x+/material+/$itemId.tsx@@ -1,4 +1,4 @@-import { error } from "@carbon/auth";+import { error, getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import { Outlet } from "@remix-run/react";@@ -6,15 +6,12 @@ import type { LoaderFunctionArgs } from "@vercel/remix";import { defer, redirect } from "@vercel/remix";import {getItemFiles,+ getMakeMethods,getMaterial,getPickMethods,getSupplierParts,} from "~/modules/items";-import {- MaterialHeader,- MaterialProperties,-} from "~/modules/items/ui/Materials";-+import { MaterialHeader } from "~/modules/items/ui/Materials";import { getTagsList } from "~/modules/shared";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -26,26 +23,26 @@ export const handle: Handle = {};export async function loader({ request, params }: LoaderFunctionArgs) {- const { client, companyId } = await requirePermissions(request, {+ const { 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(client, itemId, companyId),- getSupplierParts(client, itemId, companyId),- getPickMethods(client, itemId, companyId),- getTagsList(client, companyId, "material"),+ getMaterial(serviceRole, itemId, companyId),+ getSupplierParts(serviceRole, itemId, companyId),+ getPickMethods(serviceRole, itemId, companyId),+ getTagsList(serviceRole, companyId, "material"),]);if (materialSummary.error) {throw redirect(- path.to.materials,+ path.to.items,await flash(request,error(materialSummary.error, "Failed to load material summary")@@ -55,9 +52,10 @@ export async function loader({ request, params }: LoaderFunctionArgs) {return defer({materialSummary: materialSummary.data,- files: getItemFiles(client, itemId, companyId),+ files: getItemFiles(serviceRole, itemId, companyId),supplierParts: supplierParts.data ?? [],pickMethods: pickMethods.data ?? [],+ makeMethods: getMakeMethods(serviceRole, itemId, companyId),tags: tags.data ?? [],});}@@ -66,12 +64,7 @@ export default function MaterialRoute() {return (<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full"><MaterialHeader />- <div className="flex h-[calc(100dvh-99px)] w-full">- <div className="flex h-full w-full overflow-y-auto scrollbar-hide">- <Outlet />- </div>- <MaterialProperties />- </div>+ <Outlet /></div>);}diff --git a/apps/erp/app/routes/x+/material+/$itemId.costing.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.costing.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/material+/$itemId.costing.tsxrename to apps/erp/app/routes/x+/material+/$itemId.view.costing.tsxdiff --git a/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.details.tsxnew file mode 100644index 0000000000..9de00776d3--- /dev/null+++ b/apps/erp/app/routes/x+/material+/$itemId.view.details.tsx@@ -0,0 +1,100 @@+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 { Await, useParams } from "@remix-run/react";+import type { ActionFunctionArgs } from "@vercel/remix";+import { redirect } from "@vercel/remix";+import { Suspense } from "react";+import { usePermissions, useRouteData } from "~/hooks";+import type { ItemFile, MaterialSummary } from "~/modules/items";+import { materialValidator, upsertMaterial } from "~/modules/items";+import { ItemDocuments, ItemNotes } 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(materialValidator).validate(formData);++ if (validation.error) {+ return validationError(validation.error);+ }++ const updateMaterial = await upsertMaterial(client, {+ ...validation.data,+ id: itemId,+ customFields: setCustomFields(formData),+ updatedBy: userId,+ });+ if (updateMaterial.error) {+ throw redirect(+ path.to.material(itemId),+ await flash(+ request,+ error(updateMaterial.error, "Failed to update material")+ )+ );+ }++ throw redirect(+ path.to.material(itemId),+ await flash(request, success("Updated material"))+ );+}++export default function MaterialDetailsRoute() {+ 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 permissions = usePermissions();++ return (+ <VStack spacing={2} className="p-2">+ <ItemNotes+ id={materialData.materialSummary?.id ?? null}+ title={materialData.materialSummary?.name ?? ""}+ subTitle={materialData.materialSummary?.readableIdWithRevision ?? ""}+ notes={materialData.materialSummary?.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={materialData?.files}>+ {(resolvedFiles) => (+ <ItemDocuments+ files={resolvedFiles}+ itemId={itemId}+ type="Material"+ />+ )}+ </Await>+ </Suspense>+ </>+ )}+ </VStack>+ );+}diff --git a/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsxsimilarity index 95%rename from apps/erp/app/routes/x+/material+/$itemId.inventory.tsxrename to apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsxindex 2bb3ec8d60..495340c215 100644--- a/apps/erp/app/routes/x+/material+/$itemId.inventory.tsx+++ b/apps/erp/app/routes/x+/material+/$itemId.view.inventory.tsx@@ -17,7 +17,6 @@ import {upsertPickMethod,} from "~/modules/items";import { PickMethodForm } from "~/modules/items/ui/Item";-import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";import { useItems } from "~/stores";@@ -195,13 +194,8 @@ export default function MaterialInventoryRoute() {unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.materialRoot);- const {- materialInventory,- itemShelfQuantities,- quantities,- itemId,- locationId,- } = useLoaderData<typeof loader>();+ const { materialInventory, itemShelfQuantities, quantities, itemId } =+ useLoaderData<typeof loader>();const materialData = useRouteData<{materialSummary: Material;@@ -236,7 +230,6 @@ export default function MaterialInventoryRoute() {quantities={quantities}shelves={sharedMaterialsData?.shelves ?? []}/>- <ItemPlanningChart itemId={itemId} locationId={locationId} /></VStack>);}diff --git a/apps/erp/app/routes/x+/material+/$itemId.planning.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.planning.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/material+/$itemId.planning.tsxrename to apps/erp/app/routes/x+/material+/$itemId.view.planning.tsxdiff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.purchasing.new.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/material+/$itemId.purchasing.new.tsxrename to apps/erp/app/routes/x+/material+/$itemId.view.purchasing.new.tsxdiff --git a/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.purchasing.tsxsimilarity index 87%rename from apps/erp/app/routes/x+/material+/$itemId.purchasing.tsxrename to apps/erp/app/routes/x+/material+/$itemId.view.purchasing.tsxindex 036edf8caf..b1af5c7304 100644--- a/apps/erp/app/routes/x+/material+/$itemId.purchasing.tsx+++ b/apps/erp/app/routes/x+/material+/$itemId.view.purchasing.tsx@@ -12,11 +12,13 @@ import { getBatchProperties } from "~/modules/inventory";import BatchPropertiesConfig from "~/modules/inventory/ui/Batches/BatchPropertiesConfig";import type { SupplierPart } from "~/modules/items";import {+ getItemCostHistory,getItemReplenishment,itemPurchasingValidator,upsertItemPurchasing,} from "~/modules/items";import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";+import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";import { path } from "~/utils/path";export async function loader({ request, params }: LoaderFunctionArgs) {@@ -27,8 +29,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const { itemId } = params;if (!itemId) throw new Error("Could not find itemId");- const [materialPurchasingResult] = await Promise.all([+ const [materialPurchasingResult, itemCostHistory] = await Promise.all([getItemReplenishment(client, itemId, companyId),+ getItemCostHistory(client, itemId, companyId),]);if (materialPurchasingResult.error) {@@ -47,6 +50,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {return defer({materialPurchasing: materialPurchasingResult.data,batchProperties: getBatchProperties(client, [itemId], companyId),+ itemCostHistory: itemCostHistory.data ?? [],});}@@ -93,7 +97,7 @@ export async function action({ request, params }: ActionFunctionArgs) {}export default function MaterialPurchasingRoute() {- const { materialPurchasing, batchProperties } =+ const { materialPurchasing, batchProperties, itemCostHistory } =useLoaderData<typeof loader>();const { itemId } = useParams();@@ -104,7 +108,10 @@ export default function MaterialPurchasingRoute() {const supplierParts = routeData?.supplierParts ?? [];const materialData = useRouteData<{- materialSummary: { itemTrackingType?: string };+ materialSummary: {+ itemTrackingType?: string;+ readableIdWithRevision?: string;+ };}>(path.to.material(itemId));const initialValues = {@@ -142,6 +149,10 @@ export default function MaterialPurchasingRoute() {</Await></Suspense>)}+ <ItemCostHistoryChart+ readableId={materialData?.materialSummary?.readableIdWithRevision ?? ""}+ itemCostHistory={itemCostHistory}+ /></VStack>);}diff --git a/apps/erp/app/routes/x+/material+/$itemId.view.tsx b/apps/erp/app/routes/x+/material+/$itemId.view.tsxnew file mode 100644index 0000000000..ae8c6d349f--- /dev/null+++ b/apps/erp/app/routes/x+/material+/$itemId.view.tsx@@ -0,0 +1,154 @@+import { Await, Outlet, useLoaderData, useParams } from "@remix-run/react";+import { ResizablePanels } from "~/components/Layout";++import { requirePermissions } from "@carbon/auth/auth.server";+import { useRouteData } from "@carbon/remix";+import type { LoaderFunctionArgs } from "@vercel/remix";+import { defer } from "@vercel/remix";+import { Suspense } from "react";+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 defer({ 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 {+ jobMaterials,++ methodMaterials,+ purchaseOrderLines,+ receiptLines,++ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes,+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials,+ },+ {+ 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={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.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.details.tsxdeleted file mode 100644index 2c3811a9b6..0000000000--- a/apps/erp/app/routes/x+/part+/$itemId.details.tsx+++ /dev/null@@ -1,257 +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 {- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- ScrollArea,- Spinner,- VStack,-} from "@carbon/react";-import { Await, useLoaderData, useParams } from "@remix-run/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";-import { defer, redirect } from "@vercel/remix";-import { Suspense } from "react";-import { CadModel } from "~/components";-import { usePermissions, useRouteData } from "~/hooks";-import type { ItemFile, PartSummary } from "~/modules/items";-import { getPartUsedIn, partValidator, upsertPart } from "~/modules/items";-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";--import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";-import { 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");-- return defer({ usedIn: getPartUsedIn(client, itemId, companyId) });-}--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 { usedIn } = useLoaderData<typeof loader>();-- 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 (- <div className="flex flex-grow overflow-hidden">- <ResizablePanelGroup direction="horizontal">- <ResizablePanel- order={1}- minSize={10}- defaultSize={20}- className="bg-card"- >- <ScrollArea className="h-[calc(100dvh-99px)]">- <div className="grid h-full overflow-hidden p-2">- <Suspense fallback={<UsedInSkeleton />}>- <Await resolve={usedIn}>- {(resolvedUsedIn) => {- const {- jobMaterials,- jobs,- methodMaterials,- purchaseOrderLines,- receiptLines,- quoteLines,- quoteMaterials,- salesOrderLines,- shipmentLines,- supplierQuotes,- } = resolvedUsedIn;-- const tree: UsedInNode[] = [- {- key: "jobs",- name: "Jobs",- module: "production",- children: jobs.map((job) => ({- ...job,- methodType: "Make",- })),- },- {- key: "jobMaterials",- name: "Job Materials",- module: "production",- children: jobMaterials,- },- {- 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>- </div>- </ScrollArea>- </ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel order={2} minSize={40} defaultSize={60}>- <ScrollArea className="h-[calc(100dvh-99px)]">- <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"- />- </>- )}- </VStack>- </ScrollArea>- </ResizablePanel>- </ResizablePanelGroup>- </div>- );-}diff --git a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsx b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsxindex 137870b0fd..ef9bfa1204 100644--- a/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.manufacturing.$methodId.tsx@@ -1,10 +1,4 @@-import type { JSONContent } from "@carbon/react";-import {- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- ScrollArea,-} from "@carbon/react";+import { VStack, type JSONContent } from "@carbon/react";import {Outlet,@@ -18,6 +12,7 @@ import type { LoaderFunctionArgs } from "@vercel/remix";import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";+import { ResizablePanels } from "~/components/Layout";import type { FlatTreeItem } from "~/components/TreeView";import { flattenTree } from "~/components/TreeView";import type { Method } from "~/modules/items";@@ -31,6 +26,7 @@ import {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";@@ -145,16 +141,11 @@ export default function PartManufacturing() {if (!itemId) throw new Error("Could not find itemId");return (- <div className="flex flex-grow overflow-hidden">- <ResizablePanelGroup direction="horizontal">- <ResizablePanel- order={1}- minSize={10}- defaultSize={20}- className="bg-card"- >- <ScrollArea className="h-[calc(100dvh-99px)]">- <div className="grid h-full overflow-hidden p-2">+ <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"><BoMExploreritemType="Part"makeMethod={makeMethod}@@ -162,16 +153,16 @@ export default function PartManufacturing() {// @ts-ignoremethods={methods}/>+ </VStack>+ }+ content={+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">+ <Outlet /></div>- </ScrollArea>- </ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel order={2} minSize={40} defaultSize={60}>- <ScrollArea className="h-[calc(100dvh-99px)]">- <Outlet key={JSON.stringify(params)} />- </ScrollArea>- </ResizablePanel>- </ResizablePanelGroup>+ }+ properties={<PartProperties />}+ />+ </div></div>);}diff --git a/apps/erp/app/routes/x+/part+/$itemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.tsxindex a12b225753..e2a11f5601 100644--- a/apps/erp/app/routes/x+/part+/$itemId.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.tsx@@ -11,7 +11,7 @@ import {getPickMethods,getSupplierParts,} from "~/modules/items";-import { PartHeader, PartProperties } from "~/modules/items/ui/Parts";+import { PartHeader } from "~/modules/items/ui/Parts";import { getTagsList } from "~/modules/shared";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -62,12 +62,7 @@ export default function PartRoute() {return (<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full"><PartHeader />- <div className="flex h-[calc(100dvh-99px)] w-full">- <div className="flex h-full w-full overflow-y-auto scrollbar-hide">- <Outlet />- </div>- <PartProperties />- </div>+ <Outlet /></div>);}diff --git a/apps/erp/app/routes/x+/part+/$itemId.costing.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.costing.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.costing.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.costing.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsxnew file mode 100644index 0000000000..a05a5f962a--- /dev/null+++ b/apps/erp/app/routes/x+/part+/$itemId.view.details.tsx@@ -0,0 +1,118 @@+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 { Await, useParams } from "@remix-run/react";+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";+import { defer, redirect } from "@vercel/remix";+import { Suspense } from "react";+import { CadModel } from "~/components";+import { usePermissions, useRouteData } from "~/hooks";+import type { ItemFile, PartSummary } from "~/modules/items";+import { getPartUsedIn, partValidator, upsertPart } from "~/modules/items";+import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";++import { 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");++ return defer({ usedIn: getPartUsedIn(client, itemId, companyId) });+}++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"+ />+ </>+ )}+ </VStack>+ );+}diff --git a/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsxsimilarity index 97%rename from apps/erp/app/routes/x+/part+/$itemId.inventory.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsxindex ea67de6027..68cdf83f7f 100644--- a/apps/erp/app/routes/x+/part+/$itemId.inventory.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.view.inventory.tsx@@ -17,7 +17,6 @@ import {upsertPickMethod,} from "~/modules/items";import { PickMethodForm } from "~/modules/items/ui/Item";-import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";import { useItems } from "~/stores";@@ -187,7 +186,7 @@ export default function PartInventoryRoute() {unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.partRoot);- const { partInventory, itemShelfQuantities, quantities, itemId, locationId } =+ const { partInventory, itemShelfQuantities, quantities, itemId } =useLoaderData<typeof loader>();const partData = useRouteData<{@@ -222,7 +221,6 @@ export default function PartInventoryRoute() {quantities={quantities}shelves={sharedPartsData?.shelves ?? []}/>- <ItemPlanningChart itemId={itemId} locationId={locationId} /></VStack>);}diff --git a/apps/erp/app/routes/x+/part+/$itemId.planning.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.planning.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.planning.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.planning.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.purchasing.new.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.purchasing.new.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.purchasing.new.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.purchasing.tsxsimilarity index 87%rename from apps/erp/app/routes/x+/part+/$itemId.purchasing.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.purchasing.tsxindex a6a6c92290..f2d542a3d0 100644--- a/apps/erp/app/routes/x+/part+/$itemId.purchasing.tsx+++ b/apps/erp/app/routes/x+/part+/$itemId.view.purchasing.tsx@@ -12,11 +12,13 @@ import { getBatchProperties } from "~/modules/inventory";import BatchPropertiesConfig from "~/modules/inventory/ui/Batches/BatchPropertiesConfig";import type { SupplierPart } from "~/modules/items";import {+ getItemCostHistory,getItemReplenishment,itemPurchasingValidator,upsertItemPurchasing,} from "~/modules/items";import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";+import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";import { path } from "~/utils/path";export async function loader({ request, params }: LoaderFunctionArgs) {@@ -27,8 +29,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const { itemId } = params;if (!itemId) throw new Error("Could not find itemId");- const [partPurchasingResult] = await Promise.all([+ const [partPurchasingResult, itemCostHistory] = await Promise.all([getItemReplenishment(client, itemId, companyId),+ getItemCostHistory(client, itemId, companyId),]);if (partPurchasingResult.error) {@@ -44,6 +47,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {return defer({partPurchasing: partPurchasingResult.data,batchProperties: getBatchProperties(client, [itemId], companyId),+ itemCostHistory: itemCostHistory.data ?? [],});}@@ -87,7 +91,8 @@ export async function action({ request, params }: ActionFunctionArgs) {}export default function PartPurchasingRoute() {- const { partPurchasing, batchProperties } = useLoaderData<typeof loader>();+ const { partPurchasing, batchProperties, itemCostHistory } =+ useLoaderData<typeof loader>();const { itemId } = useParams();if (!itemId) throw new Error("Could not find itemId");@@ -97,7 +102,7 @@ export default function PartPurchasingRoute() {const supplierParts = routeData?.supplierParts ?? [];const partData = useRouteData<{- partSummary: { itemTrackingType?: string };+ partSummary: { itemTrackingType?: string; readableIdWithRevision?: string };}>(path.to.part(itemId));const initialValues = {@@ -135,6 +140,10 @@ export default function PartPurchasingRoute() {</Await></Suspense>)}+ <ItemCostHistoryChart+ readableId={partData?.partSummary?.readableIdWithRevision ?? ""}+ itemCostHistory={itemCostHistory}+ /></VStack>);}diff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.$customerPartToItemId.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.$customerPartToItemId.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.delete.$customerPartToItemId.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.delete.$customerPartToItemId.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.delete.$customerPartToItemId.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.delete.$customerPartToItemId.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.new.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.sales.customer-parts.new.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.sales.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.sales.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/part+/$itemId.sales.tsxrename to apps/erp/app/routes/x+/part+/$itemId.view.sales.tsxdiff --git a/apps/erp/app/routes/x+/part+/$itemId.view.tsx b/apps/erp/app/routes/x+/part+/$itemId.view.tsxnew file mode 100644index 0000000000..a4f5099cc9--- /dev/null+++ b/apps/erp/app/routes/x+/part+/$itemId.view.tsx@@ -0,0 +1,165 @@+import { Await, Outlet, useLoaderData, useParams } from "@remix-run/react";+import { ResizablePanels } from "~/components/Layout";+import { PartProperties } from "~/modules/items/ui/Parts";++import { requirePermissions } from "@carbon/auth/auth.server";+import { useRouteData } from "@carbon/remix";+import type { LoaderFunctionArgs } from "@vercel/remix";+import { defer } from "@vercel/remix";+import { Suspense } from "react";+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 { 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 defer({ 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 {+ jobMaterials,+ jobs,+ methodMaterials,+ purchaseOrderLines,+ receiptLines,+ quoteLines,+ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes,+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "jobs",+ name: "Jobs",+ module: "production",+ children: jobs.map((job) => ({+ ...job,+ methodType: "Make",+ })),+ },+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials,+ },+ {+ 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+/tool+/$itemId.details.tsx b/apps/erp/app/routes/x+/tool+/$itemId.details.tsxdeleted file mode 100644index faad4f4ee5..0000000000--- a/apps/erp/app/routes/x+/tool+/$itemId.details.tsx+++ /dev/null@@ -1,237 +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 {- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- ScrollArea,- Spinner,- VStack,-} from "@carbon/react";-import { Await, useLoaderData, useParams } from "@remix-run/react";-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";-import { defer, redirect } from "@vercel/remix";-import { Suspense } from "react";-import { usePermissions, useRouteData } from "~/hooks";-import type { ItemFile, ToolSummary } from "~/modules/items";-import { getPartUsedIn, toolValidator, upsertTool } from "~/modules/items";-import { ItemDocuments, ItemNotes } from "~/modules/items/ui/Item";-import type { UsedInNode } from "~/modules/items/ui/Item/UsedIn";-import { UsedInSkeleton, UsedInTree } from "~/modules/items/ui/Item/UsedIn";-import { 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");-- return defer({ usedIn: getPartUsedIn(client, itemId, companyId) });-}--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 tool"))- );- }-- throw redirect(- path.to.tool(itemId),- await flash(request, success("Updated tool"))- );-}--export default function ToolDetailsRoute() {- const { usedIn } = useLoaderData<typeof loader>();-- 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 (- <div className="flex flex-grow overflow-hidden">- <ResizablePanelGroup direction="horizontal">- <ResizablePanel- order={1}- minSize={10}- defaultSize={20}- className="bg-card"- >- <ScrollArea className="h-[calc(100dvh-99px)]">- <div className="grid h-full overflow-hidden p-2">- <Suspense fallback={<UsedInSkeleton />}>- <Await resolve={usedIn}>- {(resolvedUsedIn) => {- const {- jobMaterials,- jobs,- methodMaterials,- purchaseOrderLines,- receiptLines,- quoteMaterials,- salesOrderLines,- shipmentLines,- supplierQuotes,- } = resolvedUsedIn;-- const tree: UsedInNode[] = [- {- key: "jobs",- name: "Jobs",- module: "production",- children: jobs.map((job) => ({- ...job,- methodType: "Make",- })),- },- {- key: "jobMaterials",- name: "Job Materials",- module: "production",- children: jobMaterials,- },- {- 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={toolData.toolSummary?.revisions}- itemReadableId={toolData.toolSummary?.readableId ?? ""}- itemReadableIdWithRevision={- toolData.toolSummary?.readableIdWithRevision ?? ""- }- />- );- }}- </Await>- </Suspense>- </div>- </ScrollArea>- </ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel order={2} minSize={40} defaultSize={60}>- <ScrollArea className="h-[calc(100dvh-99px)]">- <VStack spacing={2} className="p-2">- <ItemNotes- id={toolData.toolSummary?.id ?? null}- title={toolData.toolSummary?.readableIdWithRevision ?? ""}- subTitle={toolData.toolSummary?.name ?? ""}- 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}>- {(files) => (- <ItemDocuments- files={files ?? []}- itemId={itemId}- type="Tool"- />- )}- </Await>- </Suspense>- )}- </VStack>- </ScrollArea>- </ResizablePanel>- </ResizablePanelGroup>- </div>- );-}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsxindex 6153dc2942..f5c34deb7e 100644--- a/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsx+++ b/apps/erp/app/routes/x+/tool+/$itemId.manufacturing.$methodId.tsx@@ -1,10 +1,5 @@import type { JSONContent } from "@carbon/react";-import {- ResizableHandle,- ResizablePanel,- ResizablePanelGroup,- ScrollArea,-} from "@carbon/react";+import { VStack } from "@carbon/react";import {Outlet,@@ -18,6 +13,7 @@ import type { LoaderFunctionArgs } from "@vercel/remix";import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";+import { ResizablePanels } from "~/components/Layout/Panels";import type { FlatTreeItem } from "~/components/TreeView";import { flattenTree } from "~/components/TreeView";import type { Method } from "~/modules/items";@@ -29,6 +25,7 @@ import {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";@@ -127,7 +124,6 @@ export async function loader({ request, params }: LoaderFunctionArgs) {// : [],});}-export default function ToolManufacturing() {const { makeMethod, methods } = useLoaderData<typeof loader>();@@ -136,32 +132,28 @@ export default function ToolManufacturing() {if (!itemId) throw new Error("Could not find itemId");return (- <div className="flex flex-grow overflow-hidden">- <ResizablePanelGroup direction="horizontal">- <ResizablePanel- order={1}- minSize={10}- defaultSize={20}- className="bg-card"- >- <ScrollArea className="h-[calc(100dvh-99px)]">- <div className="grid h-full overflow-hidden p-2">+ <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"><BoMExploreritemType="Tool"makeMethod={makeMethod}+ makeMethodStatus={makeMethod.status}// @ts-ignoremethods={methods}/>+ </VStack>+ }+ content={+ <div className="h-[calc(100dvh-99px)] overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent w-full">+ <Outlet /></div>- </ScrollArea>- </ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel order={2} minSize={40} defaultSize={60}>- <ScrollArea className="h-[calc(100dvh-99px)]">- <Outlet key={JSON.stringify(params)} />- </ScrollArea>- </ResizablePanel>- </ResizablePanelGroup>+ }+ properties={<ToolProperties />}+ />+ </div></div>);}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.tsx b/apps/erp/app/routes/x+/tool+/$itemId.tsxindex e6a0e6cf76..5d490e0152 100644--- a/apps/erp/app/routes/x+/tool+/$itemId.tsx+++ b/apps/erp/app/routes/x+/tool+/$itemId.tsx@@ -11,7 +11,7 @@ import {getSupplierParts,getTool,} from "~/modules/items";-import { ToolHeader, ToolProperties } from "~/modules/items/ui/Tools";+import { ToolHeader } from "~/modules/items/ui/Tools";import { getTagsList } from "~/modules/shared";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -62,12 +62,7 @@ export default function ToolRoute() {return (<div className="flex flex-col h-[calc(100dvh-49px)] overflow-hidden w-full"><ToolHeader />- <div className="flex h-[calc(100dvh-99px)] w-full">- <div className="flex h-full w-full overflow-y-auto scrollbar-hide">- <Outlet />- </div>- <ToolProperties />- </div>+ <Outlet /></div>);}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.costing.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.costing.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/tool+/$itemId.costing.tsxrename to apps/erp/app/routes/x+/tool+/$itemId.view.costing.tsxdiff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsxnew file mode 100644index 0000000000..85f19a09b5--- /dev/null+++ b/apps/erp/app/routes/x+/tool+/$itemId.view.details.tsx@@ -0,0 +1,106 @@+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 { Await, useParams } from "@remix-run/react";+import type { ActionFunctionArgs } from "@vercel/remix";+import { redirect } from "@vercel/remix";+import { Suspense } from "react";+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 } 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"+ />+ </>+ )}+ </VStack>+ );+}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsxsimilarity index 97%rename from apps/erp/app/routes/x+/tool+/$itemId.inventory.tsxrename to apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsxindex a5cd37a489..ef50282d0e 100644--- a/apps/erp/app/routes/x+/tool+/$itemId.inventory.tsx+++ b/apps/erp/app/routes/x+/tool+/$itemId.view.inventory.tsx@@ -17,7 +17,6 @@ import {upsertPickMethod,} from "~/modules/items";import { PickMethodForm } from "~/modules/items/ui/Item";-import { ItemPlanningChart } from "~/modules/items/ui/Item/ItemPlanningChart";import { getLocationsList } from "~/modules/resources";import { getUserDefaults } from "~/modules/users/users.server";import { useItems } from "~/stores/items";@@ -187,7 +186,7 @@ export default function ToolInventoryRoute() {unitOfMeasures: UnitOfMeasureListItem[];}>(path.to.toolRoot);- const { toolInventory, itemShelfQuantities, quantities, itemId, locationId } =+ const { toolInventory, itemShelfQuantities, quantities, itemId } =useLoaderData<typeof loader>();const toolData = useRouteData<{@@ -222,10 +221,6 @@ export default function ToolInventoryRoute() {quantities={quantities}shelves={sharedToolsData?.shelves ?? []}/>- <ItemPlanningChart- itemId={toolInventory.itemId}- locationId={locationId}- /></VStack>);}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.planning.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.planning.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/tool+/$itemId.planning.tsxrename to apps/erp/app/routes/x+/tool+/$itemId.view.planning.tsxdiff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.new.tsxsimilarity index 100%rename from apps/erp/app/routes/x+/tool+/$itemId.purchasing.new.tsxrename to apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.new.tsxdiff --git a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.tsxsimilarity index 87%rename from apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsxrename to apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.tsxindex 87f8008714..052eed5f7f 100644--- a/apps/erp/app/routes/x+/tool+/$itemId.purchasing.tsx+++ b/apps/erp/app/routes/x+/tool+/$itemId.view.purchasing.tsx@@ -12,11 +12,13 @@ import { getBatchProperties } from "~/modules/inventory";import BatchPropertiesConfig from "~/modules/inventory/ui/Batches/BatchPropertiesConfig";import type { SupplierPart } from "~/modules/items";import {+ getItemCostHistory,getItemReplenishment,itemPurchasingValidator,upsertItemPurchasing,} from "~/modules/items";import { ItemPurchasingForm, SupplierParts } from "~/modules/items/ui/Item";+import { ItemCostHistoryChart } from "~/modules/items/ui/Item/ItemCostHistoryChart";import { path } from "~/utils/path";export async function loader({ request, params }: LoaderFunctionArgs) {@@ -27,8 +29,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) {const { itemId } = params;if (!itemId) throw new Error("Could not find itemId");- const [toolPurchasingResult] = await Promise.all([+ const [toolPurchasingResult, itemCostHistory] = await Promise.all([getItemReplenishment(client, itemId, companyId),+ getItemCostHistory(client, itemId, companyId),]);if (toolPurchasingResult.error) {@@ -44,6 +47,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {return defer({toolPurchasing: toolPurchasingResult.data,batchProperties: getBatchProperties(client, [itemId], companyId),+ itemCostHistory: itemCostHistory.data ?? [],});}@@ -87,7 +91,8 @@ export async function action({ request, params }: ActionFunctionArgs) {}export default function ToolPurchasingRoute() {- const { toolPurchasing, batchProperties } = useLoaderData<typeof loader>();+ const { toolPurchasing, batchProperties, itemCostHistory } =+ useLoaderData<typeof loader>();const { itemId } = useParams();if (!itemId) throw new Error("Could not find itemId");@@ -97,7 +102,7 @@ export default function ToolPurchasingRoute() {const supplierParts = routeData?.supplierParts ?? [];const toolData = useRouteData<{- toolSummary: { itemTrackingType?: string };+ toolSummary: { itemTrackingType?: string; readableIdWithRevision?: string };}>(path.to.tool(itemId));const initialValues = {@@ -135,6 +140,10 @@ export default function ToolPurchasingRoute() {</Await></Suspense>)}+ <ItemCostHistoryChart+ readableId={toolData?.toolSummary?.readableIdWithRevision ?? ""}+ itemCostHistory={itemCostHistory}+ /></VStack>);}diff --git a/apps/erp/app/routes/x+/tool+/$itemId.view.tsx b/apps/erp/app/routes/x+/tool+/$itemId.view.tsxnew file mode 100644index 0000000000..39d25f26e0--- /dev/null+++ b/apps/erp/app/routes/x+/tool+/$itemId.view.tsx@@ -0,0 +1,165 @@+import { Await, Outlet, useLoaderData, useParams } from "@remix-run/react";+import { ResizablePanels } from "~/components/Layout";++import { requirePermissions } from "@carbon/auth/auth.server";+import { useRouteData } from "@carbon/remix";+import type { LoaderFunctionArgs } from "@vercel/remix";+import { defer } from "@vercel/remix";+import { Suspense } from "react";+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 defer({ 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 {+ jobMaterials,+ jobs,+ methodMaterials,+ purchaseOrderLines,+ receiptLines,+ quoteLines,+ quoteMaterials,+ salesOrderLines,+ shipmentLines,+ supplierQuotes,+ } = resolvedUsedIn;++ const tree: UsedInNode[] = [+ {+ key: "jobs",+ name: "Jobs",+ module: "production",+ children: jobs.map((job) => ({+ ...job,+ methodType: "Make",+ })),+ },+ {+ key: "jobMaterials",+ name: "Job Materials",+ module: "production",+ children: jobMaterials,+ },+ {+ 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.tsindex 1295e8ecd3..82c46b9f5b 100644--- a/apps/erp/app/utils/path.ts+++ b/apps/erp/app/utils/path.ts@@ -348,24 +348,28 @@ export const path = {consumable: (id: string) => generatePath(`${x}/consumable/${id}`),consumables: `${x}/items/consumables`,consumableCosting: (id: string) =>- generatePath(`${x}/consumable/${id}/costing`),+ generatePath(`${x}/consumable/${id}/view/costing`),consumableDetails: (id: string) =>- generatePath(`${x}/consumable/${id}/details`),+ generatePath(`${x}/consumable/${id}/view/details`),consumableInventory: (id: string) =>- generatePath(`${x}/consumable/${id}/inventory`),+ generatePath(`${x}/consumable/${id}/view/inventory`),consumableInventoryLocation: (id: string, locationId: string) =>- generatePath(`${x}/consumable/${id}/inventory?location=${locationId}`),+ generatePath(+ `${x}/consumable/${id}/view/inventory?location=${locationId}`+ ),consumablePlanning: (id: string) =>- generatePath(`${x}/consumable/${id}/planning`),+ generatePath(`${x}/consumable/${id}/view/planning`),consumablePlanningLocation: (id: string, locationId: string) =>- generatePath(`${x}/consumable/${id}/planning?location=${locationId}`),+ generatePath(+ `${x}/consumable/${id}/view/planning?location=${locationId}`+ ),consumablePurchasing: (id: string) =>- generatePath(`${x}/consumable/${id}/purchasing`),+ generatePath(`${x}/consumable/${id}/view/purchasing`),consumableRoot: `${x}/consumable`,consumableSupplier: (itemId: string, id: string) =>- generatePath(`${x}/consumable/${itemId}/suppliers/${id}`),+ generatePath(`${x}/consumable/${itemId}/view/suppliers/${id}`),consumableSuppliers: (id: string) =>- generatePath(`${x}/consumable/${id}/suppliers`),+ generatePath(`${x}/consumable/${id}/view/suppliers`),convertQuoteToOrder: (id: string) =>generatePath(`${x}/quote/${id}/convert`),convertSupplierQuoteToOrder: (id: string) =>@@ -391,7 +395,7 @@ export const path = {generatePath(`${x}/customer/${id}/locations`),customerPart: (id: string, customerPartToItemId: string) =>generatePath(- `${x}/part/${id}/sales/customer-parts/${customerPartToItemId}`+ `${x}/part/${id}/view/sales/customer-parts/${customerPartToItemId}`),customerPayment: (id: string) =>generatePath(`${x}/customer/${id}/payments`),@@ -450,7 +454,7 @@ export const path = {generatePath(`${x}/customer/${customerId}/locations/delete/${id}`),deleteCustomerPart: (id: string, customerPartToItemId: string) =>generatePath(- `${x}/part/${id}/sales/customer-parts/delete/${customerPartToItemId}`+ `${x}/part/${id}/view/sales/customer-parts/delete/${customerPartToItemId}`),deleteCustomerStatus: (id: string) =>generatePath(`${x}/sales/customer-statuses/delete/${id}`),@@ -701,28 +705,28 @@ export const path = {makeMethodSave: `${x}/items/methods/save`,material: (id: string) => generatePath(`${x}/material/${id}`),materialCosting: (id: string) =>- generatePath(`${x}/material/${id}/costing`),+ generatePath(`${x}/material/${id}/view/costing`),materialDetails: (id: string) =>- generatePath(`${x}/material/${id}/details`),+ generatePath(`${x}/material/${id}/view/details`),materialForm: (id: string) => generatePath(`${x}/items/forms/${id}`),materialForms: `${x}/items/forms`,materialInventory: (id: string) =>- generatePath(`${x}/material/${id}/inventory`),+ generatePath(`${x}/material/${id}/view/inventory`),materialInventoryLocation: (id: string, locationId: string) =>- generatePath(`${x}/material/${id}/inventory?location=${locationId}`),+ generatePath(`${x}/material/${id}/view/inventory?location=${locationId}`),materialPlanning: (id: string) =>- generatePath(`${x}/material/${id}/planning`),+ generatePath(`${x}/material/${id}/view/planning`),materialPlanningLocation: (id: string, locationId: string) =>- generatePath(`${x}/material/${id}/planning?location=${locationId}`),+ generatePath(`${x}/material/${id}/view/planning?location=${locationId}`),materialPricing: (id: string) =>- generatePath(`${x}/material/${id}/pricing`),+ generatePath(`${x}/material/${id}/view/pricing`),materialPurchasing: (id: string) =>- generatePath(`${x}/material/${id}/purchasing`),+ generatePath(`${x}/material/${id}/view/purchasing`),materialRoot: `${x}/material`,materialSupplier: (itemId: string, id: string) =>- generatePath(`${x}/material/${itemId}/suppliers/${id}`),+ generatePath(`${x}/material/${itemId}/view/suppliers/${id}`),materialSuppliers: (id: string) =>- generatePath(`${x}/material/${id}/suppliers`),+ generatePath(`${x}/material/${id}/view/suppliers`),materials: `${x}/items/materials`,materialSubstance: (id: string) =>generatePath(`${x}/items/substances/${id}`),@@ -757,7 +761,7 @@ export const path = {newCompany: `${x}/settings/company/new`,newConsumable: `${x}/consumable/new`,newConsumableSupplier: (id: string) =>- generatePath(`${x}/consumable/${id}/purchasing/new`),+ generatePath(`${x}/consumable/${id}/view/purchasing/new`),newContractor: `${x}/resources/contractors/new`,newCurrency: `${x}/accounting/currencies/new`,newCustomer: `${x}/customer/new`,@@ -771,7 +775,7 @@ export const path = {newCustomField: (tableId: string) =>generatePath(`${x}/settings/custom-fields/${tableId}/new`),newCustomerPart: (id: string) =>- generatePath(`${x}/part/${id}/sales/customer-parts/new`),+ generatePath(`${x}/part/${id}/view/sales/customer-parts/new`),newDepartment: `${x}/people/departments/new`,newDocument: `${x}/documents/new`,newEmployee: `${x}/users/employees/new`,@@ -818,9 +822,9 @@ export const path = {newMaterialForm: `${x}/items/forms/new`,newMaterialSubstance: `${x}/items/substances/new`,newMaterialSupplier: (id: string) =>- generatePath(`${x}/material/${id}/purchasing/new`),+ generatePath(`${x}/material/${id}/view/purchasing/new`),newPartSupplier: (id: string) =>- generatePath(`${x}/part/${id}/purchasing/new`),+ generatePath(`${x}/part/${id}/view/purchasing/new`),newNoQuoteReason: `${x}/sales/no-quote-reasons/new`,newPartner: `${x}/resources/partners/new`,newPaymentTerm: `${x}/accounting/payment-terms/new`,@@ -878,7 +882,7 @@ export const path = {newTag: `${x}/settings/tags/new`,newTool: `${x}/tool/new`,newToolSupplier: (id: string) =>- generatePath(`${x}/tool/${id}/purchasing/new`),+ generatePath(`${x}/tool/${id}/view/purchasing/new`),newUom: `${x}/items/uom/new`,newWorkCenter: `${x}/resources/work-centers/new`,newWebhook: `${x}/settings/webhooks/new`,@@ -909,11 +913,12 @@ 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}/costing`),- partDetails: (id: string) => generatePath(`${x}/part/${id}/details`),- partInventory: (id: string) => generatePath(`${x}/part/${id}/inventory`),+ 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`),partInventoryLocation: (id: string, locationId: string) =>- generatePath(`${x}/part/${id}/inventory?location=${locationId}`),+ generatePath(`${x}/part/${id}/view/inventory?location=${locationId}`),partMethod: (id: string, methodId: string) =>generatePath(`${x}/part/${id}/manufacturing/${methodId}`),partMakeMethod: (id: string, methodId: string) =>@@ -928,13 +933,14 @@ export const path = {generatePath(`${x}/part/${itemId}/manufacturing/${methodId}/make/${makeMethodId}`),- partPlanning: (id: string) => generatePath(`${x}/part/${id}/planning`),+ partPlanning: (id: string) => generatePath(`${x}/part/${id}/view/planning`),partPlanningLocation: (id: string, locationId: string) =>- generatePath(`${x}/part/${id}/planning?location=${locationId}`),- partPricing: (id: string) => generatePath(`${x}/part/${id}/pricing`),- partPurchasing: (id: string) => generatePath(`${x}/part/${id}/purchasing`),+ 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`),partRoot: `${x}/part`,- partSales: (id: string) => generatePath(`${x}/part/${id}/sales`),+ partSales: (id: string) => generatePath(`${x}/part/${id}/view/sales`),partSupplier: (itemId: string, id: string) =>generatePath(`${x}/part/${itemId}/suppliers/${id}`),parts: `${x}/items/parts`,@@ -1210,11 +1216,12 @@ export const path = {theme: `${x}/account/theme`,timecards: `${x}/timecards`,tool: (id: string) => generatePath(`${x}/tool/${id}`),- toolCosting: (id: string) => generatePath(`${x}/tool/${id}/costing`),- toolDetails: (id: string) => generatePath(`${x}/tool/${id}/details`),- toolInventory: (id: string) => generatePath(`${x}/tool/${id}/inventory`),+ 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`),toolInventoryLocation: (id: string, locationId: string) =>- generatePath(`${x}/tool/${id}/inventory?location=${locationId}`),+ generatePath(`${x}/tool/${id}/view/inventory?location=${locationId}`),toolMethod: (id: string, methodId: string) =>generatePath(`${x}/tool/${id}/manufacturing/${methodId}`),toolMakeMethod: (id: string, methodId: string) =>@@ -1229,15 +1236,17 @@ export const path = {generatePath(`${x}/tool/${itemId}/manufacturing/${methodId}/make/${makeMethodId}`),- toolPlanning: (id: string) => generatePath(`${x}/tool/${id}/planning`),+ toolPlanning: (id: string) => generatePath(`${x}/tool/${id}/view/planning`),toolPlanningLocation: (id: string, locationId: string) =>- generatePath(`${x}/tool/${id}/planning?location=${locationId}`),- toolPricing: (id: string) => generatePath(`${x}/tool/${id}/pricing`),- toolPurchasing: (id: string) => generatePath(`${x}/tool/${id}/purchasing`),+ 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`),toolRoot: `${x}/tool`,toolSupplier: (itemId: string, id: string) =>- generatePath(`${x}/tool/${itemId}/suppliers/${id}`),- toolSuppliers: (id: string) => generatePath(`${x}/tool/${id}/suppliers`),+ generatePath(`${x}/tool/${itemId}/view/suppliers/${id}`),+ toolSuppliers: (id: string) =>+ generatePath(`${x}/tool/${id}/view/suppliers`),tools: `${x}/items/tools`,traceability: `${x}/traceability`,traceabilityGraph: `${x}/traceability/graph`,diff --git a/packages/react/src/Table.tsx b/packages/react/src/Table.tsxindex b81859c11b..8f3f73ceb8 100644--- a/packages/react/src/Table.tsx+++ b/packages/react/src/Table.tsx@@ -11,15 +11,12 @@ const Table = forwardRef<<div className="w-full"><tableref={ref}- className={cn(- "w-full border-b border-border caption-bottom text-sm",- className- )}+ className={cn("w-full caption-bottom text-sm", className)}{...props}/></div>) : (- <div className="rounded-md border w-full overflow-hidden">+ <div className="rounded-md w-full overflow-hidden"><div className="relative w-full overflow-auto"><tableref={ref}