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: add supplier delete route

Brad Barbin70da216b9adb
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx
index 2ab2c188da..42cee06490 100644
--- a/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SuppliersTable.tsx
@@ -285,7 +285,7 @@ const SuppliersTable = memo(
}}
>
<MenuIcon icon={<LuTrash />} />
- Delete
+ Delete Supplier
</MenuItem>
</>
),
diff --git a/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx b/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx
index 025af7622c..95b8503598 100644
--- a/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx
+++ b/apps/erp/app/modules/sales/ui/Customers/CustomersTable.tsx
@@ -257,7 +257,7 @@ const CustomersTable = memo(
}}
>
<MenuIcon icon={<LuTrash />} />
- Delete
+ Delete Customer
</MenuItem>
</>
),
diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.delete.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.delete.tsx
new file mode 100644
index 0000000000..ecf6a09b25
--- /dev/null
+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.delete.tsx
@@ -0,0 +1,31 @@
+import { assertIsPost, error } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import { flash } from "@carbon/auth/session.server";
+import type { ActionFunctionArgs } from "react-router";
+import { data, redirect } from "react-router";
+import { deleteSupplier } from "~/modules/purchasing";
+import { path } from "~/utils/path";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client } = await requirePermissions(request, {
+ delete: "purchasing"
+ });
+
+ const { supplierId } = params;
+ if (!supplierId) throw new Error("Could not find supplierId");
+
+ const supplierDelete = await deleteSupplier(client, supplierId);
+
+ if (supplierDelete.error) {
+ return data(
+ path.to.suppliers,
+ await flash(
+ request,
+ error(supplierDelete.error, supplierDelete.error.message)
+ )
+ );
+ }
+
+ throw redirect(path.to.suppliers);
+}