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
wip: flush out design for bill of material explorer
Brad Barbina9ed84cfd106
diff --git a/apps/carbon/app/routes/x+/quote+/$id.tsx b/apps/carbon/app/routes/x+/quote+/$id.tsxindex dba3768674..dc1de95a7e 100644--- a/apps/carbon/app/routes/x+/quote+/$id.tsx+++ b/apps/carbon/app/routes/x+/quote+/$id.tsx@@ -34,6 +34,9 @@ import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";import { error } from "~/utils/result";+import { AiOutlinePartition } from "react-icons/ai";+import { HiOutlineCube } from "react-icons/hi";+import { LuClock } from "react-icons/lu";import { RxChevronDown } from "react-icons/rx";export const handle: Handle = {@@ -105,7 +108,7 @@ export default function QuotationRoute() {return (<div className="grid grid-cols-1 md:grid-cols-[auto_1fr] w-full"><CollapsibleSidebar width={260}>- <VStack className="border-b border-border p-4" spacing={0}>+ <VStack className="border-b border-border p-4" spacing={1}><Heading size="h3" noOfLines={1}>QUO000001</Heading>@@ -126,7 +129,7 @@ export default function QuotationRoute() {</Tooltip></HStack></VStack>- <VStack className="p-2 w-full">+ <VStack className="h-[calc(100vh-183px)] p-2 w-full"><BillOfMaterialExplorer /></VStack></CollapsibleSidebar>@@ -152,29 +155,206 @@ export default function QuotationRoute() {);}+type BillOfMaterialNodeType =+ | "parent"+ | "part"+ | "assemblies"+ | "operations"+ | "materials"+ | "assembly"+ | "operation"+ | "material";+type BillOfMaterialNode = {id: string;- type: "folder" | "file";+ label: string;+ type: BillOfMaterialNodeType;children?: BillOfMaterialNode[];};const data: BillOfMaterialNode[] = [{- id: "QUO000001",- type: "folder",+ id: "1",+ label: "QUO000001",+ type: "parent",children: [{- id: "F505555",- type: "folder",- },- {- id: "F505556",- type: "folder",+ id: "2",+ label: "P00001233",+ type: "part",+ children: [+ {+ id: "3",+ label: "Assemblies",+ type: "assemblies",+ children: [+ {+ id: "4",+ label: "F5000123",+ type: "part",+ children: [+ {+ id: "5",+ label: "Assemblies",+ type: "assemblies",+ children: [],+ },+ {+ id: "6",+ label: "Operations",+ type: "operations",+ children: [+ {+ id: "7",+ label: "OP0003",+ type: "operation",+ children: [+ {+ id: "8",+ label: "Materials",+ type: "materials",+ children: [+ {+ id: "9",+ label: "RAW000001",+ type: "material",+ },+ {+ id: "10",+ label: "FAS000002",+ type: "material",+ },+ ],+ },+ ],+ },+ ],+ },+ ],+ },+ ],+ },+ {+ id: "11",+ label: "Operations",+ type: "operations",+ children: [+ {+ id: "12",+ label: "OP0001",+ type: "operation",+ children: [+ {+ id: "13",+ label: "Materials",+ type: "materials",+ children: [+ {+ id: "14",+ label: "RAW000003",+ type: "material",+ },+ ],+ },+ ],+ },+ {+ id: "13",+ label: "OP0002",+ type: "operation",+ children: [+ {+ id: "13",+ label: "Materials",+ type: "materials",+ },+ ],+ },+ ],+ },+ ],},],},];+const BillOfMaterialItem = ({+ type,+ id,+ label,+}: Omit<BillOfMaterialNode, "children">) => {+ switch (type) {+ case "assemblies":+ return (+ <Button+ variant="ghost"+ className="w-full justify-between text-muted-foreground"+ >+ <span>{label}</span>+ <IoMdAdd />+ </Button>+ );+ case "materials":+ return (+ <Button+ variant="ghost"+ className="w-full justify-between text-muted-foreground"+ >+ <span>{label}</span>+ <IoMdAdd />+ </Button>+ );+ case "operations":+ return (+ <Button+ variant="ghost"+ className="w-full justify-between text-muted-foreground"+ >+ <span>{label}</span>+ <IoMdAdd />+ </Button>+ );+ case "part":+ case "assembly":+ return (+ <Button+ leftIcon={<AiOutlinePartition />}+ variant="ghost"+ className="flex-1 justify-start"+ >+ {label}+ </Button>+ );+ case "operation":+ return (+ <Button+ leftIcon={<LuClock />}+ variant="ghost"+ className="flex-1 justify-start"+ >+ {label}+ </Button>+ );+ case "material":+ return (+ <Button+ leftIcon={<HiOutlineCube />}+ variant="ghost"+ className="flex-1 justify-start"+ >+ {label}+ </Button>+ );+ case "parent":+ default:+ return (+ <Button variant="ghost" className="flex-1 justify-start">+ {label}+ </Button>+ );+ }+};+const BillOfMaterialExplorer = () => {const [expandedNodes, setExpandedNodes] = useState<Record<string, boolean>>({}@@ -230,10 +410,11 @@ const BillOfMaterialExplorer = () => {}}variant="ghost"/>-- <Button variant="ghost" className="flex-1 justify-start">- {node.id}- </Button>+ <BillOfMaterialItem+ type={node.type}+ id={node.id}+ label={node.label}+ /></HStack>{node.children &&expandedNodes[node.id] &&diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 8445f75e40..b5c0c92480 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -6876,6 +6876,115 @@ export interface Database {}];};+ quoteAssembly: {+ Row: {+ createdAt: string;+ createdBy: string;+ description: string | null;+ id: string;+ parentModuleId: string | null;+ partId: string;+ quantityPerParent: number;+ quoteAssemblyId: string;+ quoteId: string;+ quoteLineId: string;+ unitOfMeasureCode: string | null;+ updatedAt: string | null;+ updatedBy: string | null;+ };+ Insert: {+ createdAt?: string;+ createdBy: string;+ description?: string | null;+ id?: string;+ parentModuleId?: string | null;+ partId: string;+ quantityPerParent?: number;+ quoteAssemblyId?: string;+ quoteId: string;+ quoteLineId: string;+ unitOfMeasureCode?: string | null;+ updatedAt?: string | null;+ updatedBy?: string | null;+ };+ Update: {+ createdAt?: string;+ createdBy?: string;+ description?: string | null;+ id?: string;+ parentModuleId?: string | null;+ partId?: string;+ quantityPerParent?: number;+ quoteAssemblyId?: string;+ quoteId?: string;+ quoteLineId?: string;+ unitOfMeasureCode?: string | null;+ updatedAt?: string | null;+ updatedBy?: string | null;+ };+ Relationships: [+ {+ foreignKeyName: "quoteAssembly_createdBy_fkey";+ columns: ["createdBy"];+ referencedRelation: "user";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_createdBy_fkey";+ columns: ["createdBy"];+ referencedRelation: "employeeSummary";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_createdBy_fkey";+ columns: ["createdBy"];+ referencedRelation: "userDefaults";+ referencedColumns: ["userId"];+ },+ {+ foreignKeyName: "quoteAssembly_parentModuleId_fkey";+ columns: ["parentModuleId"];+ referencedRelation: "quoteAssembly";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_quoteId_fkey";+ columns: ["quoteId"];+ referencedRelation: "quote";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_quoteId_fkey";+ columns: ["quoteId"];+ referencedRelation: "quotes";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_quoteLineId_fkey";+ columns: ["quoteLineId"];+ referencedRelation: "quoteLine";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_updatedBy_fkey";+ columns: ["updatedBy"];+ referencedRelation: "user";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_updatedBy_fkey";+ columns: ["updatedBy"];+ referencedRelation: "employeeSummary";+ referencedColumns: ["id"];+ },+ {+ foreignKeyName: "quoteAssembly_updatedBy_fkey";+ columns: ["updatedBy"];+ referencedRelation: "userDefaults";+ referencedColumns: ["userId"];+ }+ ];+ };quoteFavorite: {Row: {quoteId: string;@@ -7279,115 +7388,6 @@ export interface Database {}];};- quoteModule: {- Row: {- createdAt: string;- createdBy: string;- description: string | null;- id: string;- parentModuleId: string | null;- partId: string;- quantityPerParent: number;- quoteId: string;- quoteLineId: string;- quoteModuleId: string;- unitOfMeasureCode: string | null;- updatedAt: string | null;- updatedBy: string | null;- };- Insert: {- createdAt?: string;- createdBy: string;- description?: string | null;- id?: string;- parentModuleId?: string | null;- partId: string;- quantityPerParent?: number;- quoteId: string;- quoteLineId: string;- quoteModuleId?: string;- unitOfMeasureCode?: string | null;- updatedAt?: string | null;- updatedBy?: string | null;- };- Update: {- createdAt?: string;- createdBy?: string;- description?: string | null;- id?: string;- parentModuleId?: string | null;- partId?: string;- quantityPerParent?: number;- quoteId?: string;- quoteLineId?: string;- quoteModuleId?: string;- unitOfMeasureCode?: string | null;- updatedAt?: string | null;- updatedBy?: string | null;- };- Relationships: [- {- foreignKeyName: "quoteModule_createdBy_fkey";- columns: ["createdBy"];- referencedRelation: "user";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_createdBy_fkey";- columns: ["createdBy"];- referencedRelation: "employeeSummary";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_createdBy_fkey";- columns: ["createdBy"];- referencedRelation: "userDefaults";- referencedColumns: ["userId"];- },- {- foreignKeyName: "quoteModule_parentModuleId_fkey";- columns: ["parentModuleId"];- referencedRelation: "quoteModule";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_quoteId_fkey";- columns: ["quoteId"];- referencedRelation: "quote";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_quoteId_fkey";- columns: ["quoteId"];- referencedRelation: "quotes";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_quoteLineId_fkey";- columns: ["quoteLineId"];- referencedRelation: "quoteLine";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_updatedBy_fkey";- columns: ["updatedBy"];- referencedRelation: "user";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_updatedBy_fkey";- columns: ["updatedBy"];- referencedRelation: "employeeSummary";- referencedColumns: ["id"];- },- {- foreignKeyName: "quoteModule_updatedBy_fkey";- columns: ["updatedBy"];- referencedRelation: "userDefaults";- referencedColumns: ["userId"];- }- ];- };quoteProcess: {Row: {createdAt: string;@@ -7398,9 +7398,9 @@ export interface Database {laborRate: number;overheadRate: number;productionStandard: number;+ quoteAssemblyId: string;quoteId: string;quoteLineId: string;- quoteModuleId: string;quotingRate: number;setupHours: number;standardFactor: Database["public"]["Enums"]["factor"];@@ -7417,9 +7417,9 @@ export interface Database {laborRate?: number;overheadRate?: number;productionStandard?: number;+ quoteAssemblyId: string;quoteId: string;quoteLineId: string;- quoteModuleId: string;quotingRate?: number;setupHours?: number;standardFactor?: Database["public"]["Enums"]["factor"];@@ -7436,9 +7436,9 @@ export interface Database {laborRate?: number;overheadRate?: number;productionStandard?: number;+ quoteAssemblyId?: string;quoteId?: string;quoteLineId?: string;- quoteModuleId?: string;quotingRate?: number;setupHours?: number;standardFactor?: Database["public"]["Enums"]["factor"];@@ -7471,6 +7471,12 @@ export interface Database {referencedRelation: "equipmentType";referencedColumns: ["id"];},+ {+ foreignKeyName: "quoteProcess_quoteAssemblyId_fkey";+ columns: ["quoteAssemblyId"];+ referencedRelation: "quoteAssembly";+ referencedColumns: ["id"];+ },{foreignKeyName: "quoteProcess_quoteId_fkey";columns: ["quoteId"];@@ -7489,12 +7495,6 @@ export interface Database {referencedRelation: "quoteLine";referencedColumns: ["id"];},- {- foreignKeyName: "quoteProcess_quoteModuleId_fkey";- columns: ["quoteModuleId"];- referencedRelation: "quoteModule";- referencedColumns: ["id"];- },{foreignKeyName: "quoteProcess_updatedBy_fkey";columns: ["updatedBy"];diff --git a/packages/database/supabase/migrations/20240206224405_quotes.sql b/packages/database/supabase/migrations/20240206224405_quotes.sqlindex 52b8bbc93c..36d43d80cf 100644--- a/packages/database/supabase/migrations/20240206224405_quotes.sql+++ b/packages/database/supabase/migrations/20240206224405_quotes.sql@@ -98,11 +98,11 @@ CREATE TABLE "quoteLineQuantities" (CREATE INDEX "quoteLineQuantities_quoteLineId_idx" ON "quoteLineQuantities" ("quoteLineId");-CREATE TABLE "quoteModule" (+CREATE TABLE "quoteAssembly" ("id" TEXT NOT NULL DEFAULT xid(),"quoteId" TEXT NOT NULL,"quoteLineId" TEXT NOT NULL,- "quoteModuleId" TEXT NOT NULL DEFAULT xid(),+ "quoteAssemblyId" TEXT NOT NULL DEFAULT xid(),"parentModuleId" TEXT,"partId" TEXT NOT NULL,"description" TEXT,@@ -113,23 +113,23 @@ CREATE TABLE "quoteModule" ("updatedAt" TIMESTAMP WITH TIME ZONE,"updatedBy" TEXT,- CONSTRAINT "quoteModule_pkey" PRIMARY KEY ("id"),- CONSTRAINT "quoteModule_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteModule_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteModule_parentModuleId_fkey" FOREIGN KEY ("parentModuleId") REFERENCES "quoteModule" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteModule_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,- CONSTRAINT "quoteModule_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE+ CONSTRAINT "quoteAssembly_pkey" PRIMARY KEY ("id"),+ CONSTRAINT "quoteAssembly_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteAssembly_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteAssembly_parentModuleId_fkey" FOREIGN KEY ("parentModuleId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteAssembly_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,+ CONSTRAINT "quoteAssembly_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE);-CREATE INDEX "quoteModule_quoteId_idx" ON "quoteModule" ("quoteId");-CREATE INDEX "quoteModule_quoteLineId_idx" ON "quoteModule" ("quoteLineId");-CREATE INDEX "quoteModule_parentModuleId_idx" ON "quoteModule" ("parentModuleId");+CREATE INDEX "quoteAssembly_quoteId_idx" ON "quoteAssembly" ("quoteId");+CREATE INDEX "quoteAssembly_quoteLineId_idx" ON "quoteAssembly" ("quoteLineId");+CREATE INDEX "quoteAssembly_parentModuleId_idx" ON "quoteAssembly" ("parentModuleId");CREATE TABLE "quoteProcess" ("id" TEXT NOT NULL DEFAULT xid(),"quoteId" TEXT NOT NULL,"quoteLineId" TEXT NOT NULL,- "quoteModuleId" TEXT NOT NULL,+ "quoteAssemblyId" TEXT NOT NULL,"workCellTypeId" TEXT NOT NULL,"equipmentTypeId" TEXT,"description" TEXT NOT NULL,@@ -147,7 +147,7 @@ CREATE TABLE "quoteProcess" (CONSTRAINT "quoteProcess_pkey" PRIMARY KEY ("id"),CONSTRAINT "quoteProcess_quoteId_fkey" FOREIGN KEY ("quoteId") REFERENCES "quote" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quoteProcess_quoteLineId_fkey" FOREIGN KEY ("quoteLineId") REFERENCES "quoteLine" ("id") ON DELETE CASCADE ON UPDATE CASCADE,- CONSTRAINT "quoteProcess_quoteModuleId_fkey" FOREIGN KEY ("quoteModuleId") REFERENCES "quoteModule" ("id") ON DELETE CASCADE ON UPDATE CASCADE,+ CONSTRAINT "quoteProcess_quoteAssemblyId_fkey" FOREIGN KEY ("quoteAssemblyId") REFERENCES "quoteAssembly" ("id") ON DELETE CASCADE ON UPDATE CASCADE,CONSTRAINT "quoteProcess_workCellTypeId_fkey" FOREIGN KEY ("workCellTypeId") REFERENCES "workCellType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quoteProcess_equipmentTypeId_fkey" FOREIGN KEY ("equipmentTypeId") REFERENCES "equipmentType" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,CONSTRAINT "quoteProcess_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,@@ -156,7 +156,7 @@ CREATE TABLE "quoteProcess" (CREATE INDEX "quoteProcess_quoteId_idx" ON "quoteProcess" ("quoteId");CREATE INDEX "quoteProcess_quoteLineId_idx" ON "quoteProcess" ("quoteLineId");-CREATE INDEX "quoteProcess_quoteModuleId_idx" ON "quoteProcess" ("quoteModuleId");+CREATE INDEX "quoteProcess_quoteAssemblyId_idx" ON "quoteProcess" ("quoteAssemblyId");CREATE TABLE "quoteMaterial" ("id" TEXT NOT NULL DEFAULT xid(),