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.

fix: use select instead of createable combobox for preferred supplier

Brad Barbin8c557749e897
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
index b2e91ef82c..742dfd72f4 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
@@ -1,4 +1,4 @@
-import { ValidatedForm } from "@carbon/form";
+import { Select, ValidatedForm } from "@carbon/form";
import {
Card,
CardContent,
@@ -15,10 +15,10 @@ import {
Hidden,
Number,
Submit,
- Supplier,
UnitOfMeasure,
} from "~/components/Form";
import { usePermissions, useRouteData } from "~/hooks";
+import { useSuppliers } from "~/stores/suppliers";
import { path } from "~/utils/path";
import { itemPurchasingValidator } from "../../items.models";
import type { PartSummary } from "../../types";
@@ -36,6 +36,17 @@ const ItemPurchasingForm = ({
const { itemId } = useParams();
if (!itemId) throw new Error("itemId not found");
+ const [suppliers] = useSuppliers();
+ const allowedSuppliersOptions = suppliers?.reduce((acc, supplier) => {
+ if (allowedSuppliers?.includes(supplier.id)) {
+ acc.push({
+ label: supplier.name,
+ value: supplier.id,
+ });
+ }
+ return acc;
+ }, [] as { label: string; value: string }[]);
+
const routeData = useRouteData<{ partSummary: PartSummary }>(
path.to.part(itemId)
);
@@ -58,10 +69,10 @@ const ItemPurchasingForm = ({
<CardContent>
<Hidden name="itemId" />
<div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
- <Supplier
+ <Select
name="preferredSupplierId"
label="Preferred Supplier"
- allowedSuppliers={allowedSuppliers}
+ options={allowedSuppliersOptions}
/>
<Number name="purchasingLeadTime" label="Lead Time (Days)" />
<UnitOfMeasure
diff --git a/apps/erp/app/routes/x+/supplier+/new.tsx b/apps/erp/app/routes/x+/supplier+/new.tsx
index dff3115b5d..2a254ca855 100644
--- a/apps/erp/app/routes/x+/supplier+/new.tsx
+++ b/apps/erp/app/routes/x+/supplier+/new.tsx
@@ -46,14 +46,14 @@ export async function action({ request }: ActionFunctionArgs) {
createSupplier,
await flash(
request,
- error(createSupplier.error, "Failed to insert supplier")
+ error(createSupplier.error, createSupplier.error.message)
)
)
: redirect(
path.to.suppliers,
await flash(
request,
- error(createSupplier.error, "Failed to insert supplier")
+ error(createSupplier.error, createSupplier.error.message)
)
);
}