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
merge: resolve merge with main
Rob Carrington8def08bbac54
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsxindex e27607d65a..54cbba1511 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx@@ -1,3 +1,4 @@+import { useCarbon } from "@carbon/auth";import { ValidatedForm } from "@carbon/form";import {Card,@@ -8,8 +9,10 @@ import {CardTitle,VStack,cn,+ toast,} from "@carbon/react";import { useState } from "react";+import { flushSync } from "react-dom";import type { z } from "zod";import {Currency,@@ -35,13 +38,59 @@ type QuoteFormProps = {const QuoteForm = ({ initialValues }: QuoteFormProps) => {const permissions = usePermissions();- const [customer, setCustomer] = useState<string | undefined>(- initialValues.customerId- );+ const { carbon } = useCarbon();+ const [customer, setCustomer] = useState<{+ id: string | undefined;+ currencyCode: string | undefined;+ }>({+ id: initialValues.customerId,+ currencyCode: initialValues.presentationCurrencyCode,+ });const isCustomer = permissions.is("customer");const isDisabled = initialValues?.status !== "Draft";const isEditing = initialValues.id !== undefined;+ const onCustomerChange = async (+ newValue: {+ value: string | undefined;+ label: string;+ } | null+ ) => {+ if (!carbon) {+ toast.error("Carbon client not found");+ return;+ }++ if (newValue?.value) {+ flushSync(() => {+ // update the customer immediately+ setCustomer({+ id: newValue?.value,+ currencyCode: undefined,+ });+ });++ const { data, error } = await carbon+ ?.from("customer")+ .select("currencyCode")+ .eq("id", newValue.value)+ .single();+ if (error) {+ toast.error("Error fetching customer data");+ } else {+ setCustomer((prev) => ({+ ...prev,+ currencyCode: data.currencyCode ?? undefined,+ }));+ }+ } else {+ setCustomer({+ id: undefined,+ currencyCode: undefined,+ });+ }+ };+return (<Card><ValidatedForm@@ -72,20 +121,18 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {autoFocus={!isEditing}name="customerId"label="Customer"- onChange={(newValue) =>- setCustomer(newValue?.value as string | undefined)- }+ onChange={onCustomerChange}/><Input name="customerReference" label="Customer Ref. Number" /><CustomerLocationname="customerLocationId"label="Customer Location"- customer={customer}+ customer={customer.id}/><CustomerContactname="customerContactId"label="Customer Contact"- customer={customer}+ customer={customer.id}/><Employee name="salesPersonId" label="Sales Person" /><Employee name="estimatorId" label="Estimator" />@@ -105,6 +152,15 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {<Currencyname="presentationCurrencyCode"label="Presentation Currency"+ value={customer.currencyCode}+ onChange={(newValue) => {+ if (newValue?.value) {+ setCustomer((prevCustomer) => ({+ ...prevCustomer,+ currencyCode: newValue.value,+ }));+ }+ }}/><CustomFormFields table="quote" />diff --git a/packages/form/src/components/Combobox.tsx b/packages/form/src/components/Combobox.tsxindex 8b6aadfdc0..d4391314b2 100644--- a/packages/form/src/components/Combobox.tsx+++ b/packages/form/src/components/Combobox.tsx@@ -30,7 +30,7 @@ const Combobox = ({const [value, setValue] = useControlField<string | undefined>(name);useEffect(() => {if (props.value !== null && props.value !== undefined)- setValue(props.value);+ setValue(props.value ?? "");}, [props.value, setValue]);const onChange = (value: string) => {