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: add item to issues table

Brad Barbin7ebb209f90f3
diff --git a/apps/erp/app/modules/quality/ui/Issue/IssuesTable.tsx b/apps/erp/app/modules/quality/ui/Issue/IssuesTable.tsx
index ec396d1256..56bdd63857 100644
--- a/apps/erp/app/modules/quality/ui/Issue/IssuesTable.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/IssuesTable.tsx
@@ -11,6 +11,7 @@ import {
LuMap,
LuOctagonX,
LuPencil,
+ LuSquareStack,
LuTrash,
LuUser,
} from "react-icons/lu";
@@ -23,6 +24,8 @@ import { useLocations } from "~/components/Form/Location";
import { ConfirmDelete } from "~/components/Modals";
import { usePermissions } from "~/hooks";
import { useCustomColumns } from "~/hooks/useCustomColumns";
+import { getLinkToItemDetails } from "~/modules/items/ui/Item/ItemForm";
+import { useItems } from "~/stores/items";
import { usePeople } from "~/stores/people";
import type { ListItem } from "~/types";
import { path } from "~/utils/path";
@@ -50,6 +53,7 @@ const IssuesTable = memo(({ data, types, count }: IssuesTableProps) => {
const customColumns = useCustomColumns<Issue>("nonConformance");
const locations = useLocations();
const [people] = usePeople();
+ const [items] = useItems();
const columns = useMemo<ColumnDef<Issue>[]>(() => {
const defaultColumns: ColumnDef<Issue>[] = [
@@ -72,6 +76,33 @@ const IssuesTable = memo(({ data, types, count }: IssuesTableProps) => {
icon: <LuBookMarked />,
},
},
+ {
+ accessorKey: "itemId",
+ header: "Item",
+ cell: ({ row }) => {
+ const item = items.find((item) => item.id === row.original.itemId);
+ if (!item) return null;
+ // @ts-expect-error - TODO: fix this
+ const link = getLinkToItemDetails(item.type, item.id);
+ return (
+ <div className="flex flex-col text-sm">
+ <Hyperlink to={link}>{item.readableIdWithRevision}</Hyperlink>
+ <span className="text-xs text-muted-foreground">{item.name}</span>
+ </div>
+ );
+ },
+ meta: {
+ filter: {
+ type: "static",
+ options: items.map((item) => ({
+ label: item.name,
+ helperText: item.readableIdWithRevision,
+ value: item.id,
+ })),
+ },
+ icon: <LuSquareStack />,
+ },
+ },
{
accessorKey: "status",
header: "Status",
@@ -110,6 +141,7 @@ const IssuesTable = memo(({ data, types, count }: IssuesTableProps) => {
},
},
},
+
{
accessorKey: "priority",
header: "Priority",
@@ -208,7 +240,7 @@ const IssuesTable = memo(({ data, types, count }: IssuesTableProps) => {
},
];
return [...defaultColumns, ...customColumns];
- }, [customColumns, locations, people, types]);
+ }, [customColumns, items, locations, people, types]);
const renderContextMenu = useCallback(
(row: Issue) => {