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.

feat: get method operations

Brad Barbinafd70f510b70
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
index b4ab96e934..db90bfceb9 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBoMExplorer.tsx
@@ -1,5 +1,5 @@
-import { Badge, HStack, VStack, cn } from "@carbon/react";
-import { useNavigate } from "@remix-run/react";
+import { Badge, HStack, Spinner, VStack, cn } from "@carbon/react";
+import { useFetchers, useNavigate } from "@remix-run/react";
import { useRef } from "react";
import { LuChevronDown, LuChevronUp } from "react-icons/lu";
import type { FlatTree, FlatTreeItem } from "~/components/TreeView";
@@ -18,6 +18,16 @@ const QuoteBoMExplorer = ({ methods }: QuoteBoMExplorerProps) => {
const navigate = useNavigate();
const location = useOptimisticLocation();
+ const fetchers = useFetchers();
+ const getMethodFetcher = fetchers.find(
+ (f) => f.formAction === path.to.quoteMethodGet
+ );
+
+ const isLoading =
+ getMethodFetcher?.state === "loading" &&
+ getMethodFetcher.formData?.get("quoteLineId") ===
+ methods?.[0].data.quoteLineId;
+
const {
nodes,
getTreeProps,
@@ -41,90 +51,96 @@ const QuoteBoMExplorer = ({ methods }: QuoteBoMExplorerProps) => {
return (
<VStack className="p-2">
- <TreeView
- parentRef={parentRef}
- virtualizer={virtualizer}
- autoFocus
- tree={methods}
- nodes={nodes}
- getNodeProps={getNodeProps}
- getTreeProps={getTreeProps}
- renderNode={({ node, state }) => (
- <div
- key={node.id}
- className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
- getNodePath(node) === location.pathname
- ? "bg-muted hover:bg-muted/90"
- : "bg-transparent hover:bg-muted/90"
- )}
- onClick={(e) => {
- e.stopPropagation();
- navigate(getNodePath(node));
- }}
- >
- <div className="flex h-8 items-center">
- {Array.from({ length: node.level }).map((_, index) => (
- <LevelLine
- key={index}
- isSelected={getNodePath(node) === location.pathname}
- />
- ))}
- <div
- className={cn(
- "flex h-8 w-4 items-center",
- node.hasChildren && "hover:bg-accent"
- )}
- onClick={(e) => {
- e.stopPropagation();
- if (e.altKey) {
- if (state.expanded) {
- collapseAllBelowDepth(node.level);
+ {isLoading ? (
+ <div className="flex items-center justify-center py-8 w-full">
+ <Spinner className="w-4 h-4" />
+ </div>
+ ) : (
+ <TreeView
+ parentRef={parentRef}
+ virtualizer={virtualizer}
+ autoFocus
+ tree={methods}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ renderNode={({ node, state }) => (
+ <div
+ key={node.id}
+ className={cn(
+ "flex h-8 cursor-pointer items-center overflow-hidden rounded-sm pr-2",
+ getNodePath(node) === location.pathname
+ ? "bg-muted hover:bg-muted/90"
+ : "bg-transparent hover:bg-muted/90"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ navigate(getNodePath(node));
+ }}
+ >
+ <div className="flex h-8 items-center">
+ {Array.from({ length: node.level }).map((_, index) => (
+ <LevelLine
+ key={index}
+ isSelected={getNodePath(node) === location.pathname}
+ />
+ ))}
+ <div
+ className={cn(
+ "flex h-8 w-4 items-center",
+ node.hasChildren && "hover:bg-accent"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (e.altKey) {
+ if (state.expanded) {
+ collapseAllBelowDepth(node.level);
+ } else {
+ expandAllBelowDepth(node.level);
+ }
} else {
- expandAllBelowDepth(node.level);
+ toggleExpandNode(node.id);
}
- } else {
- toggleExpandNode(node.id);
- }
- scrollToNode(node.id);
- }}
- >
- {node.hasChildren ? (
- state.expanded ? (
- <LuChevronDown className="h-4 w-4 text-gray-400" />
+ scrollToNode(node.id);
+ }}
+ >
+ {node.hasChildren ? (
+ state.expanded ? (
+ <LuChevronDown className="h-4 w-4 text-gray-400" />
+ ) : (
+ <LuChevronUp className="h-4 w-4 text-gray-400" />
+ )
) : (
- <LuChevronUp className="h-4 w-4 text-gray-400" />
- )
- ) : (
- <div className="h-8 w-4" />
- )}
+ <div className="h-8 w-4" />
+ )}
+ </div>
</div>
- </div>
- <div className="flex w-full items-center justify-between gap-2">
- <div className="flex items-center gap-2 overflow-x-hidden">
- <MethodIcon
- type={
- // node.data.isRoot ? "Method" :
- node.data.methodType
- }
- className="h-4 min-h-4 w-4 min-w-4 flex-shrink-0"
- />
- <NodeText node={node} />
- </div>
- <div className="flex items-center gap-1">
- {node.data.isRoot ? (
- <Badge variant="outline" className="text-xs">
- Method
- </Badge>
- ) : (
- <NodeData node={node} />
- )}
+ <div className="flex w-full items-center justify-between gap-2">
+ <div className="flex items-center gap-2 overflow-x-hidden">
+ <MethodIcon
+ type={
+ // node.data.isRoot ? "Method" :
+ node.data.methodType
+ }
+ className="h-4 min-h-4 w-4 min-w-4 flex-shrink-0"
+ />
+ <NodeText node={node} />
+ </div>
+ <div className="flex items-center gap-1">
+ {node.data.isRoot ? (
+ <Badge variant="outline" className="text-xs">
+ Method
+ </Badge>
+ ) : (
+ <NodeData node={node} />
+ )}
+ </div>
</div>
</div>
- </div>
- )}
- />
+ )}
+ />
+ )}
</VStack>
);
};
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx
index 46eb07bcce..e9354d2db9 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBreadcrumbs.tsx
@@ -1,76 +1,161 @@
-import { Button, HStack, Menubar, MenubarItem } from "@carbon/react";
+import {
+ Alert,
+ Button,
+ HStack,
+ Menubar,
+ MenubarItem,
+ Modal,
+ ModalBody,
+ ModalContent,
+ ModalDescription,
+ ModalFooter,
+ ModalHeader,
+ ModalTitle,
+ toast,
+ useDisclosure,
+ VStack,
+} from "@carbon/react";
+import { ValidatedForm } from "@carbon/remix-validated-form";
import { Link, useFetcher, useLocation, useParams } from "@remix-run/react";
+import { useEffect } from "react";
import { LuDownload, LuUpload } from "react-icons/lu";
import { RiProgress4Line } from "react-icons/ri";
+import { z } from "zod";
import { BreadcrumbItem, Breadcrumbs } from "~/components";
+import { Hidden, Item, Submit } from "~/components/Form";
+import type { Tree } from "~/components/TreeView";
import { usePermissions, useRouteData } from "~/hooks";
import { path } from "~/utils/path";
-import type { Quotation, QuotationLine } from "../../types";
+import type { Quotation, QuotationLine, QuoteMethod } from "../../types";
+
+const getMethodValidator = z.object({
+ itemId: z.string().min(1, { message: "Please select a source method" }),
+ quoteId: z.string(),
+ quoteLineId: z.string(),
+});
const QuoteBreadcrumbs = () => {
const permissions = usePermissions();
- const { quoteId, lineId, makeMethodId } = useParams();
+ const { quoteId, lineId } = useParams();
if (!quoteId) throw new Error("quoteId not found");
- const fetcher = useFetcher<{ error: null | { message: string } }>();
- const routeData = useRouteData<{ quote: Quotation; lines: QuotationLine[] }>(
- path.to.quote(quoteId)
- );
+ const fetcher = useFetcher<{ error: string | null }>();
+ const routeData = useRouteData<{
+ quote: Quotation;
+ lines: QuotationLine[];
+ methods: Tree<QuoteMethod>[];
+ }>(path.to.quote(quoteId));
const line = routeData?.lines.find((line) => line.id === lineId);
const { pathname } = useLocation();
- const getMethod = async (itemId: string, quoteLineId: string) => {
- const formData = new FormData();
- formData.append("itemId", itemId);
- formData.append("quoteId", quoteId);
- formData.append("quoteLineId", quoteLineId);
+ const methodTree = routeData?.methods.find(
+ (m) => m.data.quoteLineId === line?.id
+ );
+ const hasMethods = methodTree?.children && methodTree.children.length > 0;
+
+ const isGetMethodLoading =
+ fetcher.state !== "idle" && fetcher.formAction === path.to.quoteMethodGet;
+
+ useEffect(() => {
+ if (fetcher.data?.error) {
+ toast.error(fetcher.data.error);
+ }
+ }, [fetcher.data?.error]);
- fetcher.submit(formData, {
- method: "post",
- action: path.to.quoteMethodGet,
- });
- };
+ const getMethodModal = useDisclosure();
return (
- <Menubar>
- <HStack className="w-full justify-between">
- <Breadcrumbs>
- <BreadcrumbItem>
- <Button leftIcon={<RiProgress4Line />} variant="ghost" asChild>
- <Link to={path.to.quoteDetails(quoteId)}>
- {routeData?.quote?.quoteId}
- </Link>
- </Button>
- </BreadcrumbItem>
- {line && (
+ <>
+ <Menubar>
+ <HStack className="w-full justify-between">
+ <Breadcrumbs>
<BreadcrumbItem>
- <Button variant="ghost" asChild>
- <Link to={path.to.quoteLine(quoteId, line.id!)}>
- {line.itemReadableId}
+ <Button leftIcon={<RiProgress4Line />} variant="ghost" asChild>
+ <Link to={path.to.quoteDetails(quoteId)}>
+ {routeData?.quote?.quoteId}
</Link>
</Button>
</BreadcrumbItem>
- )}
- </Breadcrumbs>
- {line &&
- permissions.can("update", "sales") &&
- pathname === path.to.quoteLine(quoteId, lineId!) && (
- <HStack spacing={0}>
- <MenubarItem
- leftIcon={<LuDownload />}
- isLoading={
- fetcher.state !== "idle" &&
- fetcher.formAction === path.to.quoteMethodGet
- }
- onClick={() => getMethod(line.itemId!, line.id!)}
- >
- Get Method
- </MenubarItem>
- <MenubarItem leftIcon={<LuUpload />}>Save Method</MenubarItem>
- </HStack>
- )}
- </HStack>
- </Menubar>
+ {line && (
+ <BreadcrumbItem>
+ <Button variant="ghost" asChild>
+ <Link to={path.to.quoteLine(quoteId, line.id!)}>
+ {line.itemReadableId}
+ </Link>
+ </Button>
+ </BreadcrumbItem>
+ )}
+ </Breadcrumbs>
+ {line &&
+ permissions.can("update", "sales") &&
+ pathname === path.to.quoteLine(quoteId, lineId!) && (
+ <HStack spacing={0}>
+ <MenubarItem
+ leftIcon={<LuDownload />}
+ isLoading={isGetMethodLoading}
+ isDisabled={isGetMethodLoading}
+ onClick={getMethodModal.onOpen}
+ >
+ Get Method
+ </MenubarItem>
+ <MenubarItem leftIcon={<LuUpload />}>Save Method</MenubarItem>
+ </HStack>
+ )}
+ </HStack>
+ </Menubar>
+ {getMethodModal.isOpen && (
+ <Modal
+ open
+ onOpenChange={(open) => {
+ if (!open) {
+ getMethodModal.onClose();
+ }
+ }}
+ >
+ <ModalContent>
+ <ValidatedForm
+ method="post"
+ fetcher={fetcher}
+ action={path.to.quoteMethodGet}
+ validator={getMethodValidator}
+ onSubmit={getMethodModal.onClose}
+ >
+ <ModalHeader>
+ <ModalTitle>Get Method</ModalTitle>
+ <ModalDescription>
+ Overwrite the quote method with the source method
+ </ModalDescription>
+ </ModalHeader>
+ <ModalBody>
+ <Hidden name="quoteId" value={quoteId} />
+ <Hidden name="quoteLineId" value={lineId} />
+ <VStack spacing={4}>
+ <Item
+ name="itemId"
+ label="Source Method"
+ type="Part"
+ replenishmentSystem="Make"
+ />
+ {hasMethods && (
+ <Alert variant="destructive">
+ This will overwrite the existing quote method
+ </Alert>
+ )}
+ </VStack>
+ </ModalBody>
+ <ModalFooter>
+ <Button onClick={getMethodModal.onClose} variant="secondary">
+ Cancel
+ </Button>
+ <Submit variant={hasMethods ? "destructive" : "primary"}>
+ Confirm
+ </Submit>
+ </ModalFooter>
+ </ValidatedForm>
+ </ModalContent>
+ </Modal>
+ )}
+ </>
);
};
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
index 7b2b11452d..a091174101 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
@@ -347,7 +347,7 @@ const QuoteLinePricing = ({
<span className="flex items-center justify-start gap-2">
Markup Percent
<Tooltip>
- <TooltipTrigger>
+ <TooltipTrigger tabIndex={-1}>
<LuInfo className="w-4 h-4" />
</TooltipTrigger>
<TooltipContent>(Price - Cost) / Cost</TooltipContent>
@@ -481,7 +481,7 @@ const QuoteLinePricing = ({
<span className="flex items-center justify-start gap-2">
Profit Percent
<Tooltip>
- <TooltipTrigger>
+ <TooltipTrigger tabIndex={-1}>
<LuInfo className="w-4 h-4" />
</TooltipTrigger>
<TooltipContent>(Price - Cost) / Price</TooltipContent>
diff --git a/apps/carbon/app/modules/shared/ui/RealtimeDataProvider.tsx b/apps/carbon/app/modules/shared/ui/RealtimeDataProvider.tsx
index 470c2f7fa7..8da2a0f226 100644
--- a/apps/carbon/app/modules/shared/ui/RealtimeDataProvider.tsx
+++ b/apps/carbon/app/modules/shared/ui/RealtimeDataProvider.tsx
@@ -46,7 +46,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
.from("item")
.select("id, readableId, name, type, replenishmentSystem, active")
.eq("companyId", companyId)
- .order("name"),
+ .order("readableId"),
supabase
.from("supplier")
.select("id, name")
@@ -121,7 +121,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
type: inserted.type,
active: inserted.active,
},
- ].sort((a, b) => a.name.localeCompare(b.name))
+ ].sort((a, b) => a.readableId.localeCompare(b.readableId))
);
break;
@@ -143,7 +143,7 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
}
return i;
})
- .sort((a, b) => a.name.localeCompare(b.name))
+ .sort((a, b) => a.readableId.localeCompare(b.readableId))
);
break;
case "DELETE":
diff --git a/apps/carbon/app/routes/x+/quote+/methods.get.tsx b/apps/carbon/app/routes/x+/quote+/methods.get.tsx
index ba71708513..c056e02d15 100644
--- a/apps/carbon/app/routes/x+/quote+/methods.get.tsx
+++ b/apps/carbon/app/routes/x+/quote+/methods.get.tsx
@@ -17,20 +17,17 @@ export async function action({ request }: ActionFunctionArgs) {
}
const supabaseServiceRole = getSupabaseServiceRole();
- const { data, error } = await supabaseServiceRole.functions.invoke(
- "get-method",
- {
- body: {
- type: "quote",
- sourceId: itemId,
- targetId: `${quoteId}:${quoteLineId}`,
- companyId,
- userId,
- },
- }
- );
-
- console.log({ data, error });
+ const { error } = await supabaseServiceRole.functions.invoke("get-method", {
+ body: {
+ type: "quote",
+ sourceId: itemId,
+ targetId: `${quoteId}:${quoteLineId}`,
+ companyId,
+ userId,
+ },
+ });
- return null;
+ return {
+ error: error ? "Failed to get method" : null,
+ };
}
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index ce97440754..532f8d7bff 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -25607,6 +25607,9 @@ export type Database = {
itemId: string
itemReadableId: string
itemType: string
+ description: string
+ unitOfMeasureCode: string
+ unitCost: number
quantity: number
methodType: Database["public"]["Enums"]["methodType"]
parentMaterialId: string
diff --git a/packages/database/supabase/functions/get-method/index.ts b/packages/database/supabase/functions/get-method/index.ts
index 975893913d..18951efb3c 100644
--- a/packages/database/supabase/functions/get-method/index.ts
+++ b/packages/database/supabase/functions/get-method/index.ts
@@ -110,51 +110,51 @@ serve(async (req: Request) => {
(child) => child.data.methodType !== "Make"
);
- // const relatedOperations = await client
- // .from("methodOperation")
- // .select("*")
- // .eq("makeMethodId", node.data.makeMethodId);
-
- // const quoteOperations =
- // relatedOperations?.data?.map((op) => ({
- // quoteId,
- // quoteLineId,
- // quoteMakeMethodId: parentQuoteMakeMethodId!,
- // workCellTypeId: op.workCellTypeId,
- // equipmentTypeId: op.equipmentTypeId,
- // description: op.description,
- // setupHours: op.setupHours,
- // standardFactor: op.standardFactor,
- // productionStandard: op.productionStandard,
- // quotingRate: 0, // TODO
- // laborRate: 0, // TODO
- // overheadRate: 0, // TODO
- // order: op.order,
- // operationOrder: op.operationOrder,
- // companyId,
- // createdBy: userId,
- // customFields: {},
- // })) ?? [];
-
- // let methodOperationsToQuoteOperations: Record<string, string> = {};
- // if (quoteOperations?.length > 0) {
- // const operationIds = await trx
- // .insertInto("quoteOperation")
- // .values(quoteOperations)
- // .returning(["id"])
- // .execute();
-
- // methodOperationsToQuoteOperations =
- // relatedOperations.data?.reduce<Record<string, string>>(
- // (acc, op, index) => {
- // if (operationIds[index].id) {
- // acc[op.id!] = operationIds[index].id!;
- // }
- // return acc;
- // },
- // {}
- // ) ?? {};
- // }
+ const relatedOperations = await client
+ .from("methodOperation")
+ .select("*, workCellType(quotingRate, laborRate, overheadRate)")
+ .eq("makeMethodId", node.data.materialMakeMethodId);
+
+ const quoteOperations =
+ relatedOperations?.data?.map((op) => ({
+ quoteId,
+ quoteLineId,
+ quoteMakeMethodId: parentQuoteMakeMethodId!,
+ workCellTypeId: op.workCellTypeId,
+ equipmentTypeId: op.equipmentTypeId,
+ description: op.description,
+ setupHours: op.setupHours,
+ standardFactor: op.standardFactor,
+ productionStandard: op.productionStandard,
+ quotingRate: op.workCellType?.quotingRate ?? 0,
+ laborRate: op.workCellType?.laborRate ?? 0,
+ overheadRate: op.workCellType?.overheadRate ?? 0,
+ order: op.order,
+ operationOrder: op.operationOrder,
+ companyId,
+ createdBy: userId,
+ customFields: {},
+ })) ?? [];
+
+ let methodOperationsToQuoteOperations: Record<string, string> = {};
+ if (quoteOperations?.length > 0) {
+ const operationIds = await trx
+ .insertInto("quoteOperation")
+ .values(quoteOperations)
+ .returning(["id"])
+ .execute();
+
+ methodOperationsToQuoteOperations =
+ relatedOperations.data?.reduce<Record<string, string>>(
+ (acc, op, index) => {
+ if (operationIds[index].id) {
+ acc[op.id!] = operationIds[index].id!;
+ }
+ return acc;
+ },
+ {}
+ ) ?? {};
+ }
const mapMethodMaterialToQuoteMaterial = (
child: MethodTreeItem
@@ -168,10 +168,10 @@ serve(async (req: Request) => {
methodType: child.data.methodType,
// operation: methodOperationsToQuoteOperations[child.data.operationId], // TODO
order: child.data.order,
- description: "", // TODO
+ description: child.data.description,
quantity: child.data.quantity,
- unitOfMeasureCode: "EA", // TODO
- unitCost: 0, // TODO
+ unitOfMeasureCode: child.data.unitOfMeasureCode,
+ unitCost: child.data.unitCost,
companyId,
createdBy: userId,
customFields: {},
@@ -201,7 +201,6 @@ serve(async (req: Request) => {
.execute();
for (const [index, child] of madeChildren.entries()) {
- // insert quoteMakeMethod for child
const makeMethodId = quoteMakeMethods[index].id ?? null;
await traverseMethodToQuote(child, makeMethodId);
}
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index ce97440754..532f8d7bff 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -25607,6 +25607,9 @@ export type Database = {
itemId: string
itemReadableId: string
itemType: string
+ description: string
+ unitOfMeasureCode: string
+ unitCost: number
quantity: number
methodType: Database["public"]["Enums"]["methodType"]
parentMaterialId: string
diff --git a/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql b/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql
new file mode 100644
index 0000000000..3ccb6ec56f
--- /dev/null
+++ b/packages/database/supabase/migrations/20240807112857_add-description-unit-cost-to-method-tree.sql
@@ -0,0 +1,93 @@
+DROP FUNCTION get_method_tree;
+CREATE OR REPLACE FUNCTION get_method_tree(uid TEXT)
+RETURNS TABLE (
+ "methodMaterialId" TEXT,
+ "makeMethodId" TEXT,
+ "materialMakeMethodId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "itemType" TEXT,
+ "description" TEXT,
+ "unitOfMeasureCode" TEXT,
+ "unitCost" NUMERIC,
+ "quantity" NUMERIC,
+ "methodType" "methodType",
+ "parentMaterialId" TEXT,
+ "order" DOUBLE PRECISION,
+ "isRoot" BOOLEAN
+) AS $$
+WITH RECURSIVE material AS (
+ SELECT
+ "id",
+ "makeMethodId",
+ "methodType",
+ "materialMakeMethodId",
+ "itemId",
+ "itemType",
+ "quantity",
+ "makeMethodId" AS "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order"
+ FROM
+ "methodMaterial"
+ WHERE
+ "makeMethodId" = uid
+ UNION
+ SELECT
+ child."id",
+ child."makeMethodId",
+ child."methodType",
+ child."materialMakeMethodId",
+ child."itemId",
+ child."itemType",
+ child."quantity",
+ parent."id" AS "parentMaterialId",
+ child."order"
+ FROM
+ "methodMaterial" child
+ INNER JOIN material parent ON parent."materialMakeMethodId" = child."makeMethodId"
+)
+SELECT
+ material.id as "methodMaterialId",
+ material."makeMethodId",
+ material."materialMakeMethodId",
+ material."itemId",
+ item."readableId" AS "itemReadableId",
+ material."itemType",
+ item."name" AS "description",
+ item."unitOfMeasureCode",
+ cost."unitCost",
+ material."quantity",
+ material."methodType",
+ material."parentMaterialId",
+ material."order",
+ false AS "isRoot"
+FROM material
+INNER JOIN item
+ ON material."itemId" = item.id
+INNER JOIN "itemCost" cost
+ ON item.id = cost."itemId"
+UNION
+SELECT
+ mm."id" AS "methodMaterialId",
+ NULL AS "makeMethodId",
+ mm.id AS "materialMakeMethodId",
+ mm."itemId",
+ item."readableId" AS "itemReadableId",
+ item."type"::text,
+ item."name" AS "description",
+ item."unitOfMeasureCode",
+ cost."unitCost",
+ 1 AS "quantity",
+ 'Make' AS "methodType",
+ NULL AS "parentMaterialId",
+ CAST(1 AS DOUBLE PRECISION) AS "order",
+ true AS "isRoot"
+
+FROM "makeMethod" mm
+INNER JOIN item
+ ON mm."itemId" = item.id
+INNER JOIN "itemCost" cost
+ ON item.id = cost."itemId"
+WHERE mm.id = uid
+ORDER BY "order"
+$$ LANGUAGE sql STABLE;
\ No newline at end of file
diff --git a/packages/react/src/Alert.tsx b/packages/react/src/Alert.tsx
index bca007049f..d0b92e84d4 100644
--- a/packages/react/src/Alert.tsx
+++ b/packages/react/src/Alert.tsx
@@ -10,8 +10,10 @@ const alertVariants = cva(
variants: {
variant: {
default: "bg-background text-foreground",
+ success:
+ "bg-gradient-to-r dark:from-emerald-600/60 dark:via-card dark:to-card from-emerald-100 to-emerald-100 border-emerald-600 text-emerald-600 [&>svg]:text-emerald-600 dark:text-foreground dark:[&>svg]:text-foreground",
destructive:
- "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
+ "bg-gradient-to-r dark:from-destructive/60 dark:via-card dark:to-card from-destructive/10 to-destructive/10 border-destructive text-destructive [&>svg]:text-destructive dark:text-foreground dark:[&>svg]:text-foreground",
},
},
defaultVariants: {