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: load default customer data
Brad Barbin98fca61ba22e
diff --git a/apps/carbon/app/components/Table/Table.tsx b/apps/carbon/app/components/Table/Table.tsxindex 3f46c1c320..e8917652c3 100644--- a/apps/carbon/app/components/Table/Table.tsx+++ b/apps/carbon/app/components/Table/Table.tsx@@ -575,14 +575,35 @@ const Table = <T extends object>({<div className="flex max-w-full h-full">{rows.length === 0 ? (navigation.state === "loading" ? (- <div className="flex h-full w-full items-center justify-center">+ <div className="flex h-full w-full items-start justify-center"><TableBase className="w-full">+ <Thead>+ <Tr>+ {Array.from({ length: 7 }).map((_, colIndex) => (+ <Th+ key={colIndex}+ className={cn(+ "h-[44px] w-[200px]",+ colIndex === 0 && "border-r border-border"+ )}+ >+ <div className="h-8" />+ </Th>+ ))}+ </Tr>+ </Thead><Tbody>{Array.from({ length: 30 }).map((_, rowIndex) => (<Tr key={rowIndex}>- {Array.from({ length: 10 }).map((_, colIndex) => (- <Td key={colIndex} className="p-2 h-[44px] w-[150px]">- <div className="h-8 bg-gradient-to-r from-foreground/10 to-foreground/10 rounded animate-pulse" />+ {Array.from({ length: 7 }).map((_, colIndex) => (+ <Td+ key={colIndex}+ className={cn(+ "h-[44px] w-[200px]",+ colIndex === 0 && "border-r border-border"+ )}+ >+ <div className="h-6 w-full bg-gradient-to-r from-foreground/10 to-foreground/10 rounded animate-pulse" /></Td>))}</Tr>diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsxindex 135ae5ee69..064acdab6b 100644--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerShippingForm.tsx@@ -5,7 +5,6 @@ import {CardHeader,CardTitle,HStack,- VStack,} from "@carbon/react";import { ValidatedForm } from "@carbon/remix-validated-form";import { useState } from "react";@@ -14,6 +13,7 @@ import {Customer,CustomerContact,CustomerLocation,+ CustomFormFields,Hidden,Select,Submit,@@ -65,35 +65,33 @@ const CustomerShippingForm = ({ initialValues }: CustomerShippingFormProps) => {<CardContent><Hidden name="customerId" /><div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">- <VStack>- <Customer- name="shippingCustomerId"- label="Shipping Customer"- onChange={(value) => setCustomer(value?.value as string)}- />- <CustomerLocation- name="shippingCustomerLocationId"- label="Shipping Location"- customer={customer}- />- <CustomerContact- name="shippingCustomerContactId"- label="Shipping Contact"- customer={customer}- />- </VStack>- <VStack>- <Select- name="shippingMethodId"- label="Shipping Method"- options={shippingMethodOptions}- />- <Select- name="shippingTermId"- label="Shipping Term"- options={shippingTermOptions}- />- </VStack>+ <Customer+ name="shippingCustomerId"+ label="Shipping Customer"+ onChange={(value) => setCustomer(value?.value as string)}+ />+ <CustomerLocation+ name="shippingCustomerLocationId"+ label="Shipping Location"+ customer={customer}+ />+ <CustomerContact+ name="shippingCustomerContactId"+ label="Shipping Contact"+ customer={customer}+ />++ <Select+ name="shippingMethodId"+ label="Shipping Method"+ options={shippingMethodOptions}+ />+ <Select+ name="shippingTermId"+ label="Shipping Term"+ options={shippingTermOptions}+ />+ <CustomFormFields table="customerShipping" /></div></CardContent><CardFooter>diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsxindex 902ef484ae..db4e8ee0c5 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx@@ -127,7 +127,10 @@ const QuoteHeader = () => {<ButtonleftIcon={<LuTrophy />}variant="primary"- onClick={convertToOrderModal.onOpen}+ onClick={() => {+ new Audio("/audio/airhorn.mp3").play();+ convertToOrderModal.onOpen();+ }}>Won</Button>diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsxindex face5b2a14..5f9afc7eae 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx@@ -1,3 +1,4 @@+import type { Database } from "@carbon/database";import {Button,cn,@@ -23,7 +24,8 @@ import {VStack,} from "@carbon/react";import { Form } from "@remix-run/react";-import { useMemo, useState } from "react";+import type { Dispatch, SetStateAction } from "react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useDropzone } from "react-dropzone";import {LuBan,@@ -35,6 +37,7 @@ import {LuUserSquare,} from "react-icons/lu";import { useCurrencyFormatter } from "~/hooks/useCurrencyFormatter";+import { useSupabase } from "~/lib/supabase";import { path } from "~/utils/path";import type { Quotation, QuotationLine, QuotationPrice } from "../../types";@@ -46,6 +49,10 @@ type QuoteToOrderDrawerProps = {onClose: () => void;};+type Customer = Database["public"]["Tables"]["customer"]["Row"];+type CustomerPayment = Database["public"]["Tables"]["customerPayment"]["Row"];+type CustomerShipping = Database["public"]["Tables"]["customerShipping"]["Row"];+const QuoteToOrderDrawer = ({isOpen,quote,@@ -66,13 +73,54 @@ const QuoteToOrderDrawer = ({}>>({});- const [customerDetails, setCustomerDetails] = useState({});- const [paymentDetails, setPaymentDetails] = useState({- // Add default payment details from customerPayment table- });- const [shippingDetails, setShippingDetails] = useState({- // Add default shipping details from customerShipping table- });+ const [customerDetails, setCustomerDetails] = useState<Customer | null>(null);+ const [paymentDetails, setPaymentDetails] = useState<CustomerPayment | null>(+ null+ );+ const [shippingDetails, setShippingDetails] =+ useState<CustomerShipping | null>(null);++ const { supabase } = useSupabase();+ const fetching = useRef(false);+ const fetchCustomerDetails = useCallback(async () => {+ if (!supabase) return;+ if (fetching.current) return false;+ if (customerDetails || paymentDetails || shippingDetails) return;++ fetching.current = true;+ const [customer, payment, shipping] = await Promise.all([+ supabase+ .from("customer")+ .select("*")+ .eq("id", quote.customerId!)+ .single(),+ supabase+ .from("customerPayment")+ .select("*")+ .eq("customerId", quote.customerId!)+ .single(),+ supabase+ .from("customerShipping")+ .select("*")+ .eq("customerId", quote.customerId!)+ .single(),+ ]);++ setCustomerDetails(customer.data);+ setPaymentDetails(payment.data);+ setShippingDetails(shipping.data);+ fetching.current = false;+ }, [+ customerDetails,+ paymentDetails,+ quote.customerId,+ shippingDetails,+ supabase,+ ]);++ useEffect(() => {+ if (isOpen) fetchCustomerDetails();+ }, [fetchCustomerDetails, isOpen]);const onDrop = (acceptedFiles: File[]) => {if (acceptedFiles.length > 0) {@@ -206,8 +254,8 @@ export default QuoteToOrderDrawer;type LinePricingFormProps = {lines: QuotationLine[];pricing: QuotationPrice[];- setSelectedLines: React.Dispatch<- React.SetStateAction<+ setSelectedLines: Dispatch<+ SetStateAction<Record<string,{@@ -276,8 +324,8 @@ type LinePricingOptionsProps = {line: QuotationLine;options: QuotationPrice[];formatter: Intl.NumberFormat;- setSelectedLines: React.Dispatch<- React.SetStateAction<+ setSelectedLines: Dispatch<+ SetStateAction<Record<string,{@@ -469,10 +517,10 @@ const LinePricingOptions = ({);};-interface PaymentDetailsFormProps {- paymentDetails: PaymentDetails;- setPaymentDetails: React.Dispatch<React.SetStateAction<PaymentDetails>>;-}+type PaymentDetailsFormProps = {+ paymentDetails: CustomerPayment | null;+ setPaymentDetails: Dispatch<SetStateAction<CustomerPayment | null>>;+};function PaymentDetailsForm({paymentDetails,@@ -494,14 +542,18 @@ function PaymentDetailsForm({className={`transition-transform ${isExpanded ? "rotate-180" : ""}`}/></HStack>- {isExpanded && <div className="py-4"></div>}+ {isExpanded && (+ <div className="py-4">+ <pre>{JSON.stringify(paymentDetails, null, 2)}</pre>+ </div>+ )}</div>);}-interface CustomerDetailsFormProps {- customerDetails: CustomerDetails;- setCustomerDetails: React.Dispatch<React.SetStateAction<CustomerDetails>>;-}+type CustomerDetailsFormProps = {+ customerDetails: Customer | null;+ setCustomerDetails: Dispatch<SetStateAction<Customer | null>>;+};function CustomerDetailsForm({customerDetails,@@ -523,15 +575,19 @@ function CustomerDetailsForm({className={`transition-transform ${isExpanded ? "rotate-180" : ""}`}/></HStack>- {isExpanded && <div className="py-4"></div>}+ {isExpanded && (+ <div className="py-4">+ <pre>{JSON.stringify(customerDetails, null, 2)}</pre>+ </div>+ )}</div>);}-interface ShippingDetailsFormProps {- shippingDetails: ShippingDetails;- setShippingDetails: React.Dispatch<React.SetStateAction<ShippingDetails>>;-}+type ShippingDetailsFormProps = {+ shippingDetails: CustomerShipping | null;+ setShippingDetails: Dispatch<SetStateAction<CustomerShipping | null>>;+};function ShippingDetailsForm({shippingDetails,@@ -553,7 +609,11 @@ function ShippingDetailsForm({className={`transition-transform ${isExpanded ? "rotate-180" : ""}`}/></HStack>- {isExpanded && <div className="py-4"></div>}+ {isExpanded && (+ <div className="py-4">+ <pre>{JSON.stringify(shippingDetails, null, 2)}</pre>+ </div>+ )}</div>);}diff --git a/apps/carbon/public/audio/airhorn.mp3 b/apps/carbon/public/audio/airhorn.mp3new file mode 100644index 0000000000..cae9fdcdc2Binary files /dev/null and b/apps/carbon/public/audio/airhorn.mp3 differdiff --git a/apps/carbon/public/audio/ding.mp3 b/apps/carbon/public/audio/ding.mp3new file mode 100644index 0000000000..b80207221cBinary files /dev/null and b/apps/carbon/public/audio/ding.mp3 differ