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: make bill of process less busy

Brad Barbin59a503e58c20
diff --git a/apps/carbon/app/components/Table/Table.tsx b/apps/carbon/app/components/Table/Table.tsx
index f93e190902..23c2f6cec8 100644
--- a/apps/carbon/app/components/Table/Table.tsx
+++ b/apps/carbon/app/components/Table/Table.tsx
@@ -46,8 +46,6 @@ import type { ColumnFilter } from "./components/Filter/types";
import type { ColumnSizeMap, TableAction } from "./types";
import { getAccessorKey, updateNestedProperty } from "./utils";
-const PINNED_COLUMNS_BORDER_WIDTH = 2;
-
interface TableProps<T extends object> {
columns: ColumnDef<T>[];
data: T[];
@@ -505,14 +503,15 @@ const Table = <T extends object>({
return () => clearTimeout(timeout);
}, [getTableWrapperEl, table, visibleColumns, pinnedColumnsKey, columnOrder]);
- const lastLeftPinnedColumn = table
- .getLeftVisibleLeafColumns()
- .findLast((c) => c.getIsPinned() === "left");
+ // const lastLeftPinnedColumn = table
+ // .getLeftVisibleLeafColumns()
+ // .findLast((c) => c.getIsPinned() === "left");
const getPinnedStyles = (column: Column<T>): CSSProperties => {
const isPinned = column.getIsPinned();
return {
+ // display: "inline-block",
left:
isPinned === "left"
? columnSizeMap.get(column.id)?.startX ?? 0
@@ -521,11 +520,15 @@ const Table = <T extends object>({
position: isPinned ? "sticky" : "relative",
zIndex: isPinned ? 1 : 0,
backgroundColor: isPinned ? "hsl(var(--card))" : undefined,
- borderColor: "hsl(var(--border))",
- borderRightWidth:
- lastLeftPinnedColumn?.id === column.id
- ? PINNED_COLUMNS_BORDER_WIDTH
- : 0,
+ boxShadow: isPinned
+ ? isPinned === "left"
+ ? "4px 0 6px -2px rgba(0, 0, 0, 0.1)"
+ : "-4px 0 6px -2px rgba(0, 0, 0, 0.1)"
+ : "none",
+ borderRight:
+ isPinned === "left" ? "1px solid hsl(var(--border))" : undefined,
+
+ maxWidth: isPinned === "right" ? 60 : undefined,
};
};
@@ -558,7 +561,7 @@ const Table = <T extends object>({
<div className="flex max-w-full h-full">
<TableBase
ref={tableRef}
- className="relative table-fixed border-collapse border-spacing-0"
+ className="relative border-collapse border-spacing-0"
>
<Thead className="sticky top-0 z-10">
{table.getHeaderGroups().map((headerGroup) => (
diff --git a/apps/carbon/app/lib/swagger-docs-schema.ts b/apps/carbon/app/lib/swagger-docs-schema.ts
index 6962a74c49..a76ff452c0 100644
--- a/apps/carbon/app/lib/swagger-docs-schema.ts
+++ b/apps/carbon/app/lib/swagger-docs-schema.ts
@@ -3,7 +3,7 @@ export default {
info: {
description: "",
title: "standard public schema",
- version: "12.0.1 (cd38da5)",
+ version: "12.0.2 (a4e00ff)",
},
host: "0.0.0.0:3000",
basePath: "/",
@@ -4290,6 +4290,12 @@ export default {
{
$ref: "#/parameters/rowFilter.salesOrderLines.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.modelUploadId",
+ },
{
$ref: "#/parameters/rowFilter.salesOrderLines.customerId",
},
@@ -4299,6 +4305,27 @@ export default {
{
$ref: "#/parameters/rowFilter.salesOrderLines.itemDescription",
},
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.modelId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.autodeskUrn",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.modelPath",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.thumbnailPath",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.modelName",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.modelSize",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLines.unitCost",
+ },
{
$ref: "#/parameters/select",
},
@@ -8688,6 +8715,12 @@ export default {
{
$ref: "#/parameters/rowFilter.salesOrderLine.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLine.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLine.modelUploadId",
+ },
{
$ref: "#/parameters/select",
},
@@ -8828,6 +8861,12 @@ export default {
{
$ref: "#/parameters/rowFilter.salesOrderLine.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLine.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLine.modelUploadId",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -8922,6 +8961,12 @@ export default {
{
$ref: "#/parameters/rowFilter.salesOrderLine.customFields",
},
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLine.status",
+ },
+ {
+ $ref: "#/parameters/rowFilter.salesOrderLine.modelUploadId",
+ },
{
$ref: "#/parameters/body.salesOrderLine",
},
@@ -33885,6 +33930,15 @@ export default {
customFields: {
format: "jsonb",
},
+ status: {
+ enum: ["Ordered", "In Progress", "Completed"],
+ format: 'public."salesOrderLineStatus"',
+ type: "string",
+ },
+ modelUploadId: {
+ format: "text",
+ type: "string",
+ },
customerId: {
description:
"Note:\nThis is a Foreign Key to `customer.id`.<fk table='customer' column='id'/>",
@@ -33899,6 +33953,34 @@ export default {
format: "text",
type: "string",
},
+ modelId: {
+ format: "text",
+ type: "string",
+ },
+ autodeskUrn: {
+ format: "text",
+ type: "string",
+ },
+ modelPath: {
+ format: "text",
+ type: "string",
+ },
+ thumbnailPath: {
+ format: "text",
+ type: "string",
+ },
+ modelName: {
+ format: "text",
+ type: "string",
+ },
+ modelSize: {
+ format: "bigint",
+ type: "integer",
+ },
+ unitCost: {
+ format: "numeric",
+ type: "number",
+ },
},
type: "object",
},
@@ -35791,6 +35873,7 @@ export default {
"companyId",
"createdAt",
"createdBy",
+ "status",
],
properties: {
id: {
@@ -35927,6 +36010,16 @@ export default {
customFields: {
format: "jsonb",
},
+ status: {
+ default: "Ordered",
+ enum: ["Ordered", "In Progress", "Completed"],
+ format: 'public."salesOrderLineStatus"',
+ type: "string",
+ },
+ modelUploadId: {
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -41656,7 +41749,7 @@ export default {
properties: {
id: {
description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -41705,7 +41798,7 @@ export default {
},
supplierLocationId: {
description:
- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -48082,6 +48175,20 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.salesOrderLines.status": {
+ name: "status",
+ required: false,
+ format: 'public."salesOrderLineStatus"',
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.modelUploadId": {
+ name: "modelUploadId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"rowFilter.salesOrderLines.customerId": {
name: "customerId",
required: false,
@@ -48103,6 +48210,55 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.salesOrderLines.modelId": {
+ name: "modelId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.autodeskUrn": {
+ name: "autodeskUrn",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.modelPath": {
+ name: "modelPath",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.thumbnailPath": {
+ name: "thumbnailPath",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.modelName": {
+ name: "modelName",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.modelSize": {
+ name: "modelSize",
+ required: false,
+ format: "bigint",
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLines.unitCost": {
+ name: "unitCost",
+ required: false,
+ format: "numeric",
+ in: "query",
+ type: "string",
+ },
"body.journalLine": {
name: "journalLine",
description: "journalLine",
@@ -50756,6 +50912,20 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.salesOrderLine.status": {
+ name: "status",
+ required: false,
+ format: 'public."salesOrderLineStatus"',
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.salesOrderLine.modelUploadId": {
+ name: "modelUploadId",
+ required: false,
+ format: "text",
+ in: "query",
+ type: "string",
+ },
"body.salesOrderTransaction": {
name: "salesOrderTransaction",
description: "salesOrderTransaction",
diff --git a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
index fdfc5982bf..3bdf522536 100644
--- a/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/carbon/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -10,6 +10,7 @@ import {
CardTitle,
Editor,
HStack,
+ Label,
cn,
generateHTML,
useDebounce,
@@ -23,13 +24,13 @@ import { nanoid } from "nanoid";
import type { Dispatch, SetStateAction } from "react";
import { useCallback, useEffect, useState } from "react";
import { flushSync } from "react-dom";
-import { LuSettings2, LuX } from "react-icons/lu";
+import { LuChevronDown, LuSettings2, LuX } from "react-icons/lu";
import type { z } from "zod";
import { DirectionAwareTabs } from "~/components/DirectionAwareTabs";
import {
Hidden,
InputControlled,
- Number,
+ NumberControlled,
Process,
Select,
SelectControlled,
@@ -541,24 +542,39 @@ function OperationForm({
}
}, [item.id, methodOperationFetcher.data, setItems, setSelectedItemId]);
+ const [showSetup, setShowSetup] = useState((item.data.setupTime ?? 0) > 0);
+ const [showMachine, setShowMachine] = useState(
+ (item.data.machineTime ?? 0) > 0
+ );
+ const [showLabor, setShowLabor] = useState(
+ (item.data.laborTime ?? 0) > 0 ||
+ (showSetup === false && showMachine === false)
+ );
+
const [processData, setProcessData] = useState<{
description: string;
+ laborTime: number;
laborUnit: string;
laborUnitHint: string;
+ machineTime: number;
machineUnit: string;
machineUnitHint: string;
operationType: string;
processId: string;
+ setupTime: number;
setupUnit: string;
setupUnitHint: string;
}>({
description: item.data.description ?? "",
+ laborTime: item.data.laborTime ?? 0,
laborUnit: item.data.laborUnit ?? "Hours/Piece",
laborUnitHint: getUnitHint(item.data.laborUnit),
+ machineTime: item.data.machineTime ?? 0,
machineUnit: item.data.machineUnit ?? "Hours/Piece",
machineUnitHint: getUnitHint(item.data.machineUnit),
operationType: item.data.operationType ?? "Inside",
processId: item.data.processId ?? "",
+ setupTime: item.data.setupTime ?? 0,
setupUnit: item.data.setupUnit ?? "Total Minutes",
setupUnitHint: getUnitHint(item.data.setupUnit),
});
@@ -714,87 +730,191 @@ function OperationForm({
}
}}
/>
- <UnitHint
- name="setupHint"
- label="Setup"
- value={processData.setupUnitHint}
- onChange={(hint) => {
- setProcessData((d) => ({
- ...d,
- setupUnitHint: hint,
- setupUnit:
- hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
- }));
- }}
- />
- <Number name="setupTime" label="Setup Time" minValue={0} />
- <StandardFactor
- name="setupUnit"
- label="Setup Unit"
- hint={processData.setupUnitHint}
- value={processData.setupUnit}
- onChange={(newValue) => {
- setProcessData((d) => ({
- ...d,
- setupUnit: newValue?.value ?? "Total Minutes",
- }));
- }}
- />
- <UnitHint
- name="laborHint"
- label="Labor"
- value={processData.laborUnitHint}
- onChange={(hint) => {
- setProcessData((d) => ({
- ...d,
- laborUnitHint: hint,
- laborUnit:
- hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
- }));
- }}
- />
- <Number name="laborTime" label="Labor Time" minValue={0} />
- <StandardFactor
- name="laborUnit"
- label="Labor Unit"
- hint={processData.laborUnitHint}
- value={processData.laborUnit}
- onChange={(newValue) => {
- setProcessData((d) => ({
- ...d,
- laborUnit: newValue?.value ?? "Hours/Piece",
- }));
- }}
- />
- <UnitHint
- name="machineHint"
- label="Machine"
- value={processData.machineUnitHint}
- onChange={(hint) => {
- setProcessData((d) => ({
- ...d,
- machineUnitHint: hint,
- machineUnit:
- hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
- }));
- }}
- />
- <Number name="machineTime" label="Machine Time" minValue={0} />
- <StandardFactor
- name="machineUnit"
- label="Machine Unit"
- hint={processData.machineUnitHint}
- value={processData.machineUnit}
- onChange={(newValue) => {
- setProcessData((d) => ({
- ...d,
- machineUnit: newValue?.value ?? "Hours/Piece",
- }));
- }}
- />
</>
)}
</div>
+ {processData.operationType === "Inside" && (
+ <>
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowLabor(!showLabor)}
+ >
+ <HStack>
+ <TimeTypeIcon type="Labor" />
+ <Label>Labor</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showLabor ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showLabor ? "" : "hidden"
+ }`}
+ >
+ <UnitHint
+ name="laborHint"
+ label="Labor"
+ value={processData.laborUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ laborUnitHint: hint,
+ laborUnit:
+ hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <NumberControlled
+ name="laborTime"
+ label="Labor Time"
+ minValue={0}
+ value={processData.laborTime}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ laborTime: newValue,
+ }))
+ }
+ />
+ <StandardFactor
+ name="laborUnit"
+ label="Labor Unit"
+ hint={processData.laborUnitHint}
+ value={processData.laborUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ laborUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ </div>
+ </div>
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowSetup(!showSetup)}
+ >
+ <HStack>
+ <TimeTypeIcon type="Setup" />
+ <Label>Setup</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showSetup ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showSetup ? "" : "hidden"
+ }`}
+ >
+ <UnitHint
+ name="setupHint"
+ label="Setup"
+ value={processData.setupUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ setupUnitHint: hint,
+ setupUnit:
+ hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <NumberControlled
+ name="setupTime"
+ label="Setup Time"
+ minValue={0}
+ value={processData.setupTime}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ setupTime: newValue,
+ }))
+ }
+ />
+ <StandardFactor
+ name="setupUnit"
+ label="Setup Unit"
+ hint={processData.setupUnitHint}
+ value={processData.setupUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ setupUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ </div>
+ </div>
+
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowMachine(!showMachine)}
+ >
+ <HStack>
+ <TimeTypeIcon type="Machine" />
+ <Label>Machine</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showMachine ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showMachine ? "" : "hidden"
+ }`}
+ >
+ <UnitHint
+ name="machineHint"
+ label="Machine"
+ value={processData.machineUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ machineUnitHint: hint,
+ machineUnit:
+ hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <NumberControlled
+ name="machineTime"
+ label="Machine Time"
+ minValue={0}
+ value={processData.machineTime}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ machineTime: newValue,
+ }))
+ }
+ />
+ <StandardFactor
+ name="machineUnit"
+ label="Machine Unit"
+ hint={processData.machineUnitHint}
+ value={processData.machineUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ machineUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ </div>
+ </div>
+ </>
+ )}
<motion.div
className="flex w-full items-center justify-end p-2"
initial={{ opacity: 0, filter: "blur(4px)" }}
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index 00f12fed88..7dd30e3a8c 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -404,7 +404,7 @@ export const quoteOperationValidator = z
.refine(
(data) => {
if (data.operationType === "Inside") {
- return Number.isFinite(data.machineTime);
+ return Number.isFinite(data.machineRate);
}
return true;
},
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index c00275fb11..f3b83be386 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -10,6 +10,7 @@ import {
CardTitle,
Editor,
HStack,
+ Label,
cn,
generateHTML,
useDebounce,
@@ -23,13 +24,12 @@ import { nanoid } from "nanoid";
import type { Dispatch, SetStateAction } from "react";
import { useCallback, useEffect, useState } from "react";
import { flushSync } from "react-dom";
-import { LuSettings2, LuX } from "react-icons/lu";
+import { LuChevronDown, LuDollarSign, LuSettings2, LuX } from "react-icons/lu";
import type { z } from "zod";
import { DirectionAwareTabs } from "~/components/DirectionAwareTabs";
import {
Hidden,
InputControlled,
- Number,
NumberControlled,
Process,
Select,
@@ -268,14 +268,15 @@ const QuoteBillOfProcess = ({
: item
)
);
- await supabase
- ?.from("quoteOperationWorkInstruction")
- .update({
- content,
- updatedAt: today(getLocalTimeZone()).toString(),
- updatedBy: userId,
- })
- .eq("quoteOperationId", selectedItemId!);
+ if (selectedItemId !== null && !isTemporaryId(selectedItemId))
+ await supabase
+ ?.from("quoteOperationWorkInstruction")
+ .update({
+ content,
+ updatedAt: today(getLocalTimeZone()).toString(),
+ updatedBy: userId,
+ })
+ .eq("quoteOperationId", selectedItemId!);
}, 2500);
const onUploadImage = async (file: File) => {
@@ -334,7 +335,6 @@ const QuoteBillOfProcess = ({
{
id: 1,
label: "Work Instructions",
- disabled: isTemporaryId(item.id),
content: (
<div className="flex flex-col">
<motion.div
@@ -565,12 +565,24 @@ function OperationForm({
}
}, [item.id, fetcher.data, setItems, setSelectedItemId]);
+ const [showSetup, setShowSetup] = useState((item.data.setupTime ?? 0) > 0);
+ const [showMachine, setShowMachine] = useState(
+ (item.data.machineTime ?? 0) > 0
+ );
+ const [showLabor, setShowLabor] = useState(
+ (item.data.laborTime ?? 0) > 0 ||
+ (showSetup === false && showMachine === false)
+ );
+ const [showCost, setShowCost] = useState(false);
+
const [processData, setProcessData] = useState<{
description: string;
laborRate: number;
+ laborTime: number;
laborUnit: string;
laborUnitHint: string;
machineRate: number;
+ machineTime: number;
machineUnit: string;
machineUnitHint: string;
operationMinimumCost: number;
@@ -579,14 +591,17 @@ function OperationForm({
operationUnitCost: number;
overheadRate: number;
processId: string;
+ setupTime: number;
setupUnit: string;
setupUnitHint: string;
}>({
description: item.data.description ?? "",
laborRate: item.data.laborRate ?? 0,
+ laborTime: item.data.laborTime ?? 0,
laborUnit: item.data.laborUnit ?? "Hours/Piece",
laborUnitHint: getUnitHint(item.data.laborUnit),
machineRate: item.data.machineRate ?? 0,
+ machineTime: item.data.machineTime ?? 0,
machineUnit: item.data.machineUnit ?? "Hours/Piece",
machineUnitHint: getUnitHint(item.data.machineUnit),
operationMinimumCost: item.data.operationMinimumCost ?? 0,
@@ -595,6 +610,7 @@ function OperationForm({
operationUnitCost: item.data.operationUnitCost ?? 0,
overheadRate: item.data.overheadRate ?? 0,
processId: item.data.processId ?? "",
+ setupTime: item.data.setupTime ?? 0,
setupUnit: item.data.setupUnit ?? "Total Minutes",
setupUnitHint: getUnitHint(item.data.setupUnit),
});
@@ -725,7 +741,7 @@ function OperationForm({
validator={quoteOperationValidator}
className="w-full flex flex-col gap-y-4"
fetcher={fetcher}
- onSubmit={(values) => {
+ onSubmit={async (values) => {
setItems((prevItems) =>
prevItems.map((i) =>
i.id === item.id
@@ -852,148 +868,273 @@ function OperationForm({
/>
</>
) : (
- <>
- <WorkCenter
- name="workCenterId"
- label="Work Center"
- isOptional
- processId={processData.processId}
- onChange={(value) => {
- if (value) {
- onWorkCenterChange(value?.value as string);
- }
- }}
- />
- <UnitHint
- name="setupHint"
- label="Setup"
- value={processData.setupUnitHint}
- onChange={(hint) => {
- setProcessData((d) => ({
- ...d,
- setupUnitHint: hint,
- setupUnit:
- hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
- }));
- }}
- />
- <Number name="setupTime" label="Setup Time" minValue={0} />
- <StandardFactor
- name="setupUnit"
- label="Setup Unit"
- hint={processData.setupUnitHint}
- value={processData.setupUnit}
- onChange={(newValue) => {
- setProcessData((d) => ({
- ...d,
- setupUnit: newValue?.value ?? "Total Minutes",
- }));
- }}
- />
- <UnitHint
- name="laborHint"
- label="Labor"
- value={processData.laborUnitHint}
- onChange={(hint) => {
- setProcessData((d) => ({
- ...d,
- laborUnitHint: hint,
- laborUnit:
- hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
- }));
- }}
- />
- <Number name="laborTime" label="Labor Time" minValue={0} />
- <StandardFactor
- name="laborUnit"
- label="Labor Unit"
- hint={processData.laborUnitHint}
- value={processData.laborUnit}
- onChange={(newValue) => {
- setProcessData((d) => ({
- ...d,
- laborUnit: newValue?.value ?? "Hours/Piece",
- }));
- }}
- />
- <UnitHint
- name="machineHint"
- label="Machine"
- value={processData.machineUnitHint}
- onChange={(hint) => {
- setProcessData((d) => ({
- ...d,
- machineUnitHint: hint,
- machineUnit:
- hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
- }));
- }}
- />
- <Number name="machineTime" label="Machine Time" minValue={0} />
- <StandardFactor
- name="machineUnit"
- label="Machine Unit"
- hint={processData.machineUnitHint}
- value={processData.machineUnit}
- onChange={(newValue) => {
- setProcessData((d) => ({
- ...d,
- machineUnit: newValue?.value ?? "Hours/Piece",
- }));
- }}
- />
-
- <NumberControlled
- name="laborRate"
- label="Labor Rate"
- minValue={0}
- value={processData.laborRate}
- formatOptions={{
- style: "currency",
- currency: "USD",
- }}
- onChange={(newValue) =>
- setProcessData((d) => ({
- ...d,
- laborRate: newValue,
- }))
+ <WorkCenter
+ name="workCenterId"
+ label="Work Center"
+ isOptional
+ processId={processData.processId}
+ onChange={(value) => {
+ if (value) {
+ onWorkCenterChange(value?.value as string);
}
- />
- <NumberControlled
- name="machineRate"
- label="Machine Rate"
- minValue={0}
- value={processData.machineRate}
- formatOptions={{
- style: "currency",
- currency: "USD",
- }}
- onChange={(newValue) =>
- setProcessData((d) => ({
- ...d,
- machineRate: newValue,
- }))
- }
- />
- <NumberControlled
- name="overheadRate"
- label="Overhead Rate"
- minValue={0}
- value={processData.overheadRate}
- formatOptions={{
- style: "currency",
- currency: "USD",
- }}
- onChange={(newValue) =>
- setProcessData((d) => ({
- ...d,
- overheadRate: newValue,
- }))
- }
- />
- </>
+ }}
+ />
)}
</div>
+
+ {processData.operationType === "Inside" && (
+ <>
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowLabor(!showLabor)}
+ >
+ <HStack>
+ <TimeTypeIcon type="Labor" />
+ <Label>Labor</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showLabor ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showLabor ? "" : "hidden"
+ }`}
+ >
+ <UnitHint
+ name="laborHint"
+ label="Labor"
+ value={processData.laborUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ laborUnitHint: hint,
+ laborUnit:
+ hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <NumberControlled
+ name="laborTime"
+ label="Labor Time"
+ minValue={0}
+ value={processData.laborTime}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ laborTime: newValue,
+ }))
+ }
+ />
+ <StandardFactor
+ name="laborUnit"
+ label="Labor Unit"
+ hint={processData.laborUnitHint}
+ value={processData.laborUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ laborUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ </div>
+ </div>
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowSetup(!showSetup)}
+ >
+ <HStack>
+ <TimeTypeIcon type="Setup" />
+ <Label>Setup</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showSetup ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showSetup ? "" : "hidden"
+ }`}
+ >
+ <UnitHint
+ name="setupHint"
+ label="Setup"
+ value={processData.setupUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ setupUnitHint: hint,
+ setupUnit:
+ hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <NumberControlled
+ name="setupTime"
+ label="Setup Time"
+ minValue={0}
+ value={processData.setupTime}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ setupTime: newValue,
+ }))
+ }
+ />
+ <StandardFactor
+ name="setupUnit"
+ label="Setup Unit"
+ hint={processData.setupUnitHint}
+ value={processData.setupUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ setupUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ </div>
+ </div>
+
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowMachine(!showMachine)}
+ >
+ <HStack>
+ <TimeTypeIcon type="Machine" />
+ <Label>Machine</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showMachine ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showMachine ? "" : "hidden"
+ }`}
+ >
+ <UnitHint
+ name="machineHint"
+ label="Machine"
+ value={processData.machineUnitHint}
+ onChange={(hint) => {
+ setProcessData((d) => ({
+ ...d,
+ machineUnitHint: hint,
+ machineUnit:
+ hint === "Fixed" ? "Total Minutes" : "Minutes/Piece",
+ }));
+ }}
+ />
+ <NumberControlled
+ name="machineTime"
+ label="Machine Time"
+ minValue={0}
+ value={processData.machineTime}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ machineTime: newValue,
+ }))
+ }
+ />
+ <StandardFactor
+ name="machineUnit"
+ label="Machine Unit"
+ hint={processData.machineUnitHint}
+ value={processData.machineUnit}
+ onChange={(newValue) => {
+ setProcessData((d) => ({
+ ...d,
+ machineUnit: newValue?.value ?? "Total Minutes",
+ }));
+ }}
+ />
+ </div>
+ </div>
+
+ <div className="border border-border rounded-md shadow-sm p-4 flex flex-col gap-4">
+ <HStack
+ className="w-full justify-between cursor-pointer"
+ onClick={() => setShowCost(!showCost)}
+ >
+ <HStack>
+ <LuDollarSign />
+ <Label>Costing</Label>
+ </HStack>
+ <LuChevronDown
+ className={`transition-transform ${
+ showCost ? "rotate-180" : ""
+ }`}
+ />
+ </HStack>
+ <div
+ className={`grid w-full gap-x-8 gap-y-4 grid-cols-1 lg:grid-cols-3 pb-4 ${
+ showCost ? "" : "hidden"
+ }`}
+ >
+ <NumberControlled
+ name="laborRate"
+ label="Labor Rate"
+ minValue={0}
+ value={processData.laborRate}
+ formatOptions={{
+ style: "currency",
+ currency: "USD",
+ }}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ laborRate: newValue,
+ }))
+ }
+ />
+ <NumberControlled
+ name="machineRate"
+ label="Machine Rate"
+ minValue={0}
+ value={processData.machineRate}
+ formatOptions={{
+ style: "currency",
+ currency: "USD",
+ }}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ machineRate: newValue,
+ }))
+ }
+ />
+ <NumberControlled
+ name="overheadRate"
+ label="Overhead Rate"
+ minValue={0}
+ value={processData.overheadRate}
+ formatOptions={{
+ style: "currency",
+ currency: "USD",
+ }}
+ onChange={(newValue) =>
+ setProcessData((d) => ({
+ ...d,
+ overheadRate: newValue,
+ }))
+ }
+ />
+ </div>
+ </div>
+ </>
+ )}
<motion.div
className="flex w-full items-center justify-end p-2"
initial={{ opacity: 0, filter: "blur(4px)" }}
diff --git a/package-lock.json b/package-lock.json
index 3fdcc1c148..4006f92ea8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -35655,6 +35655,7 @@
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
+ "@radix-ui/react-collapsible": "1.1.0",
"@radix-ui/react-context-menu": "^2.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
diff --git a/packages/react/package.json b/packages/react/package.json
index f5a9bbbf9e..b126d46e7a 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -4,6 +4,7 @@
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
+ "@radix-ui/react-collapsible": "1.1.0",
"@radix-ui/react-context-menu": "^2.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
diff --git a/packages/react/src/Collapsible.tsx b/packages/react/src/Collapsible.tsx
new file mode 100644
index 0000000000..1fe76f5d16
--- /dev/null
+++ b/packages/react/src/Collapsible.tsx
@@ -0,0 +1,11 @@
+"use client";
+
+import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
+
+const Collapsible = CollapsiblePrimitive.Root;
+
+const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
+
+const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
+
+export { Collapsible, CollapsibleContent, CollapsibleTrigger };
diff --git a/packages/react/src/Table.tsx b/packages/react/src/Table.tsx
index 0f29187dcf..95047d2d20 100644
--- a/packages/react/src/Table.tsx
+++ b/packages/react/src/Table.tsx
@@ -72,7 +72,7 @@ const Th = forwardRef<
<th
ref={ref}
className={cn(
- "group-hover:bg-muted/30 h-11 px-6 text-left align-middle uppercase bg-card font-semibold tracking-tight text-muted-foreground [&:has([role=checkbox])]:pr-0 border-b border-border",
+ "group-hover:bg-muted/30 h-11 px-6 text-left align-middle uppercase bg-card font-semibold tracking-tight text-muted-foreground [&:has([role=checkbox])]:pr-0",
className
)}
{...props}
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index bf46c35800..15bb869302 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -35,6 +35,11 @@ import {
import { Checkbox } from "./Checkbox";
import { ClientOnly } from "./ClientOnly";
import { CodeBlock } from "./CodeBlock";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "./Collapsible";
import {
Command,
CommandDialog,
@@ -287,6 +292,9 @@ export {
Checkbox,
ClientOnly,
CodeBlock,
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
Command,
CommandDialog,
CommandEmpty,