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.

1.0 KB
Raw Blame
// 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 { cn, PrefetchLink } from "@carbon/react";
import type { ReactNode } from "react";
import { getItemDetailPath } from "~/utils/path";

// Renders an item reference (id/name) as a link to the item's detail page.
// Classic link behavior: a plain click navigates in the same tab; a Cmd/Ctrl
// (or middle) click opens a new tab — React Router's Link handles the modifier
// keys natively. `type` picks the right detail route (defaults to Part for
// assemblies/unknown types).
export default function ItemLink({
  itemId,
  type,
  children,
  className
}: {
  itemId: string;
  type: string | null | undefined;
  children: ReactNode;
  className?: string;
}) {
  return (
    <PrefetchLink
      to={getItemDetailPath(type, itemId)}
      className={cn("hover:underline", className)}
    >
      {children}
    </PrefetchLink>
  );
}