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.4 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 { useLingui } from "@lingui/react/macro";
import {
  LuClock,
  LuGraduationCap,
  LuHardHat,
  LuList,
  LuStickyNote,
  LuUser
} from "react-icons/lu";
import type { PublicAttributes } from "~/modules/users/types";

export function usePersonSidebar(
  attributeCategories: PublicAttributes[],
  timeCardEnabled?: boolean
) {
  const { t } = useLingui();
  const baseLinks = [
    {
      name: t`Profile`,
      to: "details",
      icon: <LuUser />
    },
    {
      name: t`Job`,
      to: "job",
      icon: <LuHardHat />
    },
    {
      name: t`Abilities`,
      to: "abilities",
      icon: <LuGraduationCap />
    },
    {
      name: t`Notes`,
      to: "notes",
      icon: <LuStickyNote />
    },
    ...(timeCardEnabled
      ? [
          {
            name: t`Timecards`,
            to: "timecard",
            icon: <LuClock />
          }
        ]
      : [])
  ];

  const categoryLinks = attributeCategories.map((category) => ({
    name: category.name ?? t`Attributes`,
    to: `attributes/${category.id}`,
    icon: category.emoji ? (
      <span className="text-base">{category.emoji}</span>
    ) : (
      <LuList />
    )
  }));

  return [...baseLinks, ...categoryLinks];
}