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.

style: use item type icon for item thumbnail

Brad Barbina35f05bb9317
diff --git a/apps/carbon/app/components/EmployeeAvatar.tsx b/apps/carbon/app/components/EmployeeAvatar.tsx
index 086eaeb19d..9476101901 100644
--- a/apps/carbon/app/components/EmployeeAvatar.tsx
+++ b/apps/carbon/app/components/EmployeeAvatar.tsx
@@ -6,7 +6,7 @@ import Avatar from "./Avatar";
type EmployeeAvatarProps = AvatarProps & {
employeeId: string | null;
className?: string;
- withName: boolean;
+ withName?: boolean;
};
const EmployeeAvatar = ({
diff --git a/apps/carbon/app/components/ItemThumbnail.tsx b/apps/carbon/app/components/ItemThumbnail.tsx
index 1a95d11b92..b96e4bea37 100644
--- a/apps/carbon/app/components/ItemThumbnail.tsx
+++ b/apps/carbon/app/components/ItemThumbnail.tsx
@@ -1,25 +1,39 @@
import { Spinner } from "@carbon/react";
-import { LuImage } from "react-icons/lu";
+import { LuHexagon } from "react-icons/lu";
+import type { MethodItemType } from "~/modules/shared";
+import { MethodItemTypeIcon } from "./Icons";
interface ItemThumbnailProps {
thumbnailPath?: string | null;
modelId?: string | null;
+ type?: MethodItemType;
}
-const ItemThumbnail = ({ thumbnailPath, modelId }: ItemThumbnailProps) => {
+const ItemThumbnail = ({
+ thumbnailPath,
+ modelId,
+ type,
+}: ItemThumbnailProps) => {
return thumbnailPath ? (
<img
- alt="P2392303"
+ alt="thumbnail"
className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border-2 border-transparent"
src={`/file/preview/private/${thumbnailPath}`}
/>
) : !!modelId && !thumbnailPath ? (
- <div className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border-2 border-transparent p-1.5">
+ <div className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border-2 border-transparent p-2">
<Spinner className="w-6 h-6 text-muted-foreground" />
</div>
) : (
- <div className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border-2 border-transparent p-1.5">
- <LuImage className="w-6 h-6 text-muted-foreground" />
+ <div className="w-10 h-10 bg-gradient-to-bl from-muted to-muted/40 rounded-lg border-2 border-transparent p-2">
+ {type ? (
+ <MethodItemTypeIcon
+ className="w-5 h-5 text-muted-foreground"
+ type={type}
+ />
+ ) : (
+ <LuHexagon className="w-5 h-5 text-muted-foreground" />
+ )}
</div>
);
};
diff --git a/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx b/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx
index 187391c8a3..ceec9b71fa 100644
--- a/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx
@@ -52,7 +52,10 @@ const InventoryTable = memo(
header: "Item ID",
cell: ({ row }) => (
<HStack className="py-1">
- <ItemThumbnail thumbnailPath={row.original.thumbnailPath} />
+ <ItemThumbnail
+ thumbnailPath={row.original.thumbnailPath}
+ type={row.original.type}
+ />
<Hyperlink
to={`${path.to.inventoryItem(row.original.itemId!)}/?${params}`}
className="max-w-[260px] truncate"
@@ -62,31 +65,7 @@ const InventoryTable = memo(
</HStack>
),
},
- {
- accessorKey: "type",
- header: "Type",
- cell: ({ row }) =>
- row.original.type && (
- <HStack>
- <MethodItemTypeIcon type={row.original.type} />
- <span>{row.original.type}</span>
- </HStack>
- ),
- meta: {
- filter: {
- type: "static",
- options: itemTypes.map((type) => ({
- label: (
- <HStack spacing={2}>
- <MethodItemTypeIcon type={type} />
- <span>{type}</span>
- </HStack>
- ),
- value: type,
- })),
- },
- },
- },
+
{
accessorKey: "name",
header: "Name",
@@ -97,18 +76,7 @@ const InventoryTable = memo(
header: "Location",
cell: ({ row }) => <Enumerable value={row.original.locationName} />,
},
- {
- accessorKey: "unitOfMeasureCode",
- header: "Unit of Measure",
- cell: ({ row }) => {
- const unitOfMeasure = unitOfMeasures.find(
- (uom) => uom.code === row.original.unitOfMeasureCode
- );
- return unitOfMeasure
- ? unitOfMeasure.name
- : row.original.unitOfMeasureCode;
- },
- },
+
{
accessorKey: "materialFormId",
header: "Form",
@@ -168,6 +136,43 @@ const InventoryTable = memo(
header: "On Sales Order",
cell: ({ row }) => row.original.quantityOnSalesOrder,
},
+ {
+ accessorKey: "unitOfMeasureCode",
+ header: "Unit of Measure",
+ cell: ({ row }) => {
+ const unitOfMeasure = unitOfMeasures.find(
+ (uom) => uom.code === row.original.unitOfMeasureCode
+ );
+ return unitOfMeasure
+ ? unitOfMeasure.name
+ : row.original.unitOfMeasureCode;
+ },
+ },
+ {
+ accessorKey: "type",
+ header: "Type",
+ cell: ({ row }) =>
+ row.original.type && (
+ <HStack>
+ <MethodItemTypeIcon type={row.original.type} />
+ <span>{row.original.type}</span>
+ </HStack>
+ ),
+ meta: {
+ filter: {
+ type: "static",
+ options: itemTypes.map((type) => ({
+ label: (
+ <HStack spacing={2}>
+ <MethodItemTypeIcon type={type} />
+ <span>{type}</span>
+ </HStack>
+ ),
+ value: type,
+ })),
+ },
+ },
+ },
];
}, [forms, params, substances, unitOfMeasures]);
@@ -176,10 +181,7 @@ const InventoryTable = memo(
}, []);
const defaultColumnVisibility = {
- readableId: true,
- type: true,
- name: true,
- description: true,
+ type: false,
};
return (
diff --git a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
index 9c59e050fc..7930d72675 100644
--- a/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
+++ b/apps/carbon/app/modules/items/ui/Parts/PartsTable.tsx
@@ -54,7 +54,10 @@ const PartsTable = memo(({ data, count }: PartsTableProps) => {
header: "Part ID",
cell: ({ row }) => (
<HStack className="py-1">
- <ItemThumbnail thumbnailPath={row.original.thumbnailPath} />
+ <ItemThumbnail
+ thumbnailPath={row.original.thumbnailPath}
+ type="Part"
+ />
<Hyperlink to={path.to.partDetails(row.original.itemId!)}>
{row.original.id}
</Hyperlink>
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
index 9773f0a894..e3f809ba15 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteExplorer.tsx
@@ -32,6 +32,7 @@ import {
useRouteData,
useUser,
} from "~/hooks";
+import type { MethodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
import type { Quotation, QuotationLine, QuoteMethod } from "../../types";
import DeleteQuoteLine from "./DeleteQuoteLine";
@@ -212,6 +213,7 @@ function QuoteLineItem({
<ItemThumbnail
modelId={line.modelId}
thumbnailPath={line.thumbnailPath}
+ type={line.itemType as MethodItemType}
/>
<VStack spacing={0}>
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
index 02795952bb..d78b16956a 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderExplorer.tsx
@@ -190,6 +190,7 @@ function SalesOrderLineItem({
<ItemThumbnail
modelId={line.modelId}
thumbnailPath={line.thumbnailPath}
+ type="Part" // TODO
/>
<VStack spacing={0}>
diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
index 91750b6c1c..a89b6b305d 100644
--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQExplorer.tsx
@@ -25,6 +25,7 @@ import { LuPlus, LuTrash } from "react-icons/lu";
import { MdMoreVert } from "react-icons/md";
import { Empty, ItemThumbnail } from "~/components";
import { usePermissions, useRealtime, useRouteData } from "~/hooks";
+import type { MethodItemType } from "~/modules/shared";
import { path } from "~/utils/path";
import type { SalesRFQ, SalesRFQLine } from "../../types";
import DeleteSalesRFQLine from "./DeleteSalesRFQLine";
@@ -247,6 +248,7 @@ function SalesRFQLineItem({
<ItemThumbnail
modelId={line.modelId}
thumbnailPath={line.thumbnailPath}
+ type={line.itemType as MethodItemType}
/>
<VStack spacing={0}>