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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { useLingui } from "@lingui/react/macro";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo } from "react";
import { Hyperlink, Table } from "~/components";
import { Enumerable } from "~/components/Enumerable";
import type { InfiniteOptions } from "~/components/Table";
import { operationTypes } from "~/modules/shared/shared.models";
import { useParts, useTools } from "~/stores";
import type { MethodOperation } from "../../types";
import { getPathToMakeMethod } from "./utils";
type MethodOperationsTableProps = {
data: MethodOperation[];
count: number;
infinite: InfiniteOptions;
};
const MethodOperationsTable = memo(
({ data, count, infinite }: MethodOperationsTableProps) => {
const { t } = useLingui();
const parts = useParts();
const tools = useTools();
const items = useMemo(() => [...parts, ...tools], [parts, tools]);
const columns = useMemo<ColumnDef<MethodOperation>[]>(() => {
return [
{
accessorKey: "description",
header: t`Description`,
cell: ({ row }) => (
<Hyperlink
to={getPathToMakeMethod(
// @ts-expect-error
row.original.makeMethod?.item?.type,
row.original.makeMethod?.item?.id,
// @ts-expect-error
row.original.makeMethod?.id
)}
className="max-w-[260px] truncate"
>
{row.original.description}
</Hyperlink>
),
meta: { mobile: "P1" }
},
{
accessorKey: "makeMethod.item.readableIdWithRevision",
header: t`Item ID`,
cell: ({ row }) => {
return row.original.makeMethod?.item?.readableIdWithRevision;
},
meta: {
mobile: "P3",
filter: {
type: "static",
options: items?.map((item) => ({
value: item.readableIdWithRevision,
label: item.readableIdWithRevision
}))
}
}
},
{
accessorKey: "operationType",
header: t`Operation Type`,
cell: (item) => (
<Enumerable value={item.getValue<string>() ?? null} />
),
meta: {
mobile: "P2",
filter: {
type: "static",
options: operationTypes.map((value) => ({
value,
label: <Enumerable value={value ?? null} />
}))
}
}
},
{
accessorKey: "setupTime",
header: t`Setup Time`,
cell: ({ row }) => {
return `${row.original.setupTime} ${row.original.setupUnit}`;
}
},
{
accessorKey: "laborTime",
header: t`Labor Time`,
cell: ({ row }) => {
return `${row.original.laborTime} ${row.original.laborUnit}`;
}
},
{
accessorKey: "machineTime",
header: t`Machine Time`,
cell: ({ row }) => {
return `${row.original.machineTime} ${row.original.machineUnit}`;
}
}
];
}, [items, t]);
return (
<Table<MethodOperation>
count={count}
columns={columns}
data={data}
infinite={infinite}
title={t`Method Operations`}
/>
);
}
);
MethodOperationsTable.displayName = "MethodOperationsTable";
export default MethodOperationsTable;