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
style: add read-only readableId to CustomerPartForm
Rob Carrington3852eeb930d0
diff --git a/apps/carbon/app/modules/items/items.models.ts b/apps/carbon/app/modules/items/items.models.tsindex a739688b5f..36255b830a 100644--- a/apps/carbon/app/modules/items/items.models.ts+++ b/apps/carbon/app/modules/items/items.models.ts@@ -95,7 +95,7 @@ export const consumableValidator = itemValidator.merge(export const customerPartValidator = z.object({id: zfd.text(z.string().optional()),itemId: z.string().min(1, { message: "Item ID is required" }),- customerId: z.string().min(36, { message: "Supplier ID is required" }),+ customerId: z.string().min(36, { message: "Customer is required" }),customerPartId: z.string(),customerPartRevision: zfd.text(z.string().optional()),});diff --git a/apps/carbon/app/modules/items/ui/Item/CustomerPartForm.tsx b/apps/carbon/app/modules/items/ui/Item/CustomerPartForm.tsxindex b01e3d288c..fab8f32537 100644--- a/apps/carbon/app/modules/items/ui/Item/CustomerPartForm.tsx+++ b/apps/carbon/app/modules/items/ui/Item/CustomerPartForm.tsx@@ -18,7 +18,9 @@ import { customerPartValidator } from "~/modules/items";import { path } from "~/utils/path";type CustomerPartFormProps = {- initialValues: z.infer<typeof customerPartValidator>;+ initialValues: z.infer<typeof customerPartValidator> & {+ readableId: string;+ };};const CustomerPartForm = ({ initialValues }: CustomerPartFormProps) => {@@ -59,6 +61,7 @@ const CustomerPartForm = ({ initialValues }: CustomerPartFormProps) => {<Hidden name="itemId" /><VStack spacing={4}>+ <Input name="readableId" label="Part ID" isDisabled /><Customer name="customerId" label="Customer" /><Input name="customerPartId" label="Customer Part ID" /><Inputdiff --git a/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx b/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsxindex acf1cfc304..4a184f1059 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.$customerPartToItemId.tsx@@ -7,6 +7,7 @@ import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";import {customerPartValidator,+ getItem,getItemCustomerPart,upsertItemCustomerPart,} from "~/modules/items";@@ -29,8 +30,14 @@ export async function loader({ request, params }: LoaderFunctionArgs) {companyId);+ if (!customerPart?.data) throw new Error("Could not find customer part");++ const itemData = await getItem(client, customerPart.data.itemId);+ const readableId = itemData?.data?.readableId;+return json({customerPart: customerPart?.data ?? null,+ readableId,});}@@ -74,11 +81,12 @@ export async function action({ request, params }: ActionFunctionArgs) {}export default function EditCustomerPartRoute() {- const { customerPart } = useLoaderData<typeof loader>();+ const { customerPart, readableId } = useLoaderData<typeof loader>();const initialValues = {id: customerPart?.id ?? "",itemId: customerPart?.itemId ?? "",+ readableId: readableId ?? "",customerId: customerPart?.customerId ?? "",customerPartId: customerPart?.customerPartId ?? "",customerPartRevision: customerPart?.customerPartRevision ?? "",diff --git a/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx b/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsxindex e29952871d..fe60c020af 100644--- a/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx+++ b/apps/carbon/app/routes/x+/part+/$itemId.sales.customer-parts.new.tsx@@ -2,13 +2,34 @@ import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";-import { useParams } from "@remix-run/react";-import type { ActionFunctionArgs } from "@vercel/remix";-import { redirect } from "@vercel/remix";-import { customerPartValidator, upsertItemCustomerPart } from "~/modules/items";+import { useLoaderData, useParams } from "@remix-run/react";+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";+import { json, redirect } from "@vercel/remix";+import {+ customerPartValidator,+ getItem,+ upsertItemCustomerPart,+} from "~/modules/items";import CustomerPartForm from "~/modules/items/ui/Item/CustomerPartForm";import { path } from "~/utils/path";+export async function loader({ request, params }: LoaderFunctionArgs) {+ const { client } = await requirePermissions(request, {+ view: "parts",+ role: "employee",+ });++ const { itemId } = params;+ if (!itemId) throw new Error("Could not find itemId");++ const itemData = await getItem(client, itemId);+ const readableId = itemData?.data?.readableId;++ return json({+ readableId,+ });+}+export async function action({ request, params }: ActionFunctionArgs) {assertIsPost(request);const { client, companyId } = await requirePermissions(request, {@@ -50,6 +71,7 @@ export async function action({ request, params }: ActionFunctionArgs) {export default function NewCustomerPartRoute() {const { itemId } = useParams();+ const { readableId } = useLoaderData<typeof loader>();if (!itemId) throw new Error("itemId not found");@@ -58,6 +80,7 @@ export default function NewCustomerPartRoute() {customerId: "",customerPartId: "",customerPartRevision: "",+ readableId: readableId ?? "",};return <CustomerPartForm initialValues={initialValues} />;