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 { MENU_ITEM_SHORTCUTS, MenuIcon, MenuItem } from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo } from "react";
import {
LuFolderKanban,
LuLetterText,
LuPencil,
LuTrash
} from "react-icons/lu";
import { useNavigate } from "react-router";
import { Hyperlink, New, Table } from "~/components";
import type { InfiniteOptions } from "~/components/Table";
import { usePermissions, useUrlParams } from "~/hooks";
import { path } from "~/utils/path";
import type { Project } from "../../types";
type ProjectsTableProps = {
data: Project[];
count: number;
infinite: InfiniteOptions;
};
const ProjectsTable = memo((props: ProjectsTableProps) => {
const { data, count, infinite } = props;
const { t } = useLingui();
const [params] = useUrlParams();
const navigate = useNavigate();
const permissions = usePermissions();
const columns = useMemo<ColumnDef<Project>[]>(() => {
return [
{
accessorKey: "name",
header: t`Name`,
cell: ({ row }) => (
<Hyperlink to={`${row.original.id}?${params.toString()}`}>
{row.original.name}
</Hyperlink>
),
meta: {
mobile: "P1",
icon: <LuFolderKanban />
}
},
{
accessorKey: "description",
header: t`Description`,
cell: (item) => item.getValue(),
meta: {
mobile: "P3",
icon: <LuLetterText />
}
}
];
}, [params, t]);
const renderContextMenu = useCallback(
(row: Project) => {
return (
<>
<MenuItem
shortcut={MENU_ITEM_SHORTCUTS.edit}
disabled={!permissions.can("update", "accounting")}
onClick={() => {
navigate(`${path.to.project(row.id)}?${params.toString()}`);
}}
>
<MenuIcon icon={<LuPencil />} />
<Trans>Edit Project</Trans>
</MenuItem>
<MenuItem
shortcut={MENU_ITEM_SHORTCUTS.delete}
disabled={!permissions.can("delete", "accounting")}
onClick={() => {
navigate(`${path.to.deleteProject(row.id)}?${params.toString()}`);
}}
>
<MenuIcon icon={<LuTrash />} />
<Trans>Delete Project</Trans>
</MenuItem>
</>
);
},
[navigate, params, permissions]
);
return (
<Table<Project>
infinite={infinite}
data={data}
columns={columns}
count={count}
primaryAction={
permissions.can("create", "accounting") && (
<New label={t`Project`} to={`new?${params.toString()}`} />
)
}
renderContextMenu={renderContextMenu}
title={t`Projects`}
/>
);
});
ProjectsTable.displayName = "ProjectsTable";
export default ProjectsTable;