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.

refactor: employee form component to use combobox instead of user select component

Brad Barbin533eda67e667
diff --git a/apps/carbon/app/components/Form/Employee.tsx b/apps/carbon/app/components/Form/Employee.tsx
index 6389831d7a..f13b847691 100644
--- a/apps/carbon/app/components/Form/Employee.tsx
+++ b/apps/carbon/app/components/Form/Employee.tsx
@@ -1,10 +1,33 @@
-import type { UserProps } from "./User";
-import User from "./User";
+import { useMemo } from "react";
+import { usePeople } from "~/stores";
+import type { ComboboxProps } from "./Combobox";
+import CreatableCombobox from "./CreatableCombobox";
-export type EmployeesProps = UserProps;
+type EmployeeSelectProps = Omit<ComboboxProps, "options"> & {};
-const Employee = (props: EmployeesProps) => (
- <User {...props} usersOnly type="employee" />
-);
+const Employee = (props: EmployeeSelectProps) => {
+ const [people] = usePeople();
+
+ const options = useMemo(
+ () =>
+ people.map((part) => ({
+ value: part.id,
+ label: part.name,
+ })) ?? [],
+ [people]
+ );
+
+ return (
+ <>
+ <CreatableCombobox
+ options={options}
+ {...props}
+ label={props?.label ?? "Employee"}
+ />
+ </>
+ );
+};
+
+Employee.displayName = "Employee";
export default Employee;