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
fix: bom explorer memory leak
Brad Barbin5a971b1c744f
diff --git a/apps/carbon/app/modules/accounting/accounting.models.ts b/apps/carbon/app/modules/accounting/accounting.models.tsindex f5440b0e6d..6f60cfa56d 100644--- a/apps/carbon/app/modules/accounting/accounting.models.ts+++ b/apps/carbon/app/modules/accounting/accounting.models.ts@@ -222,12 +222,7 @@ export const currencyValidator = withZod(id: zfd.text(z.string().optional()),name: z.string().min(1, { message: "Name is required" }),code: z.string().min(1, { message: "Code is required" }),- symbol: zfd.text(- z- .string()- .max(1, { message: "Symbol can only be one character" })- .optional()- ),+ symbol: z.string().min(1, { message: "Symbol is required" }),decimalPlaces: zfd.numeric(z.number().min(0).max(4)),exchangeRate: zfd.numeric(z.number().min(0, { message: "Rate is required" })diff --git a/apps/carbon/app/modules/accounting/accounting.service.ts b/apps/carbon/app/modules/accounting/accounting.service.tsindex 243f44c203..722fa89a2f 100644--- a/apps/carbon/app/modules/accounting/accounting.service.ts+++ b/apps/carbon/app/modules/accounting/accounting.service.ts@@ -375,7 +375,7 @@ export async function getCurrencies(query = query.ilike("name", `%${args.name}%`);}- query = setGenericQueryFilters(query, args);+ query = setGenericQueryFilters(query, args, "isBaseCurrency", false);return query;}diff --git a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsxindex c65b44d2f7..f662fd8e41 100644--- a/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotation/QuotationExplorer.tsx@@ -1,7 +1,8 @@import { Button, cn, HStack, IconButton } from "@carbon/react";import type { Params } from "@remix-run/react";import { Link, useLocation, useParams } from "@remix-run/react";-import { useState } from "react";+import { arrayToTree } from "performant-array-to-tree";+import { useMemo, useState } from "react";import { AiOutlinePartition } from "react-icons/ai";import { HiOutlineCube } from "react-icons/hi";import { IoMdAdd } from "react-icons/io";@@ -9,64 +10,59 @@ import { LuClock } from "react-icons/lu";import { RxChevronDown } from "react-icons/rx";import type { BillOfMaterialNode } from "~/modules/shared";import { path } from "~/utils/path";-import { useQuotationMenu } from "./useQuotation";+import type { QuotationMaterial } from "../..";+import { useQuotation } from "./useQuotation";const QuotationExplorerItem = (node: Omit<BillOfMaterialNode, "children"> & {params: Params<string>;pathname: string;+ onClick: () => void;}) => {- const { type, id, parentId, label, meta, params, pathname } = node;+ const { type, id, parentId, label, meta, params, pathname, onClick } = node;let isActive = false;switch (type) {- case "assemblies":- return (- <Button- variant="ghost"- className="w-full justify-between text-muted-foreground"- asChild- >- <Link- to={path.to.newQuoteAssembly(- params.id!,- meta.quoteLineId,- parentId- )}- >- <span>{label}</span>- <IoMdAdd />- </Link>- </Button>- );- case "materials":+ case "assembly":+ isActive =+ pathname ===+ path.to.quoteAssembly(params.id!, meta.quoteLineId, meta.id);return (<Button- variant="ghost"- className="w-full justify-between text-muted-foreground"+ leftIcon={<AiOutlinePartition />}+ variant={isActive ? "primary" : "ghost"}+ className="flex-1 justify-start"asChild><Link- to={path.to.newQuoteMaterial(params.id!, meta.quoteLineId, meta.id)}+ to={path.to.quoteAssembly(params.id!, meta.quoteLineId, meta.id)}+ prefetch="intent"+ onClick={onClick}>- <span>{label}</span>- <IoMdAdd />+ {label}</Link></Button>);- case "operations":+ case "assemblies":+ isActive =+ pathname ===+ path.to.newQuoteAssembly(meta.quoteId, meta.quoteLineId, parentId);return (<Button- variant="ghost"- className="w-full justify-between text-muted-foreground"+ variant={isActive ? "primary" : "ghost"}+ className={cn(+ "w-full justify-between",+ !isActive && "text-muted-foreground"+ )}asChild><Link- to={path.to.newQuoteOperation(- params.id!,+ to={path.to.newQuoteAssembly(+ meta.quoteId,meta.quoteLineId,parentId)}+ onClick={onClick}><span>{label}</span><IoMdAdd />@@ -82,9 +78,17 @@ const QuotationExplorerItem = (className="flex-1 justify-between"asChild>- <Link to={path.to.quoteLine(params.id!, id)} prefetch="intent">- <span className="flex justify-start">- <AiOutlinePartition className="w-4 h-4 mr-2" />+ <Link+ to={path.to.quoteLine(params.id!, id)}+ prefetch="intent"+ onClick={onClick}+ >+ <span className="flex items-center justify-start">+ {meta.replenishmentSystem === "Buy" ? (+ <HiOutlineCube className="w-4 h-4 mr-2" />+ ) : (+ <AiOutlinePartition className="w-4 h-4 mr-2" />+ )}{label}</span><span@@ -98,55 +102,82 @@ const QuotationExplorerItem = (</Link></Button>);- case "assembly":- isActive =- pathname ===- path.to.quoteAssembly(params.id!, meta.quoteLineId, meta.id);++ case "material":return (<Button- leftIcon={<AiOutlinePartition />}- variant={isActive ? "primary" : "ghost"}+ leftIcon={<HiOutlineCube />}+ variant="ghost"className="flex-1 justify-start"asChild><Link- to={path.to.quoteAssembly(params.id!, meta.quoteLineId, meta.id)}- prefetch="intent"+ to={path.to.quoteOperation(params.id!, meta.quoteLineId, parentId!)}>{label}</Link></Button>);- case "operation":- isActive = [- path.to.quoteOperation(params.id!, meta.quoteLineId, meta.id),- path.to.newQuoteMaterial(params.id!, meta.quoteLineId, meta.id),- ].includes(pathname);++ case "materials":+ return (+ <Button+ variant="ghost"+ className="w-full justify-between text-muted-foreground"+ asChild+ >+ <Link+ to={path.to.newQuoteMaterial(params.id!, meta.quoteLineId, meta.id)}+ onClick={onClick}+ >+ <span>{label}</span>+ <IoMdAdd />+ </Link>+ </Button>+ );+ case "operations":+ isActive =+ pathname ===+ path.to.newQuoteOperation(meta.quoteId, meta.quoteLineId, parentId);return (<Button- leftIcon={<LuClock />}variant={isActive ? "primary" : "ghost"}- className="flex-1 justify-start"+ className={cn(+ "w-full justify-between",+ !isActive && "text-muted-foreground"+ )}asChild><Link- to={path.to.quoteOperation(params.id!, meta.quoteLineId, meta.id)}- prefetch="intent"+ to={path.to.newQuoteOperation(+ meta.quoteId,+ meta.quoteLineId,+ parentId+ )}+ onClick={onClick}>- {label}+ <span>{label}</span>+ <IoMdAdd /></Link></Button>);- case "material":++ case "operation":+ isActive = [+ path.to.quoteOperation(params.id!, meta.quoteLineId, meta.id),+ path.to.newQuoteMaterial(params.id!, meta.quoteLineId, meta.id),+ ].includes(pathname);return (<Button- leftIcon={<HiOutlineCube />}- variant="ghost"+ leftIcon={<LuClock />}+ variant={isActive ? "primary" : "ghost"}className="flex-1 justify-start"asChild><Link- to={path.to.quoteOperation(params.id!, meta.quoteLineId, parentId!)}+ to={path.to.quoteOperation(params.id!, meta.quoteLineId, meta.id)}+ prefetch="intent"+ onClick={onClick}>{label}</Link>@@ -160,7 +191,11 @@ const QuotationExplorerItem = (className="flex-1 justify-start"asChild>- <Link to={path.to.quote(params.id!)} prefetch="intent">+ <Link+ to={path.to.quote(params.id!)}+ prefetch="intent"+ onClick={onClick}+ >{label}</Link></Button>@@ -173,17 +208,202 @@ const QuotationExplorerItem = (};const QuotationExplorer = () => {- const { pathname } = useLocation();+ const { pathname, search } = useLocation();+const params = useParams();if (!params.id) throw new Error("id not found");- const menu = useQuotationMenu() as BillOfMaterialNode[];- console.log({ menu });+ const [quote] = useQuotation();+ console.log({ quote });++ const tree = useMemo(() => {+ if (!quote.quote) return [];++ let materialsByOperationId = quote.materials?.reduce<+ Record<string, QuotationMaterial[]>+ >((acc, material) => {+ if (!acc[material.quoteOperationId]) {+ acc[material.quoteOperationId] = [];+ }+ acc[material.quoteOperationId].push(material);+ return acc;+ }, {});++ let operationsByAssemblyId = quote.operations?.reduce<+ Record<string, BillOfMaterialNode[]>+ >((acc, operation) => {+ if (!operation?.quoteAssemblyId) return acc;+ if (!acc[operation.quoteAssemblyId]) {+ acc[operation.quoteAssemblyId] = [];+ }+ acc[operation.quoteAssemblyId].push({+ id: operation.id,+ parentId: operation.quoteAssemblyId ?? undefined,+ label: operation.description ?? "Operation",+ type: "operation",+ meta: operation,+ children: [+ {+ id: operation.id,+ label: "Materials",+ type: "materials",+ meta: operation,+ children: materialsByOperationId[operation.id]?.map((material) => ({+ id: material.id,+ parentId: operation.id,+ label: material.description,+ type: "material",+ meta: material,+ })),+ },+ ],+ });+ return acc;+ }, {});++ const assembliesByLineId = quote.assemblies?.reduce<+ Record<string, BillOfMaterialNode[]>+ >((acc, assembly) => {+ if (!acc[assembly.quoteLineId]) {+ acc[assembly.quoteLineId] = [];+ }+ acc[assembly.quoteLineId].push({+ id: assembly.id,+ parentId: assembly.parentAssemblyId ?? undefined,+ label: assembly.description ?? assembly.partId,+ type: "assembly",+ meta: assembly,+ });+ return acc;+ }, {});++ const operationsByLineId = quote.operations?.reduce<+ Record<string, BillOfMaterialNode[]>+ >((acc, operation) => {+ if (!acc[operation.quoteLineId]) {+ acc[operation.quoteLineId] = [];+ }+ acc[operation.quoteLineId].push({+ id: operation.id,+ parentId: operation.quoteAssemblyId ?? undefined,+ label: operation.description ?? "Operation",+ type: "operation",+ meta: operation,+ children: [+ {+ id: operation.id,+ label: "Materials",+ type: "materials",+ meta: operation,+ children: materialsByOperationId[operation.id]?.map((material) => ({+ id: material.id,+ parentId: operation.id,+ label: material.description,+ type: "material",+ meta: material,+ })),+ },+ ],+ });+ return acc;+ }, {});++ let tree: BillOfMaterialNode[] = [+ {+ id: quote.quote.id!,+ label: quote.quote.quoteId!,+ type: "parent",+ children: quote.lines?.map<BillOfMaterialNode>((line) => ({+ id: line.id,+ label: line.description,+ type: "line",+ meta: line,+ children:+ line.replenishmentSystem === "Make"+ ? [+ {+ id: `${line.id}-assemblies`,+ label: "Assemblies",+ type: "assemblies",+ children: assembliesByLineId[line.id]+ ? [+ ...(arrayToTree([...assembliesByLineId[line.id]], {+ id: "id",+ dataField: null,+ }) as BillOfMaterialNode[]),+ ]+ : [],+ meta: {+ quoteId: line.quoteId,+ quoteLineId: line.id,+ },+ },+ {+ id: `${line.id}-operations`,+ label: "Operations",+ type: "operations",+ children: operationsByLineId[line.id]+ ? [...operationsByLineId[line.id]]?.filter(+ (operation) => operation.parentId === undefined+ )+ : ([] as BillOfMaterialNode[]),+ meta: {+ quoteId: line.quoteId,+ quoteLineId: line.id,+ },+ },+ ]+ : undefined,+ })),+ },+ ];++ traverseTree(tree, (node) => {+ if (node.type === "assembly") {+ let currentChildren = node.children ? [...node.children] : [];+ node.children = [+ {+ id: `${node.id}-assemblies`,+ parentId: node.id,+ label: "Assemblies",+ type: "assemblies",+ children: currentChildren,+ meta: {+ quoteId: node.meta.quoteId,+ quoteLineId: node.meta.quoteLineId,+ },+ },+ {+ id: `${node.id}-operations`,+ parentId: node.id,+ label: "Operations",+ type: "operations",+ children: operationsByAssemblyId[node.id]+ ? [...operationsByAssemblyId[node.id]]+ : [],+ meta: {+ quoteId: node.meta.quoteId,+ quoteLineId: node.meta.quoteLineId,+ },+ },+ ];+ }+ });++ return tree;+ }, [quote]);const [expandedNodes, setExpandedNodes] = useState<Record<string, boolean>>({[params.id]: true,});+ const openNode = (id: string) => {+ setExpandedNodes((prev) => ({+ ...prev,+ [id]: true,+ }));+ };+const toggleNode = (id: string) => {setExpandedNodes((prev) => ({...prev,@@ -192,10 +412,10 @@ const QuotationExplorer = () => {};const renderBillOfMaterial = (- menu: BillOfMaterialNode[],+ tree: BillOfMaterialNode[],level: number = 0) => {- return menu.map((node) => {+ return tree.map((node) => {return (<div className="w-full" role="group" key={`${node.id}:${node.type}`}><HStack@@ -227,8 +447,9 @@ const QuotationExplorer = () => {label={node.label}parentId={node.parentId}params={params}- pathname={pathname}+ pathname={pathname + search}meta={node.meta}+ onClick={() => openNode(node.id)}/></HStack>{node.children &&@@ -241,9 +462,21 @@ const QuotationExplorer = () => {return (<div className="w-full h-full overflow-auto" role="tree">- {renderBillOfMaterial(menu)}+ {renderBillOfMaterial(tree)}</div>);};export default QuotationExplorer;++function traverseTree(+ tree: BillOfMaterialNode[],+ callback: (node: BillOfMaterialNode) => void+) {+ tree.forEach((node) => {+ callback(node);+ if (node.children) {+ traverseTree(node.children, callback);+ }+ });+}diff --git a/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsx b/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsxindex 16e140c284..825eb38afc 100644--- a/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotation/useQuotation.tsx@@ -1,6 +1,5 @@import { useStore as useValue } from "@nanostores/react";import { atom, computed } from "nanostores";-import { arrayToTree } from "performant-array-to-tree";import { useNanoStore } from "~/hooks";import type {Quotation,@@ -9,7 +8,6 @@ import type {QuotationMaterial,QuotationOperation,} from "~/modules/sales";-import type { BillOfMaterialNode } from "~/modules/shared";type Quote = {quote?: Quotation;@@ -37,12 +35,7 @@ const $quotationStore = atom<Quote>({materials: [],});-const defaultItems = {- assemblies: [],- operations: [],-};--const defaultEffects = {+const defaultEffects: LinePriceEffects = {materialCost: [],laborCost: [],overheadCost: [],@@ -53,31 +46,29 @@ const defaultEffects = {const $quotationLinePriceEffects = computed($quotationStore, (store: Quote) => {// vroom vroomif (!store.quote) return [];- let linePriceEffects: Record<string, LinePriceEffects> = {};+ let linePriceEffects: Record<string, LinePriceEffects> = Object.create(null);- let itemsByLineId: Record<- string,- {- assemblies: QuotationAssembly[];- operations: QuotationOperation[];+ const assembliesByLineId = store.assemblies?.reduce<+ Record<string, QuotationAssembly[]>+ >((acc, assembly) => {+ if (!acc[assembly.quoteLineId]) {+ acc[assembly.quoteLineId] = [];}- > = {};-- store.assemblies.forEach((assembly) => {- if (!itemsByLineId[assembly.quoteLineId]) {- itemsByLineId[assembly.quoteLineId] = defaultItems;- }- itemsByLineId[assembly.quoteLineId].assemblies.push(assembly);- });+ acc[assembly.quoteLineId].push(assembly);+ return acc;+ }, {});- store.operations.forEach((operation) => {- if (!itemsByLineId[operation.quoteLineId]) {- itemsByLineId[operation.quoteLineId] = defaultItems;+ const operationsByLineId = store.operations?.reduce<+ Record<string, QuotationOperation[]>+ >((acc, operation) => {+ if (!acc[operation.quoteLineId]) {+ acc[operation.quoteLineId] = [];}- itemsByLineId[operation.quoteLineId].operations.push(operation);- });+ acc[operation.quoteLineId].push(operation);+ return acc;+ }, {});- let materialsByOperationId = store.materials.reduce<+ let materialsByOperationId = store.materials?.reduce<Record<string, QuotationMaterial[]>>((acc, material) => {if (!acc[material.quoteOperationId]) {@@ -87,10 +78,10 @@ const $quotationLinePriceEffects = computed($quotationStore, (store: Quote) => {return acc;}, {});- store.lines.forEach((line) => {+ store.lines?.forEach((line) => {linePriceEffects[line.id] = defaultEffects;- let assembliesById = itemsByLineId[line.id].assemblies.reduce<+ let assembliesById = assembliesByLineId[line.id]?.reduce<Record<string, QuotationAssembly>>((acc, assembly) => {acc[assembly.id] = assembly;@@ -99,7 +90,7 @@ const $quotationLinePriceEffects = computed($quotationStore, (store: Quote) => {let extendedQuantitiesPerAssembly: Record<string, number> = {};- itemsByLineId[line.id].assemblies.forEach((assembly: QuotationAssembly) => {+ assembliesByLineId[line.id]?.forEach((assembly: QuotationAssembly) => {let quantity = assembly.quantityPerParent ?? 1;let asm = assembliesById[assembly.id];while (asm.parentAssemblyId) {@@ -117,28 +108,32 @@ const $quotationLinePriceEffects = computed($quotationStore, (store: Quote) => {extendedQuantitiesPerAssembly[assembly.id] = quantity;});- itemsByLineId[line.id].operations.forEach(- (operation: QuotationOperation) => {- let materials = materialsByOperationId[operation.id] ?? [];- let extendedQuantityPerAssembly = operation.quoteAssemblyId- ? extendedQuantitiesPerAssembly[operation.quoteAssemblyId] ?? 1- : 1;+ operationsByLineId[line.id]?.forEach((operation: QuotationOperation) => {+ let materials = materialsByOperationId[operation.id] ?? [];+ let extendedQuantityPerAssembly = operation.quoteAssemblyId+ ? extendedQuantitiesPerAssembly[operation.quoteAssemblyId] ?? 1+ : 1;- let materialCost = materials.reduce(- (acc, material: QuotationMaterial) => {- return acc + (material.quantity ?? 0) * (material.unitCost ?? 0);- },- 0- );+ let materialCost = materials.reduce(+ (acc, material: QuotationMaterial) => {+ return acc + (material.quantity ?? 0) * (material.unitCost ?? 0);+ },+ 0+ );- linePriceEffects[line.id].materialCost.push((quantity) => {- return materialCost * quantity * extendedQuantityPerAssembly;- });+ linePriceEffects[line.id].materialCost.push((quantity) => {+ return materialCost * quantity * extendedQuantityPerAssembly;+ });- if (operation.setupHours) {- linePriceEffects[line.id].setupHours.push((_quantity) => {- return operation.setupHours;+ if (operation.setupHours) {+ linePriceEffects[line.id].setupHours.push((_quantity) => {+ return operation.setupHours;+ });+ if (operation.quotingRate) {+ linePriceEffects[line.id].overheadCost.push((_quantity) => {+ return operation.setupHours * (operation.quotingRate ?? 0);});+ } else {linePriceEffects[line.id].laborCost.push((_quantity) => {return operation.setupHours * (operation.laborRate ?? 0);});@@ -146,70 +141,87 @@ const $quotationLinePriceEffects = computed($quotationStore, (store: Quote) => {return operation.setupHours * (operation.overheadRate ?? 0);});}+ }- if (operation.productionStandard) {- let hoursPerProductionStandard = 0;- switch (operation.standardFactor) {- case "Hours/Piece":- hoursPerProductionStandard = operation.productionStandard;- break;- case "Hours/100 Pieces":- hoursPerProductionStandard = operation.productionStandard / 100;- break;- case "Hours/1000 Pieces":- hoursPerProductionStandard = operation.productionStandard / 1000;- break;- case "Minutes/Piece":- hoursPerProductionStandard = operation.productionStandard / 60;- break;- case "Minutes/100 Pieces":- hoursPerProductionStandard =- operation.productionStandard / 100 / 60;- break;- case "Minutes/1000 Pieces":- hoursPerProductionStandard =- operation.productionStandard / 1000 / 60;- break;- case "Pieces/Hour":- hoursPerProductionStandard = 1 / operation.productionStandard;- break;- case "Pieces/Minute":- hoursPerProductionStandard =- 1 / (operation.productionStandard / 60);- break;- case "Seconds/Piece":- hoursPerProductionStandard = operation.productionStandard / 3600;- break;- case "Total Hours":- hoursPerProductionStandard = operation.productionStandard;- break;- case "Total Minutes":- hoursPerProductionStandard = operation.productionStandard / 60;- break;- default:- break;- }+ if (operation.productionStandard) {+ let hoursPerProductionStandard = 0;+ switch (operation.standardFactor) {+ case "Hours/Piece":+ hoursPerProductionStandard = operation.productionStandard;+ break;+ case "Hours/100 Pieces":+ hoursPerProductionStandard = operation.productionStandard / 100;+ break;+ case "Hours/1000 Pieces":+ hoursPerProductionStandard = operation.productionStandard / 1000;+ break;+ case "Minutes/Piece":+ hoursPerProductionStandard = operation.productionStandard / 60;+ break;+ case "Minutes/100 Pieces":+ hoursPerProductionStandard =+ operation.productionStandard / 100 / 60;+ break;+ case "Minutes/1000 Pieces":+ hoursPerProductionStandard =+ operation.productionStandard / 1000 / 60;+ break;+ case "Pieces/Hour":+ hoursPerProductionStandard = 1 / operation.productionStandard;+ break;+ case "Pieces/Minute":+ hoursPerProductionStandard =+ 1 / (operation.productionStandard / 60);+ break;+ case "Seconds/Piece":+ hoursPerProductionStandard = operation.productionStandard / 3600;+ break;+ case "Total Hours":+ hoursPerProductionStandard = operation.productionStandard;+ break;+ case "Total Minutes":+ hoursPerProductionStandard = operation.productionStandard / 60;+ break;+ default:+ break;+ }- if (- ["Total Hours", "Total Minutes"].includes(operation.standardFactor)- ) {- linePriceEffects[line.id].productionHours.push((_quantity) => {- return hoursPerProductionStandard;+ if (+ ["Total Hours", "Total Minutes"].includes(operation.standardFactor)+ ) {+ linePriceEffects[line.id].productionHours.push((_quantity) => {+ return hoursPerProductionStandard;+ });+ if (operation.quotingRate) {+ linePriceEffects[line.id].overheadCost.push((_quantity) => {+ return hoursPerProductionStandard * (operation.quotingRate ?? 0);});+ } else {linePriceEffects[line.id].laborCost.push((_quantity) => {return hoursPerProductionStandard * (operation.laborRate ?? 0);});linePriceEffects[line.id].overheadCost.push((_quantity) => {return hoursPerProductionStandard * (operation.overheadRate ?? 0);});- } else {- linePriceEffects[line.id].productionHours.push((quantity) => {+ }+ } else {+ linePriceEffects[line.id].productionHours.push((quantity) => {+ return (+ hoursPerProductionStandard *+ quantity *+ extendedQuantityPerAssembly+ );+ });+ if (operation.quotingRate) {+ linePriceEffects[line.id].overheadCost.push((quantity) => {return (hoursPerProductionStandard *quantity *- extendedQuantityPerAssembly+ extendedQuantityPerAssembly *+ (operation.quotingRate ?? 0));});+ } else {linePriceEffects[line.id].laborCost.push((quantity) => {return (hoursPerProductionStandard *@@ -229,184 +241,11 @@ const $quotationLinePriceEffects = computed($quotationStore, (store: Quote) => {}}}- );- });- return linePriceEffects;-});--const $quotationMenuStore = computed($quotationStore, (store: Quote) => {- if (!store.quote) return [];-- let materialsByOperationId = store.materials.reduce<- Record<string, QuotationMaterial[]>- >((acc, material) => {- if (!acc[material.quoteOperationId]) {- acc[material.quoteOperationId] = [];- }- acc[material.quoteOperationId].push(material);- return acc;- }, {});-- let operationsByAssemblyId = store.operations.reduce<- Record<string, BillOfMaterialNode[]>- >((acc, operation) => {- if (!operation?.quoteAssemblyId) return acc;- if (!acc[operation.quoteAssemblyId]) {- acc[operation.quoteAssemblyId] = [];- }- acc[operation.quoteAssemblyId].push({- id: operation.id,- parentId: operation.quoteAssemblyId ?? undefined,- label: operation.description ?? "Operation",- type: "operation",- meta: operation,- children: [- {- id: operation.id,- label: "Materials",- type: "materials",- meta: operation,- children: materialsByOperationId[operation.id]?.map((material) => ({- id: material.id,- parentId: operation.id,- label: material.description,- type: "material",- meta: material,- })),- },- ],- });- return acc;- }, {});-- let itemsByLineId: Record<- string,- {- assemblies: BillOfMaterialNode[];- operations: BillOfMaterialNode[];- }- > = {};-- store.assemblies.forEach((assembly) => {- if (!itemsByLineId[assembly.quoteLineId]) {- itemsByLineId[assembly.quoteLineId] = defaultItems;- }- itemsByLineId[assembly.quoteLineId].assemblies.push({- id: assembly.id,- parentId: assembly.parentAssemblyId ?? undefined,- label: assembly.description ?? assembly.partId,- type: "assembly",- meta: assembly,});});-- store.operations.forEach((operation) => {- if (!itemsByLineId[operation.quoteLineId]) {- itemsByLineId[operation.quoteLineId] = defaultItems;- }- itemsByLineId[operation.quoteLineId].operations.push({- id: operation.id,- parentId: operation.quoteAssemblyId ?? undefined,- label: operation.description ?? "Operation",- type: "operation",- meta: operation,- children: [- {- id: `${operation.id}-materials`,- label: "Materials",- type: "materials",- meta: operation,- children: materialsByOperationId[operation.id]?.map((material) => ({- id: material.id,- parentId: operation.id,- label: material.description,- type: "material",- meta: material,- })),- },- ],- });- });-- let menu: BillOfMaterialNode[] = [- {- id: store.quote.id!,- label: store.quote.quoteId!,- type: "parent",- children: store.lines.map<BillOfMaterialNode>((line) => ({- id: line.id,- label: line.description,- type: "line",- meta: line,- children: [- {- id: `${line.id}-assemblies`,- label: "Assemblies",- type: "assemblies",- children: itemsByLineId[line.id]?.assemblies- ? [- ...(arrayToTree(itemsByLineId[line.id].assemblies, {- id: "id",- dataField: null,- }) as BillOfMaterialNode[]),- ]- : [],- meta: line,- },- {- id: `${line.id}-operations`,- label: "Operations",- type: "operations",- children: itemsByLineId[line.id]?.operations.filter(- (operation) => operation.parentId === undefined- ) as BillOfMaterialNode[],- meta: line,- },- ],- })),- },- ];-- traverseTree(menu, (node) => {- if (node.type === "assembly") {- let currentChildren = node.children ? [...node.children] : [];- node.children = [- {- id: `${node.id}-assemblies`,- parentId: node.id,- label: "Assemblies",- type: "assemblies",- children: currentChildren,- meta: node.meta,- },- {- id: `${node.id}-operations`,- parentId: node.id,- label: "Operations",- type: "operations",- children: operationsByAssemblyId[node.id] ?? [],- meta: node.meta,- },- ];- }- });-- return menu;+ return linePriceEffects;});-function traverseTree(- tree: BillOfMaterialNode[],- callback: (node: BillOfMaterialNode) => void-) {- tree.forEach((node) => {- callback(node);- if (node.children) {- traverseTree(node.children, callback);- }- });-}-export const useQuotation = () => useNanoStore<Quote>($quotationStore);-export const useQuotationMenu = () => useValue($quotationMenuStore);export const useQuotationLinePriceEffects = () =>useValue($quotationLinePriceEffects);diff --git a/apps/carbon/app/root.tsx b/apps/carbon/app/root.tsxindex 34a498cad2..2da8c371ab 100644--- a/apps/carbon/app/root.tsx+++ b/apps/carbon/app/root.tsx@@ -32,7 +32,6 @@ import { modeValidator } from "./types/validators";export function links() {return [{ rel: "stylesheet", href: Tailwind },- { rel: "stylesheet", href: "/assets/theme.css" },{ rel: "stylesheet", href: Background },{ rel: "stylesheet", href: NProgress },];diff --git a/apps/carbon/app/routes/x+/_layout.tsx b/apps/carbon/app/routes/x+/_layout.tsxindex 854bc5059c..3880e62745 100644--- a/apps/carbon/app/routes/x+/_layout.tsx+++ b/apps/carbon/app/routes/x+/_layout.tsx@@ -21,6 +21,10 @@ import {} from "~/services/session.server";import { path } from "~/utils/path";+export function links() {+ return [{ rel: "stylesheet", href: "/assets/theme.css" }];+}+export async function loader({ request }: LoaderFunctionArgs) {const { accessToken, expiresAt, expiresIn, userId } =await requireAuthSession(request, { verify: true });