Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: quote save method and bill of material/process fixes

Brad Barbinb0b3f4eed87a
diff --git a/apps/carbon/app/components/Assignee.tsx b/apps/carbon/app/components/Assignee.tsx
index 7f953f1c69..2a5022676b 100644
--- a/apps/carbon/app/components/Assignee.tsx
+++ b/apps/carbon/app/components/Assignee.tsx
@@ -85,7 +85,7 @@ const Assign = forwardRef<HTMLButtonElement, AssigneeProps>(
<PopoverTrigger asChild>
<button
className={cn(
- "rounded-md px-2.5 py-0.5 text-sm transition-colors cursor-pointer bg-background hover:bg-accent hover:text-accent-foreground border border-input font-normal",
+ "rounded-md px-2.5 py-0.5 text-sm transition-colors cursor-pointer hover:bg-accent hover:text-accent-foreground border border-input bg-card font-normal",
className
)}
role="combobox"
diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsx
index c1ed9aec75..d64a860a8e 100644
--- a/apps/carbon/app/components/Form/Item.tsx
+++ b/apps/carbon/app/components/Form/Item.tsx
@@ -158,6 +158,7 @@ const Item = ({
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton
+ type="button"
aria-label="Change Type"
className="bg-transparent flex-shrink-0 h-10 rounded-l-none border-l-0 shadow-sm"
disabled={props.isReadOnly}
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
index 9dd5ce6684..81d07fb7a8 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
@@ -172,7 +172,7 @@ const DocumentsTable = memo(
<HStack>
{row.original.favorite ? (
<LuPin
- className="cursor-pointer w-4 h-4 outline-yellow-400 fill-yellow-400 flex-shrink-0"
+ className="cursor-pointer w-4 h-4 outline-foreground fill-foreground flex-shrink-0"
onClick={() => onFavorite(row.original)}
/>
) : (
diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
index 213c263fd5..92eece131e 100644
--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableHeader.tsx
@@ -1,7 +1,7 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
-import { MethodItemTypeIcon } from "~/components";
+import { Copy, MethodItemTypeIcon } from "~/components";
import { DetailsTopbar } from "~/components/Layout";
import { useRouteData } from "~/hooks";
import type { Consumable } from "~/modules/items";
@@ -22,11 +22,12 @@ const ConsumableHeader = () => {
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.consumableDetails(itemId)}>
- <Heading size="h2">{routeData?.consumableSummary?.id}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <MethodItemTypeIcon type="Consumable" />
+ <span>{routeData?.consumableSummary?.id}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Consumable" />
- </Badge>
+ <Copy text={routeData?.consumableSummary?.id ?? ""} />
</HStack>
</VStack>
<VStack spacing={0} className="flex-shrink justify-center items-end">
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
index a3adb20059..4a09047b51 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureForm.tsx
@@ -172,7 +172,7 @@ const FixtureForm = ({
/>
<Customer name="customerId" label="Customer" />
- {!isEditing && (
+ {!isEditing && replenishmentSystem !== "Make" && (
<Number
name="unitCost"
label="Unit Cost"
diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
index 5ee98636a4..40a391de97 100644
--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureHeader.tsx
@@ -1,7 +1,7 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
-import { MethodItemTypeIcon } from "~/components";
+import { Copy, MethodItemTypeIcon } from "~/components";
import { DetailsTopbar } from "~/components/Layout";
import { useRouteData } from "~/hooks";
import type { Fixture } from "~/modules/items";
@@ -18,15 +18,16 @@ const FixtureHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.fixtureDetails(itemId)}>
- <Heading size="h2">{routeData?.fixtureSummary?.id}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <MethodItemTypeIcon type="Fixture" />
+ <span>{routeData?.fixtureSummary?.id}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Fixture" />
- </Badge>
+ <Copy text={routeData?.fixtureSummary?.id ?? ""} />
</HStack>
</VStack>
<VStack spacing={0} className="flex-shrink justify-center items-end">
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
index 302ab6c0e4..1475ec8929 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -515,6 +515,7 @@ function MaterialForm({
disabledItems={[params.itemId!]}
name="itemId"
label={itemType}
+ includeInactive
type={itemType}
onChange={(value) => {
onItemChange(value?.value as string);
diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
index 844e4d89bf..92f7d60cc9 100644
--- a/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialHeader.tsx
@@ -1,7 +1,7 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
-import { MethodItemTypeIcon } from "~/components";
+import { Copy, MethodItemTypeIcon } from "~/components";
import { DetailsTopbar } from "~/components/Layout";
import { useRouteData } from "~/hooks";
import type { Material } from "~/modules/items";
@@ -22,11 +22,12 @@ const MaterialHeader = () => {
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.materialDetails(itemId)}>
- <Heading size="h2">{routeData?.materialSummary?.id}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <MethodItemTypeIcon type="Material" />
+ <span>{routeData?.materialSummary?.id}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Material" />
- </Badge>
+ <Copy text={routeData?.materialSummary?.id ?? ""} />
</HStack>
</VStack>
<VStack spacing={0} className="flex-shrink justify-center items-end">
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
index ff9986db60..8c6c454a4c 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartForm.tsx
@@ -170,7 +170,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
label="Unit of Measure"
/>
- {!isEditing && (
+ {!isEditing && replenishmentSystem !== "Make" && (
<Number
name="unitCost"
label="Unit Cost"
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx b/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx
index 3ffd1ed0f1..ba5211843c 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartHeader.tsx
@@ -1,4 +1,4 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
import { Copy, MethodItemTypeIcon } from "~/components";
@@ -18,15 +18,15 @@ const PartHeader = () => {
);
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.partDetails(itemId)}>
- <Heading size="h2">{routeData?.partSummary?.id}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <MethodItemTypeIcon type="Part" />
+ <span>{routeData?.partSummary?.id}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Part" />
- </Badge>
<Copy text={routeData?.partSummary?.id ?? ""} />
</HStack>
</VStack>
diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
index cd695293ee..2d6af72c57 100644
--- a/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Services/ServiceHeader.tsx
@@ -1,7 +1,7 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
-import { MethodItemTypeIcon } from "~/components";
+import { Copy, MethodItemTypeIcon } from "~/components";
import { DetailsTopbar } from "~/components/Layout";
import { useRouteData } from "~/hooks";
import type { Service } from "~/modules/items";
@@ -23,11 +23,12 @@ const ServiceHeader = () => {
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.serviceDetails(itemId)}>
- <Heading size="h2">{routeData?.service?.id}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <MethodItemTypeIcon type="Service" />
+ <span>{routeData?.service?.id}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Service" />
- </Badge>
+ <Copy text={routeData?.service?.id ?? ""} />
</HStack>
</VStack>
<VStack spacing={0} className="flex-shrink justify-center items-end">
diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
index 0f2641564e..724212f371 100644
--- a/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
+++ b/apps/carbon/app/modules/items/ui/Tools/ToolHeader.tsx
@@ -1,7 +1,7 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
-import { MethodItemTypeIcon } from "~/components";
+import { Copy, MethodItemTypeIcon } from "~/components";
import { DetailsTopbar } from "~/components/Layout";
import { useRouteData } from "~/hooks";
import type { Tool } from "~/modules/items";
@@ -16,15 +16,16 @@ const ToolHeader = () => {
const routeData = useRouteData<{ toolSummary: Tool }>(path.to.tool(itemId));
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.toolDetails(itemId)}>
- <Heading size="h2">{routeData?.toolSummary?.id}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <MethodItemTypeIcon type="Tool" />
+ <span>{routeData?.toolSummary?.id}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <MethodItemTypeIcon type="Tool" />
- </Badge>
+ <Copy text={routeData?.toolSummary?.id ?? ""} />
</HStack>
</VStack>
<VStack spacing={0} className="flex-shrink justify-center items-end">
diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx
index 9bb072ee01..99b1a9483c 100644
--- a/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -1,4 +1,4 @@
-import { Badge, HStack, Heading, VStack } from "@carbon/react";
+import { HStack, Heading, VStack } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
import { LuHardHat } from "react-icons/lu";
@@ -15,15 +15,15 @@ const JobHeader = () => {
const routeData = useRouteData<{ job: Job }>(path.to.job(jobId));
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<VStack spacing={0} className="flex-grow">
<HStack>
<Link to={path.to.jobDetails(jobId)}>
- <Heading size="h2">{routeData?.job?.jobId}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <LuHardHat />
+ <span>{routeData?.job?.jobId}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <LuHardHat />
- </Badge>
<Copy text={routeData?.job?.jobId ?? ""} />
</HStack>
</VStack>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx
index 5119a16322..a4387ba005 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable.tsx
@@ -88,7 +88,7 @@ const PurchaseOrdersTable = memo(
<input type="hidden" name="favorite" value="unfavorite" />
<button type="submit">
<LuPin
- className="cursor-pointer w-4 h-4 outline-yellow-400 fill-yellow-400 flex-shrink-0"
+ className="cursor-pointer w-4 h-4 outline-foreground fill-foreground flex-shrink-0"
type="submit"
/>
</button>
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
index 2f69c8e046..3bf434ea84 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
@@ -20,7 +20,7 @@ import {
import { prettifyKeyboardShortcut } from "@carbon/utils";
import { useNavigate, useParams } from "@remix-run/react";
import { useRef, useState } from "react";
-import { LuChevronsUpDown, LuPlus, LuTrash } from "react-icons/lu";
+import { LuChevronDown, LuPlus, LuTrash } from "react-icons/lu";
import { MdMoreVert } from "react-icons/md";
import { Empty, ItemThumbnail } from "~/components";
import type { Tree } from "~/components/TreeView";
@@ -226,7 +226,8 @@ function QuoteLineItem({
{line.methodType === "Make" && permissions.can("update", "sales") && (
<IconButton
aria-label={disclosure.isOpen ? "Hide" : "Show"}
- icon={<LuChevronsUpDown />}
+ className={cn("animate", disclosure.isOpen && "-rotate-180")}
+ icon={<LuChevronDown />}
size="sm"
variant="ghost"
onClick={(e) => {
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
index 71c3c441f4..a75135c890 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx
@@ -1,4 +1,4 @@
-import { Badge, Button, HStack, Heading, useDisclosure } from "@carbon/react";
+import { Button, HStack, Heading, useDisclosure } from "@carbon/react";
import { Form, Link, useParams } from "@remix-run/react";
import {
@@ -44,19 +44,17 @@ const QuoteHeader = () => {
return (
<>
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<HStack className="w-full justify-between">
<HStack>
<Link to={path.to.quoteDetails(quoteId)}>
- <Heading size="h2">{routeData?.quote?.quoteId}</Heading>
- </Link>
- <Badge variant="secondary">
- <Badge variant="secondary">
+ <Heading size="h2" className="flex items-center gap-1">
<RiProgress4Line />
- </Badge>
- </Badge>
- <QuoteStatus status={routeData?.quote?.status} />
+ <span>{routeData?.quote?.quoteId}</span>
+ </Heading>
+ </Link>
<Copy text={routeData?.quote?.quoteId ?? ""} />
+ <QuoteStatus status={routeData?.quote?.status} />
</HStack>
<HStack>
<Assignee
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
index af77f0946b..4c14d339e8 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineForm.tsx
@@ -189,7 +189,7 @@ const QuoteLineForm = ({
<>
<ModalCardProvider type={type}>
<ModalCard onClose={onClose}>
- <ModalCardContent>
+ <ModalCardContent size="xlarge">
<ValidatedForm
defaultValues={initialValues}
validator={quoteLineValidator}
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
index 36a5922cd2..598e54f8b3 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuotesTable.tsx
@@ -85,7 +85,7 @@ const QuotesTable = memo(({ data, count }: QuotesTableProps) => {
<input type="hidden" name="favorite" value="unfavorite" />
<button type="submit">
<LuPin
- className="cursor-pointer w-4 h-4 outline-yellow-400 fill-yellow-400 flex-shrink-0"
+ className="cursor-pointer w-4 h-4 outline-foreground fill-foreground flex-shrink-0"
type="submit"
/>
</button>
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
index 72f12995c6..86fb780312 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx
@@ -1,4 +1,4 @@
-import { Badge, Button, HStack, Heading } from "@carbon/react";
+import { Button, HStack, Heading } from "@carbon/react";
import { Link, useParams } from "@remix-run/react";
import { LuEye, LuFile, LuTruck, LuXCircle } from "react-icons/lu";
@@ -32,19 +32,17 @@ const SalesOrderHeader = () => {
return (
<>
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<HStack className="w-full justify-between">
<HStack>
<Link to={path.to.salesOrderDetails(orderId)}>
- <Heading size="h2">{routeData?.salesOrder?.salesOrderId}</Heading>
- </Link>
- <Badge variant="secondary">
- <Badge variant="secondary">
+ <Heading size="h2" className="flex items-center gap-1">
<RiProgress8Line />
- </Badge>
- </Badge>
- <SalesStatus status={routeData?.salesOrder?.status} />
+ <span>{routeData?.salesOrder?.salesOrderId}</span>
+ </Heading>
+ </Link>
<Copy text={routeData?.salesOrder?.salesOrderId ?? ""} />
+ <SalesStatus status={routeData?.salesOrder?.status} />
</HStack>
<HStack>
<Assignee
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsx b/apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsx
index 53a5cdf357..6f8d650c6c 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsx
@@ -83,7 +83,7 @@ const SalesOrdersTable = memo(({ data, count }: SalesOrdersTableProps) => {
<input type="hidden" name="favorite" value="unfavorite" />
<button type="submit">
<LuPin
- className="cursor-pointer w-4 h-4 outline-yellow-400 fill-yellow-400 flex-shrink-0"
+ className="cursor-pointer w-4 h-4 outline-foreground fill-foreground flex-shrink-0"
type="submit"
/>
</button>
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx
index 9a06cfc3a5..10c5e20c37 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx
@@ -2,7 +2,6 @@ import {
Alert,
AlertDescription,
AlertTitle,
- Badge,
Button,
HStack,
Heading,
@@ -55,17 +54,17 @@ const SalesRFQHeader = () => {
const status = routeData?.rfqSummary?.status ?? "Draft";
return (
- <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border">
+ <div className="flex flex-shrink-0 items-center justify-between px-4 py-2 bg-card border-b border-border shadow-md">
<HStack className="w-full justify-between">
<HStack>
<Link to={path.to.salesRfqDetails(rfqId)}>
- <Heading size="h2">{routeData?.rfqSummary?.rfqId}</Heading>
+ <Heading size="h2" className="flex items-center gap-1">
+ <RiProgress2Line />
+ <span>{routeData?.rfqSummary?.rfqId}</span>
+ </Heading>
</Link>
- <Badge variant="secondary">
- <RiProgress2Line />
- </Badge>
- <SalesRFQStatus status={routeData?.rfqSummary?.status} />
<Copy text={routeData?.rfqSummary?.rfqId ?? ""} />
+ <SalesRFQStatus status={routeData?.rfqSummary?.status} />
</HStack>
<HStack>
<Assignee
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQsTable.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQsTable.tsx
index fdb7bc2a21..7f244a2434 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQsTable.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQsTable.tsx
@@ -74,7 +74,7 @@ const SalesRFQsTable = memo(({ data, count }: SalesRFQsTableProps) => {
<input type="hidden" name="favorite" value="unfavorite" />
<button type="submit">
<LuPin
- className="cursor-pointer w-4 h-4 outline-yellow-400 fill-yellow-400"
+ className="cursor-pointer w-4 h-4 outline-foreground fill-foreground"
type="submit"
/>
</button>
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
index 4c1b8efdf0..17a53fdc9f 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -96,8 +96,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
export default function MethodMaterialMakePage() {
- const { item, methodMaterials, methodOperations } =
- useLoaderData<typeof loader>();
+ const loaderData = useLoaderData<typeof loader>();
+ const { item, methodMaterials, methodOperations } = loaderData;
const { itemId, makeMethodId, materialId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
@@ -105,20 +105,20 @@ export default function MethodMaterialMakePage() {
if (!materialId) throw new Error("Could not find materialId");
return (
- <VStack spacing={2} className="p-2">
+ <VStack spacing={2} className="p-2" key={JSON.stringify(loaderData)}>
<MakeMethodBreadcrumbs itemId={item.id} type="Fixture" />
<ItemForm
- key={JSON.stringify(item)}
+ key={`item:${itemId}:${makeMethodId}:${materialId}`}
type={item.type}
initialValues={item}
/>
<BillOfProcess
- key={JSON.stringify(methodOperations)}
+ key={`bop:${itemId}:${makeMethodId}:${materialId}`}
makeMethodId={makeMethodId}
operations={methodOperations}
/>
<BillOfMaterial
- key={JSON.stringify(methodMaterials)}
+ key={`bom:${itemId}:${makeMethodId}:${materialId}`}
makeMethodId={makeMethodId}
materials={methodMaterials}
operations={methodOperations}
diff --git a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx
index 52c4ea5381..a7f02c6028 100644
--- a/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx
+++ b/apps/carbon/app/routes/x+/fixture+/$itemId.manufacturing.method.tsx
@@ -24,16 +24,20 @@ export default function MakeMethodRoute() {
if (!makeMethodId) throw new Error("Could not find makeMethodId");
return (
- <VStack spacing={2} className="p-2">
+ <VStack
+ spacing={2}
+ className="p-2"
+ key={JSON.stringify(manufacturingRouteData)}
+ >
<MakeMethodBreadcrumbs itemId={itemId} type="Fixture" />
<BillOfProcess
- key={JSON.stringify(manufacturingRouteData?.methodOperations)}
+ key={itemId}
makeMethodId={makeMethodId}
// @ts-ignore
- operations={manufacturingRouteData?.methodOperations}
+ operations={manufacturingRouteData?.methodOperations ?? []}
/>
<BillOfMaterial
- key={JSON.stringify(manufacturingRouteData?.methodMaterials)}
+ key={itemId}
makeMethodId={makeMethodId}
// @ts-ignore
materials={manufacturingRouteData?.methodMaterials ?? []}
diff --git a/apps/carbon/app/routes/x+/job+/$jobId.make.$methodId.$materialId.tsx b/apps/carbon/app/routes/x+/job+/$jobId.make.$methodId.$materialId.tsx
index b4af3c6f45..c6a92453c6 100644
--- a/apps/carbon/app/routes/x+/job+/$jobId.make.$methodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/job+/$jobId.make.$methodId.$materialId.tsx
@@ -101,22 +101,14 @@ export default function JobMakeMethodRoute() {
const { methodId } = useParams();
if (!methodId) throw new Error("Could not find methodId");
- const { material, materials, operations } = useLoaderData<typeof loader>();
+ const loaderData = useLoaderData<typeof loader>();
+ const { material, materials, operations } = loaderData;
return (
- <VStack spacing={2}>
- <JobMaterialForm
- key={JSON.stringify(material)}
- initialValues={material}
- operations={operations}
- />
- <JobBillOfProcess
- key={JSON.stringify(operations)}
- jobMakeMethodId={methodId}
- operations={operations}
- />
+ <VStack spacing={2} key={JSON.stringify(loaderData)}>
+ <JobMaterialForm initialValues={material} operations={operations} />
+ <JobBillOfProcess jobMakeMethodId={methodId} operations={operations} />
<JobBillOfMaterial
- key={JSON.stringify(materials)}
jobMakeMethodId={methodId}
materials={materials}
operations={operations}
diff --git a/apps/carbon/app/routes/x+/job+/$jobId.method.$methodId.tsx b/apps/carbon/app/routes/x+/job+/$jobId.method.$methodId.tsx
index 5c277e3338..65dd43d2a9 100644
--- a/apps/carbon/app/routes/x+/job+/$jobId.method.$methodId.tsx
+++ b/apps/carbon/app/routes/x+/job+/$jobId.method.$methodId.tsx
@@ -71,21 +71,16 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}
export default function JobMakeMethodRoute() {
- const { jobId, methodId } = useParams();
- if (!jobId) throw new Error("Could not find jobId");
+ const { methodId } = useParams();
if (!methodId) throw new Error("Could not find methodId");
- const { materials, operations } = useLoaderData<typeof loader>();
+ const loaderData = useLoaderData<typeof loader>();
+ const { materials, operations } = loaderData;
return (
- <VStack spacing={2}>
- <JobBillOfProcess
- jobMakeMethodId={methodId}
- operations={operations}
- key={JSON.stringify(operations)}
- />
+ <VStack spacing={2} key={JSON.stringify(loaderData)}>
+ <JobBillOfProcess jobMakeMethodId={methodId} operations={operations} />
<JobBillOfMaterial
- key={JSON.stringify(materials)}
jobMakeMethodId={methodId}
materials={materials}
operations={operations}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
index 5cffd72c21..5f74934377 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.$makeMethodId.$materialId.tsx
@@ -98,6 +98,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
export default function MethodMaterialMakePage() {
const loaderData = useLoaderData<typeof loader>();
const { item, methodMaterials, methodOperations } = loaderData;
+
const { itemId, makeMethodId, materialId } = useParams();
if (!itemId) throw new Error("Could not find itemId");
if (!makeMethodId) throw new Error("Could not find makeMethodId");
@@ -107,17 +108,17 @@ export default function MethodMaterialMakePage() {
<VStack spacing={2} className="p-2" key={JSON.stringify(loaderData)}>
<MakeMethodBreadcrumbs itemId={item.id} type="Part" />
<ItemForm
- key={JSON.stringify(item)}
+ key={`item:${itemId}:${makeMethodId}:${materialId}`}
type={item.type}
initialValues={item}
/>
<BillOfProcess
- key={JSON.stringify(methodOperations)}
+ key={`bop:${itemId}:${makeMethodId}:${materialId}`}
makeMethodId={makeMethodId}
operations={methodOperations}
/>
<BillOfMaterial
- key={JSON.stringify(methodMaterials)}
+ key={`bom:${itemId}:${makeMethodId}:${materialId}`}
makeMethodId={makeMethodId}
materials={methodMaterials}
operations={methodOperations}
diff --git a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
index c051e1f226..8c5f404b13 100644
--- a/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
+++ b/apps/carbon/app/routes/x+/part+/$itemId.manufacturing.method.tsx
@@ -123,13 +123,13 @@ export default function MakeMethodRoute() {
initialValues={manufacturingInitialValues}
/>
<BillOfProcess
- key={JSON.stringify(manufacturingRouteData?.methodOperations ?? [])}
+ key={itemId}
makeMethodId={makeMethodId}
// @ts-ignore
operations={manufacturingRouteData?.methodOperations ?? []}
/>
<BillOfMaterial
- key={JSON.stringify(manufacturingRouteData?.methodMaterials ?? [])}
+ key={itemId}
makeMethodId={makeMethodId}
// @ts-ignore
materials={manufacturingRouteData?.methodMaterials ?? []}
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
index e73b36f730..7820cd68cb 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.make.$methodId.$materialId.tsx
@@ -105,22 +105,17 @@ export default function QuoteMakeMethodRoute() {
const { methodId } = useParams();
if (!methodId) throw new Error("Could not find methodId");
- const { material, materials, operations } = useLoaderData<typeof loader>();
+ const loaderData = useLoaderData<typeof loader>();
+ const { material, materials, operations } = loaderData;
return (
- <VStack spacing={2}>
- <QuoteMaterialForm
- key={JSON.stringify(material)}
- initialValues={material}
- operations={operations}
- />
+ <VStack spacing={2} key={JSON.stringify(loaderData)}>
+ <QuoteMaterialForm initialValues={material} operations={operations} />
<QuoteBillOfProcess
- key={JSON.stringify(operations)}
quoteMakeMethodId={methodId}
operations={operations}
/>
<QuoteBillOfMaterial
- key={JSON.stringify(materials)}
quoteMakeMethodId={methodId}
materials={materials}
operations={operations}
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
index 88f5cd3bb0..4e9b17ad17 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.method.$methodId.tsx
@@ -78,17 +78,16 @@ export default function QuoteMakeMethodRoute() {
if (!lineId) throw new Error("Could not find lineId");
if (!methodId) throw new Error("Could not find methodId");
- const { materials, operations } = useLoaderData<typeof loader>();
+ const loaderData = useLoaderData<typeof loader>();
+ const { materials, operations } = loaderData;
return (
- <VStack spacing={2}>
+ <VStack spacing={2} key={JSON.stringify(loaderData)}>
<QuoteBillOfProcess
- key={JSON.stringify(operations)}
quoteMakeMethodId={methodId}
operations={operations}
/>
<QuoteBillOfMaterial
- key={JSON.stringify(materials)}
quoteMakeMethodId={methodId}
materials={materials}
operations={operations}
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index 128c181f8c..3599b7adb2 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -13,10 +13,13 @@ import type { Database } from "../lib/types.ts";
import { corsHeaders } from "../lib/headers.ts";
import {
getJobMethodTree,
+ getQuoteMethodTree,
getRatesFromSupplierProcesses,
getRatesFromWorkCenters,
JobMethodTreeItem,
+ QuoteMethodTreeItem,
traverseJobMethod,
+ traverseQuoteMethod,
} from "../lib/methods.ts";
import { getSupabaseServiceRole } from "../lib/supabase.ts";
@@ -958,46 +961,34 @@ serve(async (req: Request) => {
throw new Error("Failed to get job make method");
}
- const [jobOperations, jobParentMakeMethod] = await Promise.all([
+ const [jobOperations] = await Promise.all([
client
.from("jobOperationsWithMakeMethods")
.select("*")
.eq("jobId", jobMakeMethod.data.jobId),
- client
- .from("jobMakeMethod")
- .select("*")
- .eq("jobId", jobMakeMethod.data.jobId)
- .is("parentMaterialId", null)
- .single(),
]);
if (jobOperations.error) {
throw new Error("Failed to get job operations");
}
- if (jobParentMakeMethod.error) {
- throw new Error("Failed to get parent make method");
- }
-
const [jobMethodTrees] = await Promise.all([
- getJobMethodTree(client, jobParentMakeMethod.data.id),
+ getJobMethodTree(
+ client,
+ jobMakeMethodId,
+ jobMakeMethod.data.parentMaterialId
+ ),
]);
if (jobMethodTrees.error) {
throw new Error("Failed to get method tree");
}
- const fullJobMethodTree = jobMethodTrees.data?.[0] as JobMethodTreeItem;
- if (!fullJobMethodTree) throw new Error("Method tree not found");
-
- let jobMethodTree: JobMethodTreeItem | null = null;
+ if (jobMethodTrees.error) {
+ throw new Error("Failed to get method tree");
+ }
- traverseJobMethod(fullJobMethodTree, (node: JobMethodTreeItem) => {
- if (node.data.jobMaterialMakeMethodId === jobMakeMethodId) {
- jobMethodTree = node;
- return;
- }
- });
+ const jobMethodTree = jobMethodTrees.data?.[0] as JobMethodTreeItem;
if (!jobMethodTree) throw new Error("Job method tree not found");
const madeItemIds: string[] = [];
@@ -1353,11 +1344,17 @@ serve(async (req: Request) => {
const madeItemIds: string[] = [];
- traverseQuoteMethod(quoteMethodTree, (node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
- madeItemIds.push(node.data.itemId);
+ await traverseQuoteMethod(
+ quoteMethodTree,
+ (node: QuoteMethodTreeItem) => {
+ if (node.data.itemId && node.data.methodType === "Make") {
+ console.log(`Adding item ID: ${node.data.itemId}`);
+ madeItemIds.push(node.data.itemId);
+ }
}
- });
+ );
+
+ console.log({ madeItemIds });
const makeMethods = await client
.from("makeMethod")
@@ -1379,28 +1376,31 @@ serve(async (req: Request) => {
const operationInserts: Database["public"]["Tables"]["methodOperation"]["Insert"][] =
[];
- traverseQuoteMethod(quoteMethodTree, (node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
- makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
- }
+ await traverseQuoteMethod(
+ quoteMethodTree,
+ (node: QuoteMethodTreeItem) => {
+ if (node.data.itemId && node.data.methodType === "Make") {
+ makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
+ }
- node.children.forEach((child) => {
- materialInserts.push({
- makeMethodId: makeMethodByItemId[node.data.itemId],
- materialMakeMethodId: makeMethodByItemId[child.data.itemId],
- itemId: child.data.itemId,
- itemReadableId: child.data.itemReadableId,
- itemType: child.data.itemType,
- methodType: child.data.methodType,
- order: child.data.order,
- quantity: child.data.quantity,
- unitOfMeasureCode: child.data.unitOfMeasureCode,
- companyId,
- createdBy: userId,
- customFields: {},
+ node.children.forEach((child) => {
+ materialInserts.push({
+ makeMethodId: makeMethodByItemId[node.data.itemId],
+ materialMakeMethodId: makeMethodByItemId[child.data.itemId],
+ itemId: child.data.itemId,
+ itemReadableId: child.data.itemReadableId,
+ itemType: child.data.itemType,
+ methodType: child.data.methodType,
+ order: child.data.order,
+ quantity: child.data.quantity,
+ unitOfMeasureCode: child.data.unitOfMeasureCode,
+ companyId,
+ createdBy: userId,
+ customFields: {},
+ });
});
- });
- });
+ }
+ );
if (makeMethodsToDelete.length > 0) {
makeMethodsToDelete = makeMethodsToDelete.map((mm) =>
@@ -1685,51 +1685,36 @@ serve(async (req: Request) => {
throw new Error("Failed to get quote make method");
}
- const [quoteOperations, quoteParentMakeMethod] = await Promise.all([
+ const [quoteOperations] = await Promise.all([
client
.from("quoteOperationsWithMakeMethods")
.select("*")
.eq("quoteLineId", quoteMakeMethod.data.quoteLineId),
- client
- .from("quoteMakeMethod")
- .select("*")
- .eq("quoteLineId", quoteMakeMethod.data.quoteLineId)
- .is("parentMaterialId", null)
- .single(),
]);
if (quoteOperations.error) {
throw new Error("Failed to get quote operations");
}
- if (quoteParentMakeMethod.error) {
- throw new Error("Failed to get parent make method");
- }
-
const [quoteMethodTrees] = await Promise.all([
- getQuoteMethodTree(client, quoteParentMakeMethod.data.id),
+ getQuoteMethodTree(
+ client,
+ quoteMakeMethodId,
+ quoteMakeMethod.data.parentMaterialId
+ ),
]);
if (quoteMethodTrees.error) {
throw new Error("Failed to get method tree");
}
- const fullQuoteMethodTree = quoteMethodTrees
- .data?.[0] as QuoteMethodTreeItem;
- if (!fullQuoteMethodTree) throw new Error("Method tree not found");
-
- let quoteMethodTree: QuoteMethodTreeItem | null = null;
+ if (quoteMethodTrees.error) {
+ throw new Error("Failed to get method tree");
+ }
- traverseQuoteMethod(
- fullQuoteMethodTree,
- (node: QuoteMethodTreeItem) => {
- if (node.data.quoteMaterialMakeMethodId === quoteMakeMethodId) {
- quoteMethodTree = node;
- return;
- }
- }
- );
- if (!quoteMethodTree) throw new Error("Quote method tree not found");
+ const quoteMethodTree = quoteMethodTrees
+ .data?.[0] as QuoteMethodTreeItem;
+ if (!quoteMethodTree) throw new Error("Job method tree not found");
const madeItemIds: string[] = [];
@@ -1759,28 +1744,31 @@ serve(async (req: Request) => {
const operationInserts: Database["public"]["Tables"]["methodOperation"]["Insert"][] =
[];
- traverseQuoteMethod(quoteMethodTree!, (node: QuoteMethodTreeItem) => {
- if (node.data.itemId && node.data.methodType === "Make") {
- makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
- }
+ await traverseQuoteMethod(
+ quoteMethodTree!,
+ (node: QuoteMethodTreeItem) => {
+ if (node.data.itemId && node.data.methodType === "Make") {
+ makeMethodsToDelete.push(makeMethodByItemId[node.data.itemId]);
+ }
- node.children.forEach((child) => {
- materialInserts.push({
- makeMethodId: makeMethodByItemId[node.data.itemId],
- materialMakeMethodId: makeMethodByItemId[child.data.itemId],
- itemId: child.data.itemId,
- itemReadableId: child.data.itemReadableId,
- itemType: child.data.itemType,
- methodType: child.data.methodType,
- order: child.data.order,
- quantity: child.data.quantity,
- unitOfMeasureCode: child.data.unitOfMeasureCode,
- companyId,
- createdBy: userId,
- customFields: {},
+ node.children.forEach((child) => {
+ materialInserts.push({
+ makeMethodId: makeMethodByItemId[node.data.itemId],
+ materialMakeMethodId: makeMethodByItemId[child.data.itemId],
+ itemId: child.data.itemId,
+ itemReadableId: child.data.itemReadableId,
+ itemType: child.data.itemType,
+ methodType: child.data.methodType,
+ order: child.data.order,
+ quantity: child.data.quantity,
+ unitOfMeasureCode: child.data.unitOfMeasureCode,
+ companyId,
+ createdBy: userId,
+ customFields: {},
+ });
});
- });
- });
+ }
+ );
if (makeMethodsToDelete.length > 0) {
makeMethodsToDelete = makeMethodsToDelete.map((mm) =>
@@ -1954,89 +1942,3 @@ function getMethodTreeArrayToTree(items: Method[]): MethodTreeItem[] {
return rootItems.map((item) => traverseAndRenameIds(item));
}
-
-type QuoteMethod = NonNullable<
- Awaited<ReturnType<typeof getQuoteMethodTreeArray>>["data"]
->[number];
-type QuoteMethodTreeItem = {
- id: string;
- data: QuoteMethod;
- children: QuoteMethodTreeItem[];
-};
-
-export async function getQuoteMethodTree(
- client: SupabaseClient<Database>,
- methodId: string
-) {
- const items = await getQuoteMethodTreeArray(client, methodId);
- if (items.error) return items;
-
- const tree = getQuoteMethodTreeArrayToTree(items.data);
-
- return {
- data: tree,
- error: null,
- };
-}
-
-export function getQuoteMethodTreeArray(
- client: SupabaseClient<Database>,
- methodId: string
-) {
- return client.rpc("get_quote_methods_by_method_id", {
- mid: methodId,
- });
-}
-
-function getQuoteMethodTreeArrayToTree(
- items: QuoteMethod[]
-): QuoteMethodTreeItem[] {
- // function traverseAndRenameIds(node: QuoteMethodTreeItem) {
- // const clone = structuredClone(node);
- // clone.id = `node-${Math.random().toString(16).slice(2)}`;
- // clone.children = clone.children.map((n) => traverseAndRenameIds(n));
- // return clone;
- // }
-
- const rootItems: QuoteMethodTreeItem[] = [];
- const lookup: { [id: string]: QuoteMethodTreeItem } = {};
-
- for (const item of items) {
- const itemId = item.methodMaterialId;
- const parentId = item.parentMaterialId;
-
- if (!Object.prototype.hasOwnProperty.call(lookup, itemId)) {
- // @ts-ignore - we don't add data here
- lookup[itemId] = { id: itemId, children: [] };
- }
-
- lookup[itemId]["data"] = item;
-
- const treeItem = lookup[itemId];
-
- if (parentId === null || parentId === undefined) {
- rootItems.push(treeItem);
- } else {
- if (!Object.prototype.hasOwnProperty.call(lookup, parentId)) {
- // @ts-ignore - we don't add data here
- lookup[parentId] = { id: parentId, children: [] };
- }
-
- lookup[parentId]["children"].push(treeItem);
- }
- }
- return rootItems;
-}
-
-async function traverseQuoteMethod(
- node: QuoteMethodTreeItem,
- callback: (node: QuoteMethodTreeItem) => void | Promise<void>
-) {
- await callback(node);
-
- if (node.children) {
- for await (const child of node.children) {
- traverseQuoteMethod(child, callback);
- }
- }
-}
diff --git a/packages/database/supabase/functions/lib/methods.ts b/packages/database/supabase/functions/lib/methods.ts
index 38a1f87ccc..033ddb76cf 100644
--- a/packages/database/supabase/functions/lib/methods.ts
+++ b/packages/database/supabase/functions/lib/methods.ts
@@ -90,6 +90,89 @@ export function traverseJobMethod(
}
}
+export type QuoteMethod = NonNullable<
+ Awaited<ReturnType<typeof getQuoteMethodTreeArray>>["data"]
+>[number];
+export type QuoteMethodTreeItem = {
+ id: string;
+ data: QuoteMethod;
+ children: QuoteMethodTreeItem[];
+};
+
+export async function getQuoteMethodTree(
+ client: SupabaseClient<Database>,
+ methodId: string,
+ parentMaterialId: string | null = null
+) {
+ const items = await getQuoteMethodTreeArray(client, methodId);
+ if (items.error) return items;
+
+ const tree = getQuoteMethodTreeArrayToTree(items.data, parentMaterialId);
+
+ return {
+ data: tree,
+ error: null,
+ };
+}
+
+export function getQuoteMethodTreeArray(
+ client: SupabaseClient<Database>,
+ methodId: string
+) {
+ return client.rpc("get_quote_methods_by_method_id", {
+ mid: methodId,
+ });
+}
+
+function getQuoteMethodTreeArrayToTree(
+ items: QuoteMethod[],
+ parentMaterialId: string | null = null
+): QuoteMethodTreeItem[] {
+ const rootItems: QuoteMethodTreeItem[] = [];
+ const lookup: { [id: string]: QuoteMethodTreeItem } = {};
+
+ for (const item of items) {
+ const itemId = item.methodMaterialId;
+ const parentId = item.parentMaterialId;
+
+ if (!Object.prototype.hasOwnProperty.call(lookup, itemId)) {
+ lookup[itemId] = { id: itemId, children: [], data: item };
+ } else {
+ lookup[itemId].data = item;
+ }
+
+ const treeItem = lookup[itemId];
+
+ if (parentId === parentMaterialId || parentId === undefined) {
+ rootItems.push(treeItem);
+ } else {
+ if (!Object.prototype.hasOwnProperty.call(lookup, parentId)) {
+ lookup[parentId] = {
+ id: parentId,
+ children: [],
+ data: {} as QuoteMethod,
+ };
+ }
+
+ lookup[parentId].children.push(treeItem);
+ }
+ }
+ return rootItems;
+}
+
+export async function traverseQuoteMethod(
+ node: QuoteMethodTreeItem,
+ callback: (node: QuoteMethodTreeItem) => void | Promise<void>
+) {
+ await callback(node);
+
+ if (node.children) {
+ for await (const child of node.children) {
+ traverseQuoteMethod(child, callback);
+ }
+ }
+}
+
export const getRatesFromWorkCenters =
(workCenters: Database["public"]["Views"]["workCenters"]["Row"][] | null) =>
(
diff --git a/packages/react/src/Card.tsx b/packages/react/src/Card.tsx
index 63d17c63b6..99ea5b470b 100644
--- a/packages/react/src/Card.tsx
+++ b/packages/react/src/Card.tsx
@@ -31,7 +31,7 @@ const Card = forwardRef<HTMLDivElement, CardProps>(
<div
ref={ref}
className={cn(
- "relative flex flex-col rounded-lg border border-border shadow-md dark:border-0 dark:shadow-[0px_1px_0px_0px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_rgba(0,0,0,.1),0px_2px_2px_0px_rgba(0,0,0,.1),0px_4px_4px_0px_rgba(0,0,0,.1),0px_8px_8px_0px_rgba(0,0,0,.1)] bg-gradient-to-bl from-card via-card to-background text-card-foreground w-full",
+ "relative flex flex-col rounded-lg border border-border dark:border-0 dark:shadow-[0px_1px_0px_0px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_rgba(0,0,0,.1),0px_2px_2px_0px_rgba(0,0,0,.1),0px_4px_4px_0px_rgba(0,0,0,.1),0px_8px_8px_0px_rgba(0,0,0,.1)] bg-gradient-to-bl from-card via-card to-background text-card-foreground w-full",
className
)}
{...props}
diff --git a/packages/react/src/Menubar.tsx b/packages/react/src/Menubar.tsx
index aa94ac1aaa..877f3ec02c 100644
--- a/packages/react/src/Menubar.tsx
+++ b/packages/react/src/Menubar.tsx
@@ -10,7 +10,7 @@ const Menubar = forwardRef<HTMLDivElement, ComponentProps<"div">>(
<div
{...props}
className={cn(
- "min-h-[2.5rem] flex items-center bg-card border border-border shadow-sm dark:border-0 dark:shadow-[0px_1px_0px_0px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_rgba(0,0,0,.1),0px_2px_2px_0px_rgba(0,0,0,.1),0px_4px_4px_0px_rgba(0,0,0,.1),0px_8px_8px_0px_rgba(0,0,0,.1)] rounded-lg justify-start p-1 w-full space-x-1 overflow-x-scroll scrollbar-hide",
+ "min-h-[2.5rem] flex items-center bg-card border border-border dark:border-0 dark:shadow-[0px_1px_0px_0px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_rgba(0,0,0,.1),0px_2px_2px_0px_rgba(0,0,0,.1),0px_4px_4px_0px_rgba(0,0,0,.1),0px_8px_8px_0px_rgba(0,0,0,.1)] rounded-lg justify-start p-1 w-full space-x-1 overflow-x-scroll scrollbar-hide",
className
)}
>