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
feat: custom fields for shipping method form
Brad Barbin8c9caf4581ed
diff --git a/apps/carbon/app/modules/inventory/inventory.service.ts b/apps/carbon/app/modules/inventory/inventory.service.tsindex e8f1cf2901..c37b25baed 100644--- a/apps/carbon/app/modules/inventory/inventory.service.ts+++ b/apps/carbon/app/modules/inventory/inventory.service.ts@@ -156,10 +156,12 @@ export async function upsertShippingMethod(shippingMethod:| (Omit<z.infer<typeof shippingMethodValidator>, "id"> & {createdBy: string;+ customFields?: Json;})| (Omit<z.infer<typeof shippingMethodValidator>, "id"> & {id: string;updatedBy: string;+ customFields?: Json;})) {if ("createdBy" in shippingMethod) {diff --git a/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx b/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsxindex 0508933875..ef831f3436 100644--- a/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx+++ b/apps/carbon/app/routes/x+/inventory+/shipping-methods.$shippingMethodId.tsx@@ -11,6 +11,7 @@ import {} from "~/modules/inventory";import { requirePermissions } from "~/services/auth";import { flash } from "~/services/session.server";+import { getCustomFields, setCustomFields } from "~/utils/form";import { assertIsPost, notFound } from "~/utils/http";import { path } from "~/utils/path";import { error, success } from "~/utils/result";@@ -37,8 +38,9 @@ export async function action({ request }: ActionFunctionArgs) {update: "inventory",});+ const formData = await request.formData();const validation = await validator(shippingMethodValidator).validate(- await request.formData()+ formData);if (validation.error) {@@ -52,6 +54,7 @@ export async function action({ request }: ActionFunctionArgs) {id,...data,updatedBy: userId,+ customFields: setCustomFields(formData),});if (updateShippingMethod.error) {@@ -79,6 +82,7 @@ export default function EditShippingMethodsRoute() {carrier: (shippingMethod?.carrier ?? "") as ShippingCarrier,carrierAccountId: shippingMethod?.carrierAccountId ?? "",trackingUrl: shippingMethod?.trackingUrl ?? "",+ ...getCustomFields(shippingMethod?.customFields),};return (diff --git a/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx b/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsxindex 8a817f5867..ea4362532e 100644--- a/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx+++ b/apps/carbon/app/routes/x+/inventory+/shipping-methods.new.tsx@@ -9,6 +9,7 @@ import {} from "~/modules/inventory";import { requirePermissions } from "~/services/auth";import { flash } from "~/services/session.server";+import { setCustomFields } from "~/utils/form";import { assertIsPost } from "~/utils/http";import { path } from "~/utils/path";import { error, success } from "~/utils/result";@@ -27,22 +28,21 @@ export async function action({ request }: ActionFunctionArgs) {create: "inventory",});+ const formData = await request.formData();const validation = await validator(shippingMethodValidator).validate(- await request.formData()+ formData);if (validation.error) {return validationError(validation.error);}- const { name, carrier, carrierAccountId, trackingUrl } = validation.data;+ const { id, ...data } = validation.data;const insertShippingMethod = await upsertShippingMethod(client, {- name,- carrier,- carrierAccountId,- trackingUrl,+ ...data,createdBy: userId,+ customFields: setCustomFields(formData),});if (insertShippingMethod.error) {return json(