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 type { ComboboxProps } from "@carbon/form";
import { Combobox } from "@carbon/form";
import { useLingui } from "@lingui/react/macro";
import { useMemo } from "react";
import { usePeople } from "~/stores";
import Avatar from "../Avatar";
import EmployeeAvatar from "../EmployeeAvatar";
import { useEmptyState } from "./emptyStates";
type EmployeeSelectProps = Omit<
ComboboxProps,
"options" | "type" | "inline"
> & {
type?: "assignee";
inline?: boolean;
};
const EmployeePreview = (
value: string,
options: { value: string; label: string | React.ReactNode }[]
) => {
return <EmployeeAvatar employeeId={value} />;
};
const Employee = ({ type, inline, ...props }: EmployeeSelectProps) => {
const { t } = useLingui();
const [people] = usePeople();
const options = useMemo(() => {
const base =
people.map((person) => ({
value: person.id,
label: (
<div className="flex flex-row items-center gap-2 flex-grow">
<Avatar name={person.name} path={person.avatarUrl} size="xs" />
<span>{person.name}</span>
</div>
)
})) ?? [];
if (type === "assignee") {
return [
{
value: "",
label: t`Unassigned`
},
...base
];
}
return base;
}, [type, people, t]);
const emptyMessage = useEmptyState("employee");
return (
<>
<Combobox
options={options}
emptyMessage={emptyMessage}
{...props}
inline={inline ? EmployeePreview : undefined}
label={props?.label ?? t`Employee`}
placeholder={props?.placeholder ?? t`Select Employee`}
/>
</>
);
};
Employee.displayName = "Employee";
export default Employee;