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: inline editing for document headers
Brad Barbinc37f3f441d1d
diff --git a/apps/carbon/app/components/Form/Currency.tsx b/apps/carbon/app/components/Form/Currency.tsxindex 9e1a246d8d..71b62b97c1 100644--- a/apps/carbon/app/components/Form/Currency.tsx+++ b/apps/carbon/app/components/Form/Currency.tsx@@ -6,13 +6,29 @@ import { useMemo } from "react";import type { getCurrenciesList } from "~/modules/accounting";import { path } from "~/utils/path";-type CurrencySelectProps = Omit<ComboboxProps, "options">;+type CurrencySelectProps = Omit<ComboboxProps, "options" | "inline"> & {+ inline?: boolean;+};++const CurrencyPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const currency = options.find((o) => o.value === value);+ if (!currency) return null;+ return <span>{currency.label}</span>;+};-const Currency = ({ ...props }: CurrencySelectProps) => {+const Currency = ({ inline, ...props }: CurrencySelectProps) => {const options = useCurrencyCodes();return (- <Combobox {...props} options={options} label={props?.label ?? "Currency"} />+ <Combobox+ {...props}+ inline={inline ? CurrencyPreview : undefined}+ options={options}+ label={props?.label ?? "Currency"}+ />);};diff --git a/apps/carbon/app/components/Form/Customer.tsx b/apps/carbon/app/components/Form/Customer.tsxindex 8e2e9adcf8..5f3b723a96 100644--- a/apps/carbon/app/components/Form/Customer.tsx+++ b/apps/carbon/app/components/Form/Customer.tsx@@ -1,12 +1,25 @@-import type { ComboboxProps } from "@carbon/form";+import type { CreatableComboboxProps } from "@carbon/form";import { CreatableCombobox } from "@carbon/form";import { useDisclosure } from "@carbon/react";import { useMemo, useRef, useState } from "react";import { useUser } from "~/hooks";import { CustomerForm } from "~/modules/sales";import { useCustomers } from "~/stores";+import CustomerAvatar from "../CustomerAvatar";-type CustomerSelectProps = Omit<ComboboxProps, "options">;+type CustomerSelectProps = Omit<+ CreatableComboboxProps,+ "options" | "inline"+> & {+ inline?: boolean;+};++const CustomerPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ return <CustomerAvatar customerId={value} />;+};const Customer = (props: CustomerSelectProps) => {const [customers] = useCustomers();@@ -32,6 +45,7 @@ const Customer = (props: CustomerSelectProps) => {options={options}{...props}label={props?.label ?? "Customer"}+ inline={props?.inline ? CustomerPreview : undefined}onCreateOption={(option) => {newCustomersModal.onOpen();setCreated(option);diff --git a/apps/carbon/app/components/Form/CustomerContact.tsx b/apps/carbon/app/components/Form/CustomerContact.tsxindex 4f13b8a343..90cf6fad95 100644--- a/apps/carbon/app/components/Form/CustomerContact.tsx+++ b/apps/carbon/app/components/Form/CustomerContact.tsx@@ -8,15 +8,32 @@ import { path } from "~/utils/path";import type { ComboboxProps } from "@carbon/form";import { CreatableCombobox } from "@carbon/form";-import { useDisclosure } from "@carbon/react";+import { Avatar, HStack, useDisclosure } from "@carbon/react";import { CustomerContactForm } from "~/modules/sales";type CustomerContactSelectProps = Omit<ComboboxProps,- "options" | "onChange"+ "options" | "onChange" | "inline"> & {customer?: string;- onChange?: (customer: CustomerContactType["contact"] | null) => void;+ onChange?: (+ customer: { id: string; contact: CustomerContactType["contact"] } | null+ ) => void;+ inline?: boolean;+};++const CustomerContactPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const contact = options.find((o) => o.value === value);+ if (!contact) return null;+ return (+ <HStack>+ <Avatar size="xs" name={contact.label} />+ <span>{contact.label}</span>+ </HStack>+ );};const CustomerContact = (props: CustomerContactSelectProps) => {@@ -54,7 +71,7 @@ const CustomerContact = (props: CustomerContactSelectProps) => {(contact) => contact.id === newValue?.value) ?? null;- props.onChange?.(contact?.contact ?? null);+ props.onChange?.(contact ?? null);};return (@@ -63,6 +80,7 @@ const CustomerContact = (props: CustomerContactSelectProps) => {ref={triggerRef}options={options}{...props}+ inline={props.inline ? CustomerContactPreview : undefined}label={props?.label ?? "Customer Contact"}onChange={onChange}onCreateOption={(option) => {diff --git a/apps/carbon/app/components/Form/CustomerLocation.tsx b/apps/carbon/app/components/Form/CustomerLocation.tsxindex dac925b76a..ea10584d80 100644--- a/apps/carbon/app/components/Form/CustomerLocation.tsx+++ b/apps/carbon/app/components/Form/CustomerLocation.tsx@@ -14,12 +14,22 @@ import { formatAddress } from "@carbon/utils";type CustomerLocationSelectProps = Omit<ComboboxProps,- "options" | "onChange"+ "options" | "onChange" | "inline"> & {customer?: string;+ inline?: boolean;onChange?: (customer: CustomerLocationType | null) => void;};+const CustomerLocationPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const location = options.find((o) => o.value === value);+ if (!location) return null;+ return <span>{location.label}</span>;+};+const CustomerLocation = (props: CustomerLocationSelectProps) => {const customerLocationsFetcher =useFetcher<Awaited<ReturnType<typeof getCustomerLocations>>>();@@ -67,6 +77,7 @@ const CustomerLocation = (props: CustomerLocationSelectProps) => {ref={triggerRef}options={options}{...props}+ inline={props?.inline ? CustomerLocationPreview : undefined}label={props?.label ?? "Customer Location"}onChange={onChange}onCreateOption={(option) => {diff --git a/apps/carbon/app/components/Form/Employee.tsx b/apps/carbon/app/components/Form/Employee.tsxindex d37cd33e25..6fb838240a 100644--- a/apps/carbon/app/components/Form/Employee.tsx+++ b/apps/carbon/app/components/Form/Employee.tsx@@ -2,12 +2,24 @@ import type { ComboboxProps } from "@carbon/form";import { Combobox } from "@carbon/form";import { useMemo } from "react";import { usePeople } from "~/stores";+import EmployeeAvatar from "../EmployeeAvatar";-type EmployeeSelectProps = Omit<ComboboxProps, "options" | "type"> & {+type EmployeeSelectProps = Omit<+ ComboboxProps,+ "options" | "type" | "inline"+> & {type?: "assignee";+ inline?: boolean;};-const Employee = ({ type, ...props }: EmployeeSelectProps) => {+const EmployeePreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ return <EmployeeAvatar employeeId={value} />;+};++const Employee = ({ type, inline, ...props }: EmployeeSelectProps) => {const [people] = usePeople();const options = useMemo(() => {@@ -29,6 +41,7 @@ const Employee = ({ type, ...props }: EmployeeSelectProps) => {<Comboboxoptions={options}{...props}+ inline={inline ? EmployeePreview : undefined}label={props?.label ?? "Employee"}placeholder={props?.placeholder ?? "Select Employee"}/>diff --git a/apps/carbon/app/components/Form/ExchangeRate.tsx b/apps/carbon/app/components/Form/ExchangeRate.tsxindex a4e4a6451c..594752ebd5 100644--- a/apps/carbon/app/components/Form/ExchangeRate.tsx+++ b/apps/carbon/app/components/Form/ExchangeRate.tsx@@ -5,20 +5,25 @@ import {Tooltip,TooltipContent,TooltipTrigger,+ VStack,} from "@carbon/react";import { useLocale } from "@react-aria/i18n";import React, { useMemo } from "react";import { LuInfo, LuRefreshCw } from "react-icons/lu";-import { Input } from "~/components/Form";+import { NumberControlled } from "~/components/Form";-interface ExchangeRateProps extends React.ComponentProps<typeof Input> {+interface ExchangeRateProps+ extends React.ComponentProps<typeof NumberControlled> {+ inline?: boolean;onRefresh?: () => void;exchangeRateUpdatedAt: string | undefined;}const ExchangeRate: React.FC<ExchangeRateProps> = ({onRefresh,+ inline = false,exchangeRateUpdatedAt,+ value,...props}) => {const { locale } = useLocale();@@ -39,10 +44,12 @@ const ExchangeRate: React.FC<ExchangeRateProps> = ({return (<div className="relative"><HStack spacing={0} className="items-end">- <Input- label={- <HStack spacing={1}>- <span>Exchange Rate</span>+ {inline ? (+ <VStack spacing={2}>+ <HStack className="w-full justify-between">+ <span className="text-xs text-muted-foreground">+ Exchange Rate+ </span>{exchangeRateUpdatedAt && (<Tooltip><TooltipTrigger tabIndex={-1}>@@ -52,11 +59,34 @@ const ExchangeRate: React.FC<ExchangeRateProps> = ({</Tooltip>)}</HStack>- }- {...props}- isReadOnly- className={cn("z-10", onRefresh ? "rounded-r-none" : "")}- />+ <HStack className="w-full justify-between">+ <span>{value}</span>+ </HStack>+ </VStack>+ ) : (+ <NumberControlled+ label={+ <HStack spacing={1}>+ <span>Exchange Rate</span>+ {exchangeRateUpdatedAt && (+ <Tooltip>+ <TooltipTrigger tabIndex={-1}>+ <LuInfo className="w-4 h-4" />+ </TooltipTrigger>+ <TooltipContent>+ Last updated: {formattedDate}+ </TooltipContent>+ </Tooltip>+ )}+ </HStack>+ }+ {...props}+ value={value}+ isReadOnly+ className={cn("z-10", onRefresh ? "rounded-r-none" : "")}+ />+ )}+{onRefresh && (<IconButtonaria-label="Refresh exchange rate"diff --git a/apps/carbon/app/components/Form/Item.tsx b/apps/carbon/app/components/Form/Item.tsxindex 09bc14c7fa..4dd1e575f9 100644--- a/apps/carbon/app/components/Form/Item.tsx+++ b/apps/carbon/app/components/Form/Item.tsx@@ -13,6 +13,9 @@ import {FormHelperText,FormLabel,IconButton,+ Tooltip,+ TooltipContent,+ TooltipTrigger,useDisclosure,} from "@carbon/react";import { useEffect, useMemo, useRef, useState } from "react";@@ -27,9 +30,10 @@ import { methodItemType, type MethodItemType } from "~/modules/shared";import { useItems } from "~/stores";import { MethodItemTypeIcon } from "../Icons";-type ItemSelectProps = Omit<ComboboxProps, "options" | "type"> & {+type ItemSelectProps = Omit<ComboboxProps, "options" | "type" | "inline"> & {disabledItems?: string[];includeInactive?: boolean;+ inline?: boolean;replenishmentSystem?: "Buy" | "Make";type: MethodItemType;typeFieldName?: string;@@ -37,6 +41,15 @@ type ItemSelectProps = Omit<ComboboxProps, "options" | "type"> & {onTypeChange?: (type: MethodItemType) => void;};+const ItemPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const item = options.find((o) => o.value === value);+ if (!item) return null;+ return <span>{item.label}</span>;+};+const Item = ({name,label,@@ -140,6 +153,7 @@ const Item = ({ref={triggerRef}options={options}{...props}+ inline={props.inline ? ItemPreview : undefined}value={value?.replace(/"/g, '\\"')}onChange={(newValue) => {setValue(newValue?.replace(/"/g, '\\"') ?? "");@@ -155,17 +169,28 @@ const Item = ({/>{canSwitchItemType && (<DropdownMenu>- <DropdownMenuTrigger asChild>- <IconButton- type="button"- aria-label="Change Type"- className="bg-transparent flex-shrink-0 h-10 w-10 px-3 rounded-l-none border-l-0 shadow-sm"- disabled={props.isReadOnly}- variant="secondary"- size="lg"- icon={<MethodItemTypeIcon type={type} />}- />- </DropdownMenuTrigger>+ <Tooltip>+ <TooltipTrigger>+ <DropdownMenuTrigger asChild>+ <IconButton+ type="button"+ aria-label="Change Type"+ className={cn(+ props.inline === true+ ? "ml-1"+ : "bg-transparent flex-shrink-0 h-10 w-10 px-3 rounded-l-none border-l-0 shadow-sm"+ )}+ disabled={props.isReadOnly}+ variant="secondary"+ size={props.inline ? "sm" : "lg"}+ icon={<MethodItemTypeIcon type={type} />}+ />+ </DropdownMenuTrigger>+ </TooltipTrigger>+ <TooltipContent>+ Change the item type (e.g. Part, Material, Tool, etc.)+ </TooltipContent>+ </Tooltip><DropdownMenuContent>{Object.values(methodItemType).filter(diff --git a/apps/carbon/app/components/Form/Location.tsx b/apps/carbon/app/components/Form/Location.tsxindex e6f4538cab..47c1369f15 100644--- a/apps/carbon/app/components/Form/Location.tsx+++ b/apps/carbon/app/components/Form/Location.tsx@@ -1,4 +1,4 @@-import type { ComboboxProps } from "@carbon/form";+import type { CreatableComboboxProps } from "@carbon/form";import { CreatableCombobox } from "@carbon/form";import { useDisclosure, useMount } from "@carbon/react";import { getLocalTimeZone } from "@internationalized/date";@@ -9,9 +9,22 @@ import type { getLocationsList } from "~/modules/resources";import { LocationForm } from "~/modules/resources";import { path } from "~/utils/path";-type LocationSelectProps = Omit<ComboboxProps, "options">;+type LocationSelectProps = Omit<+ CreatableComboboxProps,+ "options" | "inline"+> & {+ inline?: boolean;+};++const LocationPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const location = options.find((o) => o.value === value);+ return <span>{location?.label}</span>;+};-const Location = (props: LocationSelectProps) => {+const Location = ({ inline = false, ...props }: LocationSelectProps) => {const newLocationModal = useDisclosure();const [created, setCreated] = useState<string>("");const triggerRef = useRef<HTMLButtonElement>(null);@@ -27,6 +40,7 @@ const Location = (props: LocationSelectProps) => {options={options}{...props}label={props?.label ?? "Location"}+ inline={inline ? LocationPreview : undefined}onCreateOption={(option) => {newLocationModal.onOpen();setCreated(option);diff --git a/apps/carbon/app/components/Form/Supplier.tsx b/apps/carbon/app/components/Form/Supplier.tsxindex 0a5ae9dbef..17e375b300 100644--- a/apps/carbon/app/components/Form/Supplier.tsx+++ b/apps/carbon/app/components/Form/Supplier.tsx@@ -1,44 +1,54 @@-import type { ComboboxProps } from "@carbon/form";-import { Combobox, CreatableCombobox } from "@carbon/form";+import type { CreatableComboboxProps } from "@carbon/form";+import { CreatableCombobox } from "@carbon/form";import { useDisclosure } from "@carbon/react";import { useMemo, useRef, useState } from "react";import { useUser } from "~/hooks";import { SupplierForm } from "~/modules/purchasing";import { useSuppliers } from "~/stores";+import SupplierAvatar from "../SupplierAvatar";-type SupplierSelectProps = Omit<ComboboxProps, "options"> & {+type SupplierSelectProps = Omit<+ CreatableComboboxProps,+ "options" | "inline"+> & {+ inline?: boolean;allowedSuppliers?: string[];};+const SupplierPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ return <SupplierAvatar supplierId={value} />;+};+const Supplier = ({ allowedSuppliers, ...props }: SupplierSelectProps) => {const [suppliers] = useSuppliers();const newSuppliersModal = useDisclosure();const [created, setCreated] = useState<string>("");const triggerRef = useRef<HTMLButtonElement>(null);- const options = useMemo(() => {- const result =- suppliers.map((c) => ({- value: c.id,- label: c.name,- })) ?? [];- if (allowedSuppliers) {- return result.filter((c) => allowedSuppliers.includes(c.value));- }- return result;- }, [suppliers, allowedSuppliers]);+ const options = useMemo(+ () =>+ suppliers+ .filter((s) => !allowedSuppliers || allowedSuppliers.includes(s.id))+ .map((c) => ({+ value: c.id,+ label: c.name,+ })) ?? [],+ [suppliers, allowedSuppliers]+ );const { company } = useUser();- return allowedSuppliers ? (- <Combobox options={options} {...props} label={props?.label ?? "Supplier"} />- ) : (+ return (<><CreatableComboboxref={triggerRef}options={options}{...props}label={props?.label ?? "Supplier"}+ inline={props?.inline ? SupplierPreview : undefined}onCreateOption={(option) => {newSuppliersModal.onOpen();setCreated(option);diff --git a/apps/carbon/app/components/Form/SupplierContact.tsx b/apps/carbon/app/components/Form/SupplierContact.tsxindex 1c41f85199..b6ab827bcd 100644--- a/apps/carbon/app/components/Form/SupplierContact.tsx+++ b/apps/carbon/app/components/Form/SupplierContact.tsx@@ -1,6 +1,3 @@-import type { ComboboxProps } from "@carbon/form";-import { CreatableCombobox } from "@carbon/form";-import { useDisclosure } from "@carbon/react";import { useFetcher } from "@remix-run/react";import { useEffect, useMemo, useRef, useState } from "react";import type {@@ -9,14 +6,34 @@ import type {} from "~/modules/purchasing";import { path } from "~/utils/path";+import type { ComboboxProps } from "@carbon/form";+import { CreatableCombobox } from "@carbon/form";+import { Avatar, HStack, useDisclosure } from "@carbon/react";import { SupplierContactForm } from "~/modules/purchasing";type SupplierContactSelectProps = Omit<ComboboxProps,- "options" | "onChange"+ "options" | "onChange" | "inline"> & {supplier?: string;- onChange?: (supplier: SupplierContactType["contact"] | null) => void;+ onChange?: (+ supplier: { id: string; contact: SupplierContactType["contact"] } | null+ ) => void;+ inline?: boolean;+};++const SupplierContactPreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const contact = options.find((o) => o.value === value);+ if (!contact) return null;+ return (+ <HStack>+ <Avatar size="xs" name={contact.label} />+ <span>{contact.label}</span>+ </HStack>+ );};const SupplierContact = (props: SupplierContactSelectProps) => {@@ -54,7 +71,7 @@ const SupplierContact = (props: SupplierContactSelectProps) => {(contact) => contact.id === newValue?.value) ?? null;- props.onChange?.(contact?.contact ?? null);+ props.onChange?.(contact ?? null);};return (@@ -63,6 +80,7 @@ const SupplierContact = (props: SupplierContactSelectProps) => {ref={triggerRef}options={options}{...props}+ inline={props.inline ? SupplierContactPreview : undefined}label={props?.label ?? "Supplier Contact"}onChange={onChange}onCreateOption={(option) => {diff --git a/apps/carbon/app/components/Form/SupplierLocation.tsx b/apps/carbon/app/components/Form/SupplierLocation.tsxindex 200a21cc04..3a24c162ca 100644--- a/apps/carbon/app/components/Form/SupplierLocation.tsx+++ b/apps/carbon/app/components/Form/SupplierLocation.tsx@@ -13,7 +13,7 @@ import { path } from "~/utils/path";type SupplierLocationSelectProps = Omit<ComboboxProps,- "options" | "onChange"+ "options" | "onChange" | "inline"> & {supplier?: string;onChange?: (supplier: SupplierLocationType | null) => void;diff --git a/apps/carbon/app/components/Form/UnitOfMeasure.tsx b/apps/carbon/app/components/Form/UnitOfMeasure.tsxindex 9b39261760..2d4347a24e 100644--- a/apps/carbon/app/components/Form/UnitOfMeasure.tsx+++ b/apps/carbon/app/components/Form/UnitOfMeasure.tsx@@ -10,8 +10,19 @@ import type {} from "~/modules/items";import { UnitOfMeasureForm } from "~/modules/items";import { path } from "~/utils/path";+import { Enumerable } from "../Enumerable";-type UnitOfMeasureSelectProps = Omit<ComboboxProps, "options">;+type UnitOfMeasureSelectProps = Omit<ComboboxProps, "options" | "inline"> & {+ inline?: boolean;+};++const UnitOfMeasurePreview = (+ value: string,+ options: { value: string; label: string }[]+) => {+ const uom = options.find((o) => o.value === value);+ return <Enumerable value={uom?.label ?? null} />;+};const UnitOfMeasure = (props: UnitOfMeasureSelectProps) => {const options = useUnitOfMeasure();@@ -26,6 +37,7 @@ const UnitOfMeasure = (props: UnitOfMeasureSelectProps) => {ref={triggerRef}options={options}{...props}+ inline={props.inline ? UnitOfMeasurePreview : undefined}label={props?.label ?? "Unit of Measure"}onCreateOption={(option) => {newUnitOfMeasureModal.onOpen();diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsxindex 2a1710a368..2f1c318f91 100644--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx@@ -84,7 +84,7 @@ const ConsumableProperties = () => {return (<VStackspacing={4}- className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"+ className="w-96 bg-background h-full overflow-y-auto border-l border-border px-4 py-2"><VStack spacing={2}><HStack className="w-full justify-between">diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsxindex fea9f6ac1a..6dc7ffa2ac 100644--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx@@ -92,7 +92,7 @@ const FixtureProperties = () => {return (<VStackspacing={4}- className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"+ className="w-96 bg-background h-full overflow-y-auto border-l border-border px-4 py-2"><VStack spacing={2}><HStack className="w-full justify-between">diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsxindex 72142df528..f75b7182d6 100644--- a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx@@ -1,3 +1,4 @@+import { ValidatedForm } from "@carbon/form";import {Badge,Button,@@ -17,8 +18,10 @@ import {import { Await, useFetcher, useParams } from "@remix-run/react";import { Suspense, useCallback, useEffect } from "react";import { LuCopy, LuLink } from "react-icons/lu";+import { z } from "zod";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/components";import { Enumerable } from "~/components/Enumerable";+import { UnitOfMeasure } from "~/components/Form";import { ItemThumbnailUpload } from "~/components/ItemThumnailUpload";import { useRouteData } from "~/hooks";import { methodType } from "~/modules/shared";@@ -65,14 +68,18 @@ const MaterialProperties = () => {}, [fetcher.data]);const onUpdate = useCallback((- field: "replenishmentSystem" | "defaultMethodType" | "itemTrackingType",- value: string+ field:+ | "replenishmentSystem"+ | "defaultMethodType"+ | "itemTrackingType"+ | "unitOfMeasureCode",+ value: string | null) => {const formData = new FormData();formData.append("items", itemId);formData.append("field", field);- formData.append("value", value);+ formData.append("value", value?.toString() ?? "");fetcher.submit(formData, {method: "post",action: path.to.bulkUpdateItems,@@ -84,7 +91,7 @@ const MaterialProperties = () => {return (<VStackspacing={4}- className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"+ className="w-96 bg-background h-full overflow-y-auto border-l border-border px-4 py-2"><VStack spacing={2}><HStack className="w-full justify-between">@@ -218,10 +225,27 @@ const MaterialProperties = () => {/></VStack>- <VStack spacing={2}>- <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>- <Enumerable value={routeData?.materialSummary?.unitOfMeasure ?? null} />- </VStack>+ <ValidatedForm+ defaultValues={{+ unitOfMeasureCode:+ routeData?.materialSummary?.unitOfMeasureCode ?? undefined,+ }}+ validator={z.object({+ unitOfMeasureCode: z+ .string()+ .min(1, { message: "Unit of Measure is required" }),+ })}+ className="w-full"+ >+ <UnitOfMeasure+ label="Unit of Measure"+ name="unitOfMeasureCode"+ inline+ onChange={(value) => {+ onUpdate("unitOfMeasureCode", value?.value ?? null);+ }}+ />+ </ValidatedForm><VStack spacing={2}><HStack className="w-full justify-between">diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsxindex 33ca0cdc3c..9632334c91 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx@@ -1,3 +1,4 @@+import { ValidatedForm } from "@carbon/form";import {Badge,Button,@@ -17,8 +18,10 @@ import {import { Await, Link, useFetcher, useParams } from "@remix-run/react";import { Suspense, useCallback, useEffect } from "react";import { LuCopy, LuExternalLink, LuLink, LuMove3D } from "react-icons/lu";+import { z } from "zod";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/components";import { Enumerable } from "~/components/Enumerable";+import { UnitOfMeasure } from "~/components/Form";import { ItemThumbnailUpload } from "~/components/ItemThumnailUpload";import { useRouteData } from "~/hooks";import { methodType } from "~/modules/shared";@@ -68,14 +71,18 @@ const PartProperties = () => {}, [fetcher.data]);const onUpdate = useCallback((- field: "replenishmentSystem" | "defaultMethodType" | "itemTrackingType",- value: string+ field:+ | "replenishmentSystem"+ | "defaultMethodType"+ | "itemTrackingType"+ | "unitOfMeasureCode",+ value: string | null) => {const formData = new FormData();formData.append("items", itemId);formData.append("field", field);- formData.append("value", value);+ formData.append("value", value?.toString() ?? "");fetcher.submit(formData, {method: "post",action: path.to.bulkUpdateItems,@@ -87,7 +94,7 @@ const PartProperties = () => {return (<VStackspacing={4}- className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"+ className="w-96 bg-background h-full overflow-y-auto border-l border-border px-4 py-2"><VStack spacing={2}><HStack className="w-full justify-between">@@ -230,10 +237,27 @@ const PartProperties = () => {</DropdownMenu></VStack>- <VStack spacing={2}>- <h3 className="text-xs text-muted-foreground">Unit of Measure</h3>- <Enumerable value={routeData?.partSummary?.unitOfMeasure ?? null} />- </VStack>+ <ValidatedForm+ defaultValues={{+ unitOfMeasureCode:+ routeData?.partSummary?.unitOfMeasureCode ?? undefined,+ }}+ validator={z.object({+ unitOfMeasureCode: z+ .string()+ .min(1, { message: "Unit of Measure is required" }),+ })}+ className="w-full"+ >+ <UnitOfMeasure+ label="Unit of Measure"+ name="unitOfMeasureCode"+ inline+ onChange={(value) => {+ onUpdate("unitOfMeasureCode", value?.value ?? null);+ }}+ />+ </ValidatedForm><VStack spacing={2}><HStack className="w-full justify-between">diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsxindex 8ed1a79fe7..35e273ad4b 100644--- a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx@@ -84,7 +84,7 @@ const ToolProperties = () => {return (<VStackspacing={4}- className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2"+ className="w-96 bg-background h-full overflow-y-auto border-l border-border px-4 py-2"><VStack spacing={2}><HStack className="w-full justify-between">diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsxindex 3fb660ca16..bc21dfca05 100644--- a/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx+++ b/apps/carbon/app/modules/production/ui/Jobs/JobHeader.tsx@@ -36,7 +36,7 @@ import {LuTable,} from "react-icons/lu";import { RiProgress8Line } from "react-icons/ri";-import { Assignee, Copy, useOptimisticAssignment } from "~/components";+import { Assignee, useOptimisticAssignment } from "~/components";import { useOptimisticLocation, usePermissions, useRouteData } from "~/hooks";import { path } from "~/utils/path";import type { Job } from "../../types";@@ -86,11 +86,9 @@ const JobHeader = () => {<HStack><Link to={path.to.jobDetails(jobId)}><Heading size="h3" className="flex items-center gap-2">- {/* <ModuleIcon icon={<LuHardHat />} /> */}<span>{routeData?.job?.jobId}</span></Heading></Link>- <Copy text={routeData?.job?.jobId ?? ""} /><JobStatus status={routeData?.job?.status} /></HStack><HStack>diff --git a/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx b/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsxnew file mode 100644index 0000000000..c9b52be9a9--- /dev/null+++ b/apps/carbon/app/modules/production/ui/Jobs/JobProperties.tsx@@ -0,0 +1,249 @@+import {+ Button,+ HStack,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ VStack,+ toast,+} from "@carbon/react";+import { useFetcher, useParams } from "@remix-run/react";+import { useCallback, useEffect, useState } from "react";+import { LuCopy, LuLink } from "react-icons/lu";+import { useRouteData } from "~/hooks";+import type { action } from "~/routes/x+/items+/update";++import { DatePicker, NumberControlled, ValidatedForm } from "@carbon/form";+import { z } from "zod";+import { zfd } from "zod-form-data";+import { Customer, Item, Location, UnitOfMeasure } from "~/components/Form";+import type { MethodItemType } from "~/modules/shared";+import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";+import type { Job } from "../../types";++const JobProperties = () => {+ const { jobId } = useParams();+ if (!jobId) throw new Error("jobId not found");++ const routeData = useRouteData<{+ job: Job;+ }>(path.to.job(jobId));++ const fetcher = useFetcher<typeof action>();+ useEffect(() => {+ if (fetcher.data?.error) {+ toast.error(fetcher.data.error.message);+ }+ }, [fetcher.data]);++ const [type, setType] = useState<MethodItemType>(+ (routeData?.job?.itemType ?? "Part") as MethodItemType+ );++ const onUpdate = useCallback(+ (field: keyof Job, value: string | number | null) => {+ if (value === routeData?.job[field]) {+ return;+ }+ const formData = new FormData();++ formData.append("ids", jobId);+ formData.append("field", field);+ formData.append("value", value?.toString() ?? "");+ fetcher.submit(formData, {+ method: "post",+ action: path.to.bulkUpdateJob,+ });+ },+ [fetcher, jobId, routeData?.job]+ );++ return (+ <VStack+ spacing={4}+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2 text-sm"+ >+ <VStack spacing={4}>+ <HStack className="w-full justify-between">+ <h3 className="text-xs text-muted-foreground">Properties</h3>+ <HStack spacing={1}>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Link"+ size="sm"+ className="p-1"+ onClick={() =>+ copyToClipboard(+ window.location.origin + path.to.jobDetails(jobId)+ )+ }+ >+ <LuLink className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy link to Job</span>+ </TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Copy"+ size="sm"+ className="p-1"+ onClick={() => copyToClipboard(routeData?.job?.id ?? "")}+ >+ <LuCopy className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy Job number</span>+ </TooltipContent>+ </Tooltip>+ </HStack>+ </HStack>+ <span className="text-sm">{routeData?.job?.jobId}</span>+ </VStack>++ <ValidatedForm+ defaultValues={{ itemId: routeData?.job?.itemId ?? undefined }}+ validator={z.object({+ itemId: z.string().min(1, { message: "Item is required" }),+ })}+ className="w-full"+ >+ <Item+ name="itemId"+ inline+ type={type}+ validItemTypes={["Part", "Fixture"]}+ onChange={(value) => {+ onUpdate("itemId", value?.value ?? null);+ }}+ onTypeChange={setType}+ />+ </ValidatedForm>+ <ValidatedForm+ defaultValues={{ quantity: routeData?.job?.quantity ?? undefined }}+ validator={z.object({+ quantity: zfd.numeric(+ z.number().min(0, { message: "Quantity is required" })+ ),+ })}+ className="w-full"+ >+ <NumberControlled+ label="Quantity"+ name="quantity"+ inline+ value={routeData?.job?.quantity ?? 0}+ onChange={(value) => {+ onUpdate("quantity", value);+ }}+ />+ </ValidatedForm>+ <ValidatedForm+ defaultValues={{+ scrapQuantity: routeData?.job?.scrapQuantity ?? undefined,+ }}+ validator={z.object({+ scrapQuantity: zfd.numeric(+ z.number().min(0, { message: "Quantity is required" })+ ),+ })}+ className="w-full"+ >+ <NumberControlled+ label="Estimated Scrap Quantity"+ name="scrapQuantity"+ inline+ value={routeData?.job?.scrapQuantity ?? 0}+ onChange={(value) => {+ onUpdate("scrapQuantity", value);+ }}+ />+ </ValidatedForm>+ <ValidatedForm+ defaultValues={{+ unitOfMeasureCode: routeData?.job?.unitOfMeasureCode ?? undefined,+ }}+ validator={z.object({+ unitOfMeasureCode: z+ .string()+ .min(1, { message: "Unit of Measure is required" }),+ })}+ className="w-full"+ >+ <UnitOfMeasure+ label="Unit of Measure"+ name="unitOfMeasureCode"+ inline+ onChange={(value) => {+ onUpdate("unitOfMeasureCode", value?.value ?? null);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{ locationId: routeData?.job?.locationId ?? undefined }}+ validator={z.object({+ locationId: z.string().min(1, { message: "Location is required" }),+ })}+ className="w-full"+ >+ <Location+ label="Job Location"+ name="locationId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("locationId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ dueDate: routeData?.job?.dueDate ?? "",+ }}+ validator={z.object({+ dueDate: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <DatePicker+ name="dueDate"+ label="Due Date"+ inline+ onChange={(date) => {+ onUpdate("dueDate", date);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{ customerId: routeData?.job?.customerId ?? undefined }}+ validator={z.object({+ customerId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <Customer+ name="customerId"+ inline+ isOptional+ onChange={(value) => {+ onUpdate("customerId", value?.value ?? null);+ }}+ />+ </ValidatedForm>+ </VStack>+ );+};++export default JobProperties;diff --git a/apps/carbon/app/modules/production/ui/Jobs/index.ts b/apps/carbon/app/modules/production/ui/Jobs/index.tsindex b1b9489ae2..c1009a4c44 100644--- a/apps/carbon/app/modules/production/ui/Jobs/index.ts+++ b/apps/carbon/app/modules/production/ui/Jobs/index.ts@@ -8,6 +8,7 @@ import JobHeader from "./JobHeader";import JobMaterialForm from "./JobMaterialForm";import JobMaterialsTable from "./JobMaterialsTable";import JobOperationsTable from "./JobOperationsTable";+import JobProperties from "./JobProperties";import JobsTable from "./JobsTable";import JobStatus from "./JobStatus";@@ -28,6 +29,7 @@ export {JobMaterialForm,JobMaterialsTable,JobOperationsTable,+ JobProperties,JobsTable,JobStatus,ProductionEventForm,diff --git a/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsxindex dd01103f79..03f9f73017 100644--- a/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx+++ b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx@@ -1,5 +1,4 @@import {- Badge,Card,CardAction,CardContent,@@ -18,6 +17,7 @@ import {Th,Thead,Tr,+ VStack,toast,} from "@carbon/react";import { convertKbToString } from "@carbon/utils";@@ -303,10 +303,14 @@ const OpportunityLineDocuments = ({<Td><HStack><DocumentIcon type="Model" />- <Hyperlink target="_blank" to={getModelPath(modelUpload)}>- {modelUpload.modelName}- </Hyperlink>- <Badge variant="secondary">Model</Badge>+ <VStack>+ <Hyperlink+ target="_blank"+ to={getModelPath(modelUpload)}+ >+ {modelUpload.modelName}+ </Hyperlink>+ </VStack></HStack></Td><Td>diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsxindex 837d5e1291..4fd60be2de 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx@@ -181,7 +181,7 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {customer.currencyCode !== company.baseCurrencyCode && (<ExchangeRatename="exchangeRate"- value={initialValues.exchangeRate}+ value={initialValues.exchangeRate ?? 1}exchangeRateUpdatedAt={initialValues.exchangeRateUpdatedAt}isReadOnlyonRefresh={() => {diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsxindex 66dac8dd33..dca61585c6 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteHeader.tsx@@ -80,11 +80,9 @@ const QuoteHeader = () => {<HStack><Link to={path.to.quoteDetails(quoteId)}><Heading size="h3" className="flex items-center gap-2">- {/* <ModuleIcon icon={<RiProgress4Line />} /> */}<span>{routeData?.quote?.quoteId}</span></Heading></Link>- <Copy text={routeData?.quote?.quoteId ?? ""} /><QuoteStatus status={routeData?.quote?.status} /></HStack><HStack>diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsxnew file mode 100644index 0000000000..178c31132a--- /dev/null+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteProperties.tsx@@ -0,0 +1,377 @@+import { DatePicker, InputControlled, ValidatedForm } from "@carbon/form";+import {+ Button,+ HStack,+ IconButton,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ VStack,+ toast,+} from "@carbon/react";+import { useLocale } from "@react-aria/i18n";+import { useFetcher, useParams } from "@remix-run/react";+import { useCallback, useEffect, useMemo } from "react";+import { LuCopy, LuInfo, LuLink, LuRefreshCcw } from "react-icons/lu";+import { z } from "zod";+import { zfd } from "zod-form-data";+import {+ Currency,+ Customer,+ CustomerContact,+ CustomerLocation,+ Employee,+ Location,+} from "~/components/Form";+import { useRouteData, useUser } from "~/hooks";+import type { action } from "~/routes/x+/items+/update";+import type { action as exchangeRateAction } from "~/routes/x+/quote+/$quoteId.exchange-rate";+import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";+import type { Quotation } from "../../types";++const QuoteProperties = () => {+ const { quoteId } = useParams();+ if (!quoteId) throw new Error("quoteId not found");++ const routeData = useRouteData<{+ quote: Quotation;+ }>(path.to.quote(quoteId));++ const fetcher = useFetcher<typeof action>();+ useEffect(() => {+ if (fetcher.data?.error) {+ toast.error(fetcher.data.error.message);+ }+ }, [fetcher.data]);++ const { company } = useUser();+ const exchangeRateFetcher = useFetcher<typeof exchangeRateAction>();+ const { locale } = useLocale();+ const formatter = useMemo(+ () =>+ new Intl.DateTimeFormat(locale, {+ dateStyle: "medium",+ timeStyle: "short",+ }),+ [locale]+ );++ const onUpdate = useCallback(+ (field: keyof Quotation, value: string | null) => {+ if (value === routeData?.quote[field]) {+ return;+ }+ const formData = new FormData();++ formData.append("ids", quoteId);+ formData.append("field", field);+ formData.append("value", value ?? "");+ fetcher.submit(formData, {+ method: "post",+ action: path.to.bulkUpdateQuote,+ });+ },+ [fetcher, quoteId, routeData?.quote]+ );++ return (+ <VStack+ spacing={4}+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2 text-sm"+ >+ <VStack spacing={4}>+ <HStack className="w-full justify-between">+ <h3 className="text-xs text-muted-foreground">Properties</h3>+ <HStack spacing={1}>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Link"+ size="sm"+ className="p-1"+ onClick={() =>+ copyToClipboard(+ window.location.origin + path.to.quoteDetails(quoteId)+ )+ }+ >+ <LuLink className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy link to Quote</span>+ </TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Copy"+ size="sm"+ className="p-1"+ onClick={() => copyToClipboard(routeData?.quote?.id ?? "")}+ >+ <LuCopy className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy Quote number</span>+ </TooltipContent>+ </Tooltip>+ </HStack>+ </HStack>+ <span className="text-sm">{routeData?.quote?.quoteId}</span>+ </VStack>++ <ValidatedForm+ defaultValues={{ customerId: routeData?.quote?.customerId }}+ validator={z.object({+ customerId: z.string().min(1, { message: "Customer is required" }),+ })}+ className="w-full"+ >+ <Customer+ name="customerId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("customerId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerReference: routeData?.quote?.customerReference ?? undefined,+ }}+ validator={z.object({+ customerReference: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <InputControlled+ name="customerReference"+ label="Customer Ref. Number"+ value={routeData?.quote?.customerReference ?? ""}+ size="sm"+ inline+ onBlur={(e) => {+ onUpdate("customerReference", e.target.value);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerLocationId: routeData?.quote?.customerLocationId ?? "",+ }}+ validator={z.object({+ customerLocationId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <CustomerLocation+ name="customerLocationId"+ customer={routeData?.quote?.customerId ?? ""}+ inline+ onChange={(customerLocation) => {+ if (customerLocation?.id) {+ onUpdate("customerLocationId", customerLocation.id);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerContactId: routeData?.quote?.customerContactId ?? "",+ }}+ validator={z.object({+ customerContactId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <CustomerContact+ name="customerContactId"+ customer={routeData?.quote?.customerId ?? ""}+ inline+ onChange={(customerContact) => {+ if (customerContact?.id) {+ onUpdate("customerContactId", customerContact.id);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ expirationDate: routeData?.quote?.expirationDate ?? "",+ }}+ validator={z.object({+ expirationDate: z+ .string()+ .min(1, { message: "Expiration date is required" }),+ })}+ className="w-full"+ >+ <DatePicker+ name="expirationDate"+ label="Expiration Date"+ inline+ onChange={(date) => {+ onUpdate("expirationDate", date);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ dueDate: routeData?.quote?.dueDate ?? "",+ }}+ validator={z.object({+ dueDate: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <DatePicker+ name="dueDate"+ label="Due Date"+ inline+ onChange={(date) => {+ onUpdate("dueDate", date);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{ locationId: routeData?.quote?.locationId }}+ validator={z.object({+ locationId: z.string().min(1, { message: "Location is required" }),+ })}+ className="w-full"+ >+ <Location+ label="Quote Location"+ name="locationId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("locationId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ salesPersonId: routeData?.quote?.salesPersonId ?? undefined,+ }}+ validator={zfd.text(z.string().optional())}+ className="w-full"+ >+ <Employee+ name="salesPersonId"+ label="Sales Person"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("salesPersonId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ estimatorId: routeData?.quote?.estimatorId ?? undefined,+ }}+ validator={z.object({+ estimatorId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <Employee+ name="estimatorId"+ label="Estimator"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("estimatorId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ currencyCode: routeData?.quote?.currencyCode ?? undefined,+ }}+ validator={z.object({+ currencyCode: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <Currency+ name="currencyCode"+ label="Currency"+ inline+ value={routeData?.quote?.currencyCode ?? ""}+ onChange={(value) => {+ if (value?.value) {+ onUpdate("currencyCode", value.value);+ }+ }}+ />+ </ValidatedForm>++ {routeData?.quote?.currencyCode &&+ routeData?.quote?.currencyCode !== company.baseCurrencyCode && (+ <VStack spacing={2}>+ <HStack spacing={1}>+ <span className="text-xs text-muted-foreground">+ Exchange Rate+ </span>+ {routeData?.quote?.exchangeRateUpdatedAt && (+ <Tooltip>+ <TooltipTrigger tabIndex={-1}>+ <LuInfo className="w-4 h-4" />+ </TooltipTrigger>+ <TooltipContent>+ Last updated:{" "}+ {formatter.format(+ new Date(routeData?.quote?.exchangeRateUpdatedAt ?? "")+ )}+ </TooltipContent>+ </Tooltip>+ )}+ </HStack>+ <HStack className="w-full justify-between">+ <span>{routeData?.quote?.exchangeRate}</span>+ <IconButton+ size="sm"+ variant="secondary"+ aria-label="Refresh"+ icon={<LuRefreshCcw />}+ onClick={() => {+ const formData = new FormData();+ formData.append(+ "currencyCode",+ routeData?.quote?.currencyCode ?? ""+ );+ exchangeRateFetcher.submit(formData, {+ method: "post",+ action: path.to.quoteExchangeRate(quoteId),+ });+ }}+ />+ </HStack>+ </VStack>+ )}+ </VStack>+ );+};++export default QuoteProperties;diff --git a/apps/carbon/app/modules/sales/ui/Quotes/index.ts b/apps/carbon/app/modules/sales/ui/Quotes/index.tsindex 33e75caf38..f0ebeb97cf 100644--- a/apps/carbon/app/modules/sales/ui/Quotes/index.ts+++ b/apps/carbon/app/modules/sales/ui/Quotes/index.ts@@ -12,6 +12,7 @@ import QuoteLinePricing from "./QuoteLinePricing";import QuoteMakeMethodTools from "./QuoteMakeMethodTools";import QuoteMaterialForm from "./QuoteMaterialForm";import QuotePaymentForm from "./QuotePaymentForm";+import QuoteProperties from "./QuoteProperties";import QuoteShipmentForm from "./QuoteShipmentForm";import QuotesTable from "./QuotesTable";import { useLineCosts } from "./useLineCosts";@@ -31,6 +32,7 @@ export {QuoteMakeMethodTools,QuoteMaterialForm,QuotePaymentForm,+ QuoteProperties,QuoteShipmentForm,QuotesTable,useLineCosts,diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsxindex 6c77ba5bfe..e575f8c4e5 100644--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx@@ -194,7 +194,7 @@ const SalesOrderForm = ({ initialValues }: SalesOrderFormProps) => {customer.currencyCode !== company.baseCurrencyCode && (<ExchangeRatename="exchangeRate"- value={initialValues.exchangeRate}+ value={initialValues.exchangeRate ?? 1}exchangeRateUpdatedAt={initialValues.exchangeRateUpdatedAt}isReadOnlyonRefresh={diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsxindex 90c6d08127..7e2f7c9816 100644--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderHeader.tsx@@ -9,7 +9,7 @@ import {LuStopCircle,LuTruck,} from "react-icons/lu";-import { Assignee, Copy, useOptimisticAssignment } from "~/components";+import { Assignee, useOptimisticAssignment } from "~/components";import { usePermissions, useRouteData } from "~/hooks";import type { SalesOrder, SalesOrderLine } from "~/modules/sales";@@ -45,11 +45,9 @@ const SalesOrderHeader = () => {<HStack><Link to={path.to.salesOrderDetails(orderId)}><Heading size="h3" className="flex items-center gap-2">- {/* <ModuleIcon icon={<RiProgress8Line />} /> */}<span>{routeData?.salesOrder?.salesOrderId}</span></Heading></Link>- <Copy text={routeData?.salesOrder?.salesOrderId ?? ""} /><SalesStatus status={routeData?.salesOrder?.status} /></HStack><HStack>diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsxnew file mode 100644index 0000000000..f1397f2209--- /dev/null+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx@@ -0,0 +1,365 @@+import { DatePicker, InputControlled, ValidatedForm } from "@carbon/form";+import {+ Button,+ HStack,+ IconButton,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ VStack,+ toast,+} from "@carbon/react";+import { useLocale } from "@react-aria/i18n";+import { useFetcher, useParams } from "@remix-run/react";+import { useCallback, useEffect, useMemo } from "react";+import { LuCopy, LuInfo, LuLink, LuRefreshCcw } from "react-icons/lu";+import { z } from "zod";+import { zfd } from "zod-form-data";+import {+ Currency,+ Customer,+ CustomerContact,+ CustomerLocation,+ Employee,+ Location,+} from "~/components/Form";+import { useRouteData, useUser } from "~/hooks";+import type { action } from "~/routes/x+/items+/update";+import type { action as exchangeRateAction } from "~/routes/x+/sales-order+/$orderId.exchange-rate";+import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";+import type { Quotation, SalesOrder } from "../../types";++const SalesOrderProperties = () => {+ const { orderId } = useParams();+ if (!orderId) throw new Error("orderId not found");++ const routeData = useRouteData<{+ salesOrder: SalesOrder;+ quote: Quotation;+ originatedFromQuote: boolean;+ }>(path.to.salesOrder(orderId));++ const fetcher = useFetcher<typeof action>();+ useEffect(() => {+ if (fetcher.data?.error) {+ toast.error(fetcher.data.error.message);+ }+ }, [fetcher.data]);++ const { company } = useUser();+ const exchangeRateFetcher = useFetcher<typeof exchangeRateAction>();+ const { locale } = useLocale();+ const formatter = useMemo(+ () =>+ new Intl.DateTimeFormat(locale, {+ dateStyle: "medium",+ timeStyle: "short",+ }),+ [locale]+ );++ const onUpdate = useCallback(+ (field: keyof SalesOrder, value: string | null) => {+ if (value === routeData?.salesOrder[field]) {+ return;+ }+ const formData = new FormData();++ formData.append("ids", orderId);+ formData.append("field", field);+ formData.append("value", value ?? "");+ fetcher.submit(formData, {+ method: "post",+ action: path.to.bulkUpdateSalesOrder,+ });+ },+ [fetcher, orderId, routeData?.salesOrder]+ );++ return (+ <VStack+ spacing={4}+ className="w-96 bg-card h-full overflow-y-auto border-l border-border px-4 py-2 text-sm"+ >+ <VStack spacing={4}>+ <HStack className="w-full justify-between">+ <h3 className="text-xs text-muted-foreground">Properties</h3>+ <HStack spacing={1}>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Link"+ size="sm"+ className="p-1"+ onClick={() =>+ copyToClipboard(+ window.location.origin ++ path.to.salesOrderDetails(orderId)+ )+ }+ >+ <LuLink className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy link to Sales Order</span>+ </TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Copy"+ size="sm"+ className="p-1"+ onClick={() =>+ copyToClipboard(routeData?.salesOrder?.id ?? "")+ }+ >+ <LuCopy className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy Sales Order number</span>+ </TooltipContent>+ </Tooltip>+ </HStack>+ </HStack>+ <span className="text-sm">{routeData?.salesOrder?.salesOrderId}</span>+ </VStack>++ <ValidatedForm+ defaultValues={{ customerId: routeData?.salesOrder?.customerId }}+ validator={z.object({+ customerId: z.string().min(1, { message: "Customer is required" }),+ })}+ className="w-full"+ >+ <Customer+ name="customerId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("customerId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerReference:+ routeData?.salesOrder?.customerReference ?? undefined,+ }}+ validator={z.object({+ customerReference: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <InputControlled+ name="customerReference"+ label="Customer Ref. Number"+ value={routeData?.salesOrder?.customerReference ?? ""}+ size="sm"+ inline+ onBlur={(e) => {+ onUpdate("customerReference", e.target.value);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerLocationId: routeData?.salesOrder?.customerLocationId ?? "",+ }}+ validator={z.object({+ customerLocationId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <CustomerLocation+ name="customerLocationId"+ customer={routeData?.salesOrder?.customerId ?? ""}+ inline+ onChange={(customerLocation) => {+ if (customerLocation?.id) {+ onUpdate("customerLocationId", customerLocation.id);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerContactId: routeData?.salesOrder?.customerContactId ?? "",+ }}+ validator={z.object({+ customerContactId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <CustomerContact+ name="customerContactId"+ customer={routeData?.salesOrder?.customerId ?? ""}+ inline+ onChange={(customerContact) => {+ if (customerContact?.id) {+ onUpdate("customerContactId", customerContact.id);+ }+ }}+ />+ </ValidatedForm>++ {routeData?.originatedFromQuote && (+ <>+ <VStack spacing={2}>+ <span className="text-xs text-muted-foreground">+ Quote Accepted By+ </span>+ <span className="text-sm">+ {routeData?.quote?.digitalQuoteAcceptedBy}+ </span>+ </VStack>++ <VStack spacing={2}>+ <span className="text-xs text-muted-foreground">+ Quote Accepted By Email+ </span>+ <span className="text-sm">+ {routeData?.quote?.digitalQuoteAcceptedByEmail}+ </span>+ </VStack>+ </>+ )}++ <ValidatedForm+ defaultValues={{+ orderDate: routeData?.salesOrder?.orderDate ?? "",+ }}+ validator={z.object({+ orderDate: z.string().min(1, { message: "Order date is required" }),+ })}+ className="w-full"+ >+ <DatePicker+ name="orderDate"+ label="Order Date"+ inline+ onChange={(date) => {+ onUpdate("orderDate", date);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{ locationId: routeData?.salesOrder?.locationId }}+ validator={z.object({+ locationId: z.string().min(1, { message: "Location is required" }),+ })}+ className="w-full"+ >+ <Location+ label="Sales Order Location"+ name="locationId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("locationId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ salesPersonId: routeData?.salesOrder?.salesPersonId ?? undefined,+ }}+ validator={zfd.text(z.string().optional())}+ className="w-full"+ >+ <Employee+ name="salesPersonId"+ label="Sales Person"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("salesPersonId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ currencyCode: routeData?.salesOrder?.currencyCode ?? undefined,+ }}+ validator={z.object({+ currencyCode: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <Currency+ name="currencyCode"+ label="Currency"+ inline+ value={routeData?.salesOrder?.currencyCode ?? ""}+ onChange={(value) => {+ if (value?.value) {+ onUpdate("currencyCode", value.value);+ }+ }}+ />+ </ValidatedForm>++ {routeData?.salesOrder?.currencyCode &&+ routeData?.salesOrder?.currencyCode !== company.baseCurrencyCode && (+ <VStack spacing={2}>+ <HStack spacing={1}>+ <span className="text-xs text-muted-foreground">+ Exchange Rate+ </span>+ {routeData?.salesOrder?.exchangeRateUpdatedAt && (+ <Tooltip>+ <TooltipTrigger tabIndex={-1}>+ <LuInfo className="w-4 h-4" />+ </TooltipTrigger>+ <TooltipContent>+ Last updated:{" "}+ {formatter.format(+ new Date(+ routeData?.salesOrder?.exchangeRateUpdatedAt ?? ""+ )+ )}+ </TooltipContent>+ </Tooltip>+ )}+ </HStack>+ <HStack className="w-full justify-between">+ <span>{routeData?.salesOrder?.exchangeRate}</span>+ <IconButton+ size="sm"+ variant="secondary"+ aria-label="Refresh"+ icon={<LuRefreshCcw />}+ onClick={() => {+ const formData = new FormData();+ formData.append(+ "currencyCode",+ routeData?.salesOrder?.currencyCode ?? ""+ );+ exchangeRateFetcher.submit(formData, {+ method: "post",+ action: path.to.salesOrderExchangeRate(orderId),+ });+ }}+ />+ </HStack>+ </VStack>+ )}+ </VStack>+ );+};++export default SalesOrderProperties;diff --git a/apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsxsimilarity index 93%rename from apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsxrename to apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsxindex ea7f929610..9649da7478 100644--- a/apps/carbon/app/modules/sales/ui/SalesOrders/SalesOrdersTable.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrdersTable.tsx@@ -6,9 +6,9 @@ import {useDisclosure,} from "@carbon/react";import { formatDate } from "@carbon/utils";-import { useFetcher, useFetchers } from "@remix-run/react";+import { useFetcher, useFetchers, useNavigate } from "@remix-run/react";import type { ColumnDef } from "@tanstack/react-table";-import { memo, useMemo, useState } from "react";+import { memo, useCallback, useMemo, useState } from "react";import {LuBookMarked,LuCalendar,@@ -38,7 +38,6 @@ import { SalesStatus, salesOrderStatusType } from "~/modules/sales";import { useCustomers, usePeople } from "~/stores";import { favoriteSchema } from "~/types/validators";import { path } from "~/utils/path";-import { useSalesOrder } from "./useSalesOrder";type SalesOrdersTableProps = {data: SalesOrder[];@@ -401,3 +400,34 @@ function useOptimisticFavorite() {}}}++export const useSalesOrder = () => {+ const navigate = useNavigate();++ const edit = useCallback(+ (salesOrder: SalesOrder) => navigate(path.to.salesOrder(salesOrder.id!)),+ [navigate]+ );++ /*const invoice = useCallback(+ (salesOrder: SalesOrder) =>+ navigate(+ `${path.to.newPurchaseInvoice}?sourceDocument=Purchase Order&sourceDocumentId=${purchaseOrder.id}`+ ),+ [navigate]+ );++ const receive = useCallback(+ (salesOrder: SalesOrder) =>+ navigate(+ `${path.to.newReceipt}?sourceDocument=Purchase Order&sourceDocumentId=${salesOrder.id}`+ ),+ [navigate]+ );*/++ return {+ edit,+ //invoice,+ //receive,+ };+};diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/index.ts b/apps/carbon/app/modules/sales/ui/SalesOrder/index.tsindex 2ad3e2919a..9b0bf16797 100644--- a/apps/carbon/app/modules/sales/ui/SalesOrder/index.ts+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/index.ts@@ -2,11 +2,11 @@ import SalesOrderExplorer from "./SalesOrderExplorer";import SalesOrderForm from "./SalesOrderForm";import SalesOrderHeader from "./SalesOrderHeader";import SalesOrderLineForm from "./SalesOrderLineForm";-import SalesOrderShipmentForm from "./SalesOrderShipmentForm";--import SalesOrderPaymentForm from "./SalesOrderPaymentForm";-import { SalesOrderLineJobs } from "./SalesOrderLineJobs";+import SalesOrderPaymentForm from "./SalesOrderPaymentForm";+import SalesOrderProperties from "./SalesOrderProperties";+import SalesOrderShipmentForm from "./SalesOrderShipmentForm";+import SalesOrdersTable from "./SalesOrdersTable";import SalesStatus from "./SalesStatus";import { useSalesOrderTotals } from "./useSalesOrderTotals";@@ -17,7 +17,9 @@ export {SalesOrderLineForm,SalesOrderLineJobs,SalesOrderPaymentForm,+ SalesOrderProperties,SalesOrderShipmentForm,+ SalesOrdersTable,SalesStatus,useSalesOrderTotals,};diff --git a/apps/carbon/app/modules/sales/ui/SalesOrders/index.ts b/apps/carbon/app/modules/sales/ui/SalesOrders/index.tsdeleted file mode 100644index 9016e85e2b..0000000000--- a/apps/carbon/app/modules/sales/ui/SalesOrders/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import SalesOrdersTable from "./SalesOrdersTable";--export { SalesOrdersTable };diff --git a/apps/carbon/app/modules/sales/ui/SalesOrders/useSalesOrder.ts b/apps/carbon/app/modules/sales/ui/SalesOrders/useSalesOrder.tsdeleted file mode 100644index f29da58ecc..0000000000--- a/apps/carbon/app/modules/sales/ui/SalesOrders/useSalesOrder.ts+++ /dev/null@@ -1,35 +0,0 @@-import { useNavigate } from "@remix-run/react";-import { useCallback } from "react";-import type { SalesOrder } from "~/modules/sales";-import { path } from "~/utils/path";--export const useSalesOrder = () => {- const navigate = useNavigate();-- const edit = useCallback(- (salesOrder: SalesOrder) => navigate(path.to.salesOrder(salesOrder.id!)),- [navigate]- );-- /*const invoice = useCallback(- (salesOrder: SalesOrder) =>- navigate(- `${path.to.newPurchaseInvoice}?sourceDocument=Purchase Order&sourceDocumentId=${purchaseOrder.id}`- ),- [navigate]- );-- const receive = useCallback(- (salesOrder: SalesOrder) =>- navigate(- `${path.to.newReceipt}?sourceDocument=Purchase Order&sourceDocumentId=${salesOrder.id}`- ),- [navigate]- );*/-- return {- edit,- //invoice,- //receive,- };-};diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsxindex 2b93335ab0..4398859e05 100644--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx@@ -89,7 +89,6 @@ const SalesRFQForm = ({ initialValues }: SalesRFQFormProps) => {label="Customer Contact"customer={customer}/>-<DatePickername="rfqDate"label="RFQ Date"diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsxindex ba98202648..9f8046e14c 100644--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQHeader.tsx@@ -19,7 +19,7 @@ import { Link, useFetcher, useParams } from "@remix-run/react";import { useEffect } from "react";import { LuAlertTriangle, LuRefreshCw, LuXCircle } from "react-icons/lu";import { RiProgress4Line } from "react-icons/ri";-import { Assignee, Copy, useOptimisticAssignment } from "~/components";+import { Assignee, useOptimisticAssignment } from "~/components";import { usePermissions, useRouteData } from "~/hooks";import type { SalesRFQ, SalesRFQLine } from "~/modules/sales";import { path } from "~/utils/path";@@ -62,7 +62,6 @@ const SalesRFQHeader = () => {<span>{routeData?.rfqSummary?.rfqId}</span></Heading></Link>- <Copy text={routeData?.rfqSummary?.rfqId ?? ""} /><SalesRFQStatus status={routeData?.rfqSummary?.status} /></HStack><HStack>diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsxnew file mode 100644index 0000000000..da0ce1cf2f--- /dev/null+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx@@ -0,0 +1,277 @@+import { DatePicker, InputControlled, ValidatedForm } from "@carbon/form";+import {+ Button,+ HStack,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ VStack,+ toast,+} from "@carbon/react";+import { useFetcher, useParams } from "@remix-run/react";+import { useCallback, useEffect } from "react";+import { LuCopy, LuLink } from "react-icons/lu";+import { z } from "zod";+import { zfd } from "zod-form-data";+import {+ Customer,+ CustomerContact,+ CustomerLocation,+ Employee,+ Location,+} from "~/components/Form";+import { useRouteData } from "~/hooks";+import type { action } from "~/routes/x+/items+/update";+import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";+import type { SalesRFQ } from "../../types";++const SalesRFQProperties = () => {+ const { rfqId } = useParams();+ if (!rfqId) throw new Error("rfqId not found");++ const routeData = useRouteData<{+ rfqSummary: SalesRFQ;+ }>(path.to.salesRfq(rfqId));++ const fetcher = useFetcher<typeof action>();+ useEffect(() => {+ if (fetcher.data?.error) {+ toast.error(fetcher.data.error.message);+ }+ }, [fetcher.data]);++ const onUpdate = useCallback(+ (field: keyof SalesRFQ, value: string | null) => {+ if (value === routeData?.rfqSummary[field]) {+ return;+ }+ const formData = new FormData();++ formData.append("ids", rfqId);+ formData.append("field", field);+ formData.append("value", value ?? "");+ fetcher.submit(formData, {+ method: "post",+ action: path.to.bulkUpdateSalesRfq,+ });+ },+ [fetcher, rfqId, routeData?.rfqSummary]+ );++ return (+ <VStack+ spacing={4}+ className="w-96 bg-background h-full overflow-y-auto border-l border-border px-4 py-2 text-sm"+ >+ <VStack spacing={4}>+ <HStack className="w-full justify-between">+ <h3 className="text-xs text-muted-foreground">Properties</h3>+ <HStack spacing={1}>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Link"+ size="sm"+ className="p-1"+ onClick={() =>+ copyToClipboard(+ window.location.origin + path.to.salesRfqDetails(rfqId)+ )+ }+ >+ <LuLink className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy link to RFQ</span>+ </TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ variant="ghost"+ aria-label="Copy"+ size="sm"+ className="p-1"+ onClick={() =>+ copyToClipboard(routeData?.rfqSummary?.id ?? "")+ }+ >+ <LuCopy className="w-3 h-3" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>+ <span>Copy RFQ number</span>+ </TooltipContent>+ </Tooltip>+ </HStack>+ </HStack>+ <span className="text-sm">{routeData?.rfqSummary?.rfqId}</span>+ </VStack>++ <ValidatedForm+ defaultValues={{ customerId: routeData?.rfqSummary?.customerId }}+ validator={z.object({+ customerId: z.string().min(1, { message: "Customer is required" }),+ })}+ className="w-full"+ >+ <Customer+ name="customerId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("customerId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerReference:+ routeData?.rfqSummary?.customerReference ?? undefined,+ }}+ validator={z.object({+ customerReference: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <InputControlled+ name="customerReference"+ label="Customer Ref. Number"+ value={routeData?.rfqSummary?.customerReference ?? ""}+ size="sm"+ inline+ onBlur={(e) => {+ onUpdate("customerReference", e.target.value);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerLocationId: routeData?.rfqSummary?.customerLocationId ?? "",+ }}+ validator={z.object({+ customerLocationId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <CustomerLocation+ name="customerLocationId"+ customer={routeData?.rfqSummary?.customerId ?? ""}+ inline+ onChange={(customerLocation) => {+ if (customerLocation?.id) {+ onUpdate("customerLocationId", customerLocation.id);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ customerContactId: routeData?.rfqSummary?.customerContactId ?? "",+ }}+ validator={z.object({+ customerContactId: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <CustomerContact+ name="customerContactId"+ customer={routeData?.rfqSummary?.customerId ?? ""}+ inline+ onChange={(customerContact) => {+ if (customerContact?.id) {+ onUpdate("customerContactId", customerContact.id);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ rfqDate: routeData?.rfqSummary?.rfqDate ?? "",+ }}+ validator={z.object({+ rfqDate: z.string().min(1, { message: "RFQ Date is required" }),+ })}+ className="w-full"+ >+ <DatePicker+ name="rfqDate"+ label="RFQ Date"+ inline+ onChange={(date) => {+ onUpdate("rfqDate", date);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{+ expirationDate: routeData?.rfqSummary?.expirationDate ?? "",+ }}+ validator={z.object({+ expirationDate: zfd.text(z.string().optional()),+ })}+ className="w-full"+ >+ <DatePicker+ name="expirationDate"+ label="Expiration Date"+ inline+ onChange={(date) => {+ onUpdate("expirationDate", date);+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{ locationId: routeData?.rfqSummary?.locationId }}+ validator={z.object({+ locationId: z.string().min(1, { message: "Location is required" }),+ })}+ className="w-full"+ >+ <Location+ label="RFQ Location"+ name="locationId"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("locationId", value.value);+ }+ }}+ />+ </ValidatedForm>++ <ValidatedForm+ defaultValues={{ salesPersonId: routeData?.rfqSummary?.salesPersonId }}+ validator={z.object({+ salesPersonId: z+ .string()+ .min(1, { message: "Sales person is required" }),+ })}+ className="w-full"+ >+ <Employee+ name="salesPersonId"+ label="Sales Person"+ inline+ onChange={(value) => {+ if (value?.value) {+ onUpdate("salesPersonId", value.value);+ }+ }}+ />+ </ValidatedForm>+ </VStack>+ );+};++export default SalesRFQProperties;diff --git a/apps/carbon/app/modules/sales/ui/SalesRFQ/index.ts b/apps/carbon/app/modules/sales/ui/SalesRFQ/index.tsindex dd3a7e3a3a..7391777777 100644--- a/apps/carbon/app/modules/sales/ui/SalesRFQ/index.ts+++ b/apps/carbon/app/modules/sales/ui/SalesRFQ/index.ts@@ -4,6 +4,7 @@ import SalesRFQForm from "./SalesRFQForm";import SalesRFQHeader from "./SalesRFQHeader";import SalesRFQLineForm from "./SalesRFQLineForm";import SalesRFQLineNotes from "./SalesRFQLineNotes";+import SalesRFQProperties from "./SalesRFQProperties";import SalesRFQStatus from "./SalesRFQStatus";import SalesRFQsTable from "./SalesRFQsTable";@@ -14,6 +15,7 @@ export {SalesRFQHeader,SalesRFQLineForm,SalesRFQLineNotes,+ SalesRFQProperties,SalesRFQStatus,SalesRFQsTable,};diff --git a/apps/carbon/app/modules/sales/ui/index.ts b/apps/carbon/app/modules/sales/ui/index.tsindex 6e52d2a0f8..4615451e3e 100644--- a/apps/carbon/app/modules/sales/ui/index.ts+++ b/apps/carbon/app/modules/sales/ui/index.ts@@ -6,6 +6,5 @@ export * from "./CustomerTypes";export * from "./Opportunity";export * from "./Quotes";export * from "./SalesOrder";-export * from "./SalesOrders";export * from "./SalesRFQ";export { useSalesSubmodules };diff --git a/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal.tsx b/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal.tsxindex 1cff56e189..13c77c045a 100644--- a/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal.tsx+++ b/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal.tsx@@ -79,7 +79,7 @@ const CreateCustomerModal = () => {<CustomerContactname="id"customer={customer}- onChange={setContact}+ onChange={(contact) => setContact(contact?.contact ?? null)}/>{contact && (<>@@ -119,7 +119,12 @@ const CustomerContact = ({}: {name: string;customer?: string;- onChange?: (newValue: CustomerContactType["contact"] | null) => void;+ onChange?: (+ newValue: {+ id: string;+ contact: CustomerContactType["contact"];+ } | null+ ) => void;}) => {const initialLoad = useRef(true);const { error, defaultValue } = useField(name);@@ -164,7 +169,7 @@ const CustomerContact = ({(c) => c.id === newValue);- onChange(contact?.contact ?? null);+ onChange({ id: newValue, contact: contact?.contact ?? null });}};diff --git a/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx b/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsxindex 0b9502294a..351c4007d7 100644--- a/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx+++ b/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx@@ -11,6 +11,7 @@ import {ModalContent,ModalFooter,ModalHeader,+ ModalOverlay,ModalTitle,VStack,} from "@carbon/react";@@ -45,6 +46,7 @@ const CreateSupplierModal = () => {if (!open) navigate(path.to.supplierAccounts);}}>+ <ModalOverlay /><ModalContent><ValidatedFormmethod="post"@@ -63,6 +65,7 @@ const CreateSupplierModal = () => {<ModalHeader><ModalTitle>Create an account</ModalTitle></ModalHeader>+<ModalBody><VStack spacing={4}><Supplier@@ -75,7 +78,7 @@ const CreateSupplierModal = () => {<SupplierContactname="id"supplier={supplier}- onChange={setContact}+ onChange={(contact) => setContact(contact?.contact ?? null)}/>{contact && (<>@@ -96,12 +99,12 @@ const CreateSupplierModal = () => {</>)}</VStack>+ <ModalFooter>+ <HStack>+ <Submit>Create User</Submit>+ </HStack>+ </ModalFooter></ModalBody>- <ModalFooter>- <HStack spacing={4}>- <Submit>Create User</Submit>- </HStack>- </ModalFooter></ValidatedForm></ModalContent></Modal>@@ -115,7 +118,12 @@ const SupplierContact = ({}: {name: string;supplier?: string;- onChange?: (newValue: SupplierContactType["contact"] | null) => void;+ onChange?: (+ newValue: {+ id: string;+ contact: SupplierContactType["contact"];+ } | null+ ) => void;}) => {const initialLoad = useRef(true);const { error, defaultValue } = useField(name);@@ -159,7 +167,7 @@ const SupplierContact = ({(c) => c.id === newValue);- onChange(contact?.contact ?? null);+ onChange({ id: newValue, contact: contact?.contact ?? null });}};diff --git a/apps/carbon/app/routes/x+/items+/update.tsx b/apps/carbon/app/routes/x+/items+/update.tsxindex 3ed0826569..f13a0509e0 100644--- a/apps/carbon/app/routes/x+/items+/update.tsx+++ b/apps/carbon/app/routes/x+/items+/update.tsx@@ -19,6 +19,7 @@ export async function action({ request }: ActionFunctionArgs) {case "replenishmentSystem":case "defaultMethodType":case "itemTrackingType":+ case "unitOfMeasureCode":return json(await client.from("item")diff --git a/apps/carbon/app/routes/x+/job+/$jobId.tsx b/apps/carbon/app/routes/x+/job+/$jobId.tsxindex cb3c702313..bfebd8a608 100644--- a/apps/carbon/app/routes/x+/job+/$jobId.tsx+++ b/apps/carbon/app/routes/x+/job+/$jobId.tsx@@ -7,7 +7,6 @@ import {ResizablePanel,ResizablePanelGroup,ScrollArea,- VStack,} from "@carbon/react";import {Await,@@ -27,6 +26,7 @@ import {getJobMethodTree,JobBoMExplorer,JobHeader,+ JobProperties,} from "~/modules/production";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -113,11 +113,12 @@ export default function JobRoute() {</ResizablePanel><ResizableHandle withHandle /><ResizablePanel order={2}>- <ScrollArea className="h-[calc(100vh-99px)]">- <VStack spacing={2} className="h-[calc(100vh-99px)]">+ <div className="flex h-[calc(100vh-99px)] w-full">+ <ScrollArea className="h-[calc(100vh-99px)] w-full"><Outlet />- </VStack>- </ScrollArea>+ </ScrollArea>+ <JobProperties />+ </div></ResizablePanel></ResizablePanelGroup>)}diff --git a/apps/carbon/app/routes/x+/job+/update.tsx b/apps/carbon/app/routes/x+/job+/update.tsxnew file mode 100644index 0000000000..51f163b713--- /dev/null+++ b/apps/carbon/app/routes/x+/job+/update.tsx@@ -0,0 +1,104 @@+import { requirePermissions } from "@carbon/auth/auth.server";+import { tasks } from "@trigger.dev/sdk/v3";+import { json, type ActionFunctionArgs } from "@vercel/remix";+import type { recalculateTask } from "~/trigger/recalculate";++export const config = {+ runtime: "nodejs",+};++export async function action({ request }: ActionFunctionArgs) {+ const { client, companyId, userId } = await requirePermissions(request, {+ update: "production",+ });++ const formData = await request.formData();+ const ids = formData.getAll("ids");+ const field = formData.get("field");+ const value = formData.get("value");++ if (+ typeof field !== "string" ||+ (typeof value !== "string" && value !== null)+ ) {+ return json({ error: { message: "Invalid form data" }, data: null });+ }++ switch (field) {+ case "itemId":+ if (!value) {+ return json({ error: { message: "Invalid form data" }, data: null });+ }++ const [item, manufacturing] = await Promise.all([+ client+ .from("item")+ .select(+ "name, readableId, defaultMethodType, unitOfMeasureCode, modelUploadId"+ )+ .eq("id", value)+ .eq("companyId", companyId)+ .single(),+ client+ .from("itemReplenishment")+ .select("lotSize, scrapPercentage")+ .eq("itemId", value)+ .single(),+ ]);++ const result = await client+ .from("job")+ .update({+ itemId: value,+ unitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",+ quantity:+ (manufacturing?.data?.lotSize ?? 0) === 0+ ? undefined+ : manufacturing?.data?.lotSize ?? 0,+ modelUploadId: item.data?.modelUploadId ?? null,+ scrapQuantity: Math.ceil(+ (manufacturing?.data?.lotSize ?? 0) *+ ((manufacturing?.data?.scrapPercentage ?? 0) / 100)+ ),+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[]);++ if (!result.error) {+ await tasks.batchTrigger<typeof recalculateTask>(+ "recalculate",+ ids.map((id) => ({+ payload: {+ type: "jobRequirements",+ id: id as string,+ companyId,+ userId,+ },+ }))+ );+ }++ return json(result);+ case "customerId":+ case "deadlineType":+ case "dueDate":+ case "jobId":+ case "locationId":+ case "quantity":+ case "scrapQuantity":+ case "unitOfMeasureCode":+ return json(+ await client+ .from("job")+ .update({+ [field]: value ? value : null,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ default:+ return json({ error: { message: "Invalid field" }, data: null });+ }+}diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsxindex 68dad47475..1df9447993 100644--- a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx@@ -19,7 +19,6 @@ import {OpportunityDocuments,OpportunityNotes,OpportunityState,- QuoteForm,QuotePaymentForm,QuoteShipmentForm,quoteValidator,@@ -121,7 +120,13 @@ export default function QuoteDetailsRoute() {key={`state-${initialValues.id}`}opportunity={quoteData?.opportunity!}/>- <QuoteForm key={initialValues.id} initialValues={initialValues} />+ <OpportunityNotes+ key={`notes-${initialValues.id}`}+ id={quoteData.quote.id}+ table="quote"+ internalNotes={quoteData.quote.internalNotes as JSONContent}+ externalNotes={quoteData.quote.externalNotes as JSONContent}+ /><Suspensekey={`documents-${quoteId}`}fallback={@@ -149,13 +154,6 @@ export default function QuoteDetailsRoute() {key={`shipment-${initialValues.id}`}initialValues={shipmentInitialValues}/>- <OpportunityNotes- key={`notes-${initialValues.id}`}- id={quoteData.quote.id}- table="quote"- internalNotes={quoteData.quote.internalNotes as JSONContent}- externalNotes={quoteData.quote.externalNotes as JSONContent}- /></>);}diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.tsxindex 9a050eaa3d..11e2b9073d 100644--- a/apps/carbon/app/routes/x+/quote+/$quoteId.tsx+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.tsx@@ -25,6 +25,7 @@ import {getQuoteShipment,QuoteExplorer,QuoteHeader,+ QuoteProperties,} from "~/modules/sales";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -139,12 +140,17 @@ export default function QuoteRoute() {</ScrollArea></ResizablePanel><ResizableHandle withHandle />- <ResizablePanel order={2}>- <ScrollArea className="h-[calc(100vh-99px)]">- <VStack spacing={2} className="p-2">- <Outlet />- </VStack>- </ScrollArea>+ <ResizablePanel order={2} className="z-1">+ <div className="flex h-[calc(100vh-99px)] w-full">+ <div className="flex h-full w-full overflow-y-auto">+ <ScrollArea className="h-[calc(100vh-99px)] w-full">+ <VStack spacing={2} className="p-2">+ <Outlet />+ </VStack>+ </ScrollArea>+ </div>+ <QuoteProperties />+ </div></ResizablePanel></ResizablePanelGroup>)}diff --git a/apps/carbon/app/routes/x+/quote+/update.tsx b/apps/carbon/app/routes/x+/quote+/update.tsxnew file mode 100644index 0000000000..620057b8af--- /dev/null+++ b/apps/carbon/app/routes/x+/quote+/update.tsx@@ -0,0 +1,100 @@+import { requirePermissions } from "@carbon/auth/auth.server";+import { json, type ActionFunctionArgs } from "@vercel/remix";+import { getCurrencyByCode } from "~/modules/accounting";++export async function action({ request }: ActionFunctionArgs) {+ const { client, companyId, userId } = await requirePermissions(request, {+ update: "sales",+ });++ const formData = await request.formData();+ const ids = formData.getAll("ids");+ const field = formData.get("field");+ const value = formData.get("value");++ if (+ typeof field !== "string" ||+ (typeof value !== "string" && value !== null)+ ) {+ return json({ error: { message: "Invalid form data" }, data: null });+ }++ switch (field) {+ case "customerId":+ let currencyCode: string | undefined;+ if (value && ids.length === 1) {+ const customer = await client+ ?.from("customer")+ .select("currencyCode")+ .eq("id", value)+ .single();++ if (customer.data?.currencyCode) {+ currencyCode = customer.data.currencyCode;+ return json(+ await client+ .from("salesOrder")+ .update({+ customerId: value ?? undefined,+ currencyCode: currencyCode ? currencyCode : undefined,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ }+ }++ return json(+ await client+ .from("salesOrder")+ .update({+ customerId: value ?? undefined,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ case "currencyCode":+ const currency = await getCurrencyByCode(+ client,+ companyId,+ value as string+ );+ if (currency.data) {+ return json(+ await client+ .from("quote")+ .update({+ currencyCode: value,+ exchangeRate: currency.data.exchangeRate,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ }+ // don't break -- just let it catch the next case++ case "customerContactId":+ case "customerLocationId":+ case "customerReference":+ case "dueDate":+ case "estimatorId":+ case "expirationDate":+ case "locationId":+ case "salesPersonId":+ return json(+ await client+ .from("quote")+ .update({+ [field]: value ? value : null,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ default:+ return json({ error: { message: "Invalid field" }, data: null });+ }+}diff --git a/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx b/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsxindex fbf6a1123e..ee77bb5504 100644--- a/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx+++ b/apps/carbon/app/routes/x+/sales-order+/$orderId.details.tsx@@ -15,7 +15,6 @@ import {OpportunityDocuments,OpportunityNotes,OpportunityState,- SalesOrderForm,SalesOrderPaymentForm,SalesOrderShipmentForm,salesOrderValidator,@@ -131,15 +130,12 @@ export async function action({ request, params }: ActionFunctionArgs) {}export default function SalesOrderRoute() {- const {- salesOrderShipment,- salesOrderPayment,- originatedFromQuote,- quote,- // shippingTerms,- } = useLoaderData<typeof loader>();+ const { salesOrderShipment, salesOrderPayment } =+ useLoaderData<typeof loader>();+const { orderId } = useParams();if (!orderId) throw new Error("Could not find orderId");+const orderData = useRouteData<{salesOrder: SalesOrder;opportunity: Opportunity;@@ -147,30 +143,6 @@ export default function SalesOrderRoute() {}>(path.to.salesOrder(orderId));if (!orderData) throw new Error("Could not find order data");- const initialValues = {- id: orderData?.salesOrder?.id ?? "",- salesOrderId: orderData?.salesOrder?.salesOrderId ?? "",- customerId: orderData?.salesOrder?.customerId ?? "",- customerContactId: orderData?.salesOrder?.customerContactId ?? "",- customerLocationId: orderData?.salesOrder?.customerLocationId ?? "",- customerReference: orderData?.salesOrder?.customerReference ?? "",- orderDate: orderData?.salesOrder?.orderDate ?? "",- status: orderData?.salesOrder?.status ?? ("Draft" as "Draft"),- receiptRequestedDate: orderData?.salesOrder?.receiptRequestedDate ?? "",- receiptPromisedDate: orderData?.salesOrder?.receiptPromisedDate ?? "",- externalNotes: orderData?.salesOrder?.externalNotes ?? {},- internalNotes: orderData?.salesOrder?.internalNotes ?? {},- currencyCode: orderData?.salesOrder?.currencyCode ?? "",- exchangeRate: orderData?.salesOrder?.exchangeRate ?? undefined,- exchangeRateUpdatedAt: orderData?.salesOrder?.exchangeRateUpdatedAt ?? "",- originatedFromQuote: originatedFromQuote,- salesPersonId: orderData?.salesOrder?.salesPersonId ?? "",- digitalQuoteAcceptedBy: quote?.data?.digitalQuoteAcceptedBy ?? undefined,- digitalQuoteAcceptedByEmail:- quote?.data?.digitalQuoteAcceptedByEmail ?? undefined,- ...getCustomFields(orderData?.salesOrder?.customFields),- };-const shipmentInitialValues = {id: salesOrderShipment.id,locationId: salesOrderShipment.locationId ?? "",@@ -200,7 +172,13 @@ export default function SalesOrderRoute() {return (<><OpportunityState opportunity={orderData.opportunity} />- <SalesOrderForm key={initialValues.id} initialValues={initialValues} />+ <OpportunityNotes+ key={`notes-${orderId}`}+ id={orderData.salesOrder.id}+ table="salesOrder"+ internalNotes={orderData.salesOrder.internalNotes as JSONContent}+ externalNotes={orderData.salesOrder.externalNotes as JSONContent}+ /><Suspensekey={`documents-${orderId}`}fallback={@@ -220,22 +198,14 @@ export default function SalesOrderRoute() {)}</Await></Suspense>- <OpportunityNotes- key={`notes-${orderId}`}- id={orderData.salesOrder.id}- table="salesOrder"- internalNotes={orderData.salesOrder.internalNotes as JSONContent}- externalNotes={orderData.salesOrder.externalNotes as JSONContent}- />+<SalesOrderShipmentForm- key={`shipment-${initialValues.id}`}+ key={`shipment-${orderId}`}initialValues={shipmentInitialValues}-- // shippingTerms={shippingTerms as ListItem[]}/><SalesOrderPaymentForm- key={`payment-${initialValues.id}`}+ key={`payment-${orderId}`}initialValues={paymentInitialValues}/></>diff --git a/apps/carbon/app/routes/x+/sales-order+/$orderId.tsx b/apps/carbon/app/routes/x+/sales-order+/$orderId.tsxindex 1eec4e63f7..415fe380be 100644--- a/apps/carbon/app/routes/x+/sales-order+/$orderId.tsx+++ b/apps/carbon/app/routes/x+/sales-order+/$orderId.tsx@@ -20,6 +20,7 @@ import {getSalesOrderLines,SalesOrderExplorer,SalesOrderHeader,+ SalesOrderProperties,} from "~/modules/sales";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -96,11 +97,16 @@ export default function SalesOrderRoute() {</ResizablePanel><ResizableHandle withHandle /><ResizablePanel order={2}>- <ScrollArea className="h-[calc(100vh-99px)]">- <VStack spacing={2} className="p-2">- <Outlet />- </VStack>- </ScrollArea>+ <div className="flex h-[calc(100vh-99px)] w-full">+ <div className="flex h-full w-full overflow-y-auto">+ <ScrollArea className="h-[calc(100vh-99px)] w-full">+ <VStack spacing={2} className="p-2">+ <Outlet />+ </VStack>+ </ScrollArea>+ </div>+ <SalesOrderProperties />+ </div></ResizablePanel></ResizablePanelGroup>)}diff --git a/apps/carbon/app/routes/x+/sales-order+/update.tsx b/apps/carbon/app/routes/x+/sales-order+/update.tsxnew file mode 100644index 0000000000..7cb74aa7b8--- /dev/null+++ b/apps/carbon/app/routes/x+/sales-order+/update.tsx@@ -0,0 +1,107 @@+import { requirePermissions } from "@carbon/auth/auth.server";+import { json, type ActionFunctionArgs } from "@vercel/remix";+import { getCurrencyByCode } from "~/modules/accounting";++export async function action({ request }: ActionFunctionArgs) {+ const { client, companyId, userId } = await requirePermissions(request, {+ update: "sales",+ });++ const formData = await request.formData();+ const ids = formData.getAll("ids");+ const field = formData.get("field");+ const value = formData.get("value");++ if (+ typeof field !== "string" ||+ (typeof value !== "string" && value !== null)+ ) {+ return json({ error: { message: "Invalid form data" }, data: null });+ }++ switch (field) {+ case "customerId":+ let currencyCode: string | undefined;+ if (value && ids.length === 1) {+ const customer = await client+ ?.from("customer")+ .select("currencyCode")+ .eq("id", value)+ .single();++ if (customer.data?.currencyCode) {+ currencyCode = customer.data.currencyCode;+ const currency = await getCurrencyByCode(+ client,+ companyId,+ currencyCode+ );+ return json(+ await client+ .from("salesOrder")+ .update({+ customerId: value ?? undefined,+ currencyCode: currencyCode ?? undefined,+ exchangeRate: currency.data?.exchangeRate ?? 1,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ }+ }++ return json(+ await client+ .from("salesOrder")+ .update({+ customerId: value ?? undefined,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ case "currencyCode":+ if (value) {+ const currency = await getCurrencyByCode(+ client,+ companyId,+ value as string+ );+ if (currency.data) {+ return json(+ await client+ .from("salesOrder")+ .update({+ currencyCode: value as string,+ exchangeRate: currency.data.exchangeRate,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ }+ }+ // don't break -- just let it catch the next case+ case "customerContactId":+ case "customerLocationId":+ case "customerReference":+ case "exchangeRate":+ case "expirationDate":+ case "locationId":+ case "orderDate":+ case "salesPersonId":+ return json(+ await client+ .from("salesOrder")+ .update({+ [field]: value ? value : null,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ default:+ return json({ error: { message: "Invalid field" }, data: null });+ }+}diff --git a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsxindex efa13c74d8..645eb81bd6 100644--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.details.tsx@@ -4,28 +4,21 @@ import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";import { Spinner, VStack } from "@carbon/react";-import { parseDate } from "@internationalized/date";import { Await, useParams } from "@remix-run/react";import type { FileObject } from "@supabase/storage-js";import type { ActionFunctionArgs } from "@vercel/remix";import { redirect } from "@vercel/remix";import { Suspense } from "react";import { useRouteData } from "~/hooks";-import type {- Opportunity,- SalesRFQ,- SalesRFQLine,- SalesRFQStatusType,-} from "~/modules/sales";+import type { Opportunity, SalesRFQ, SalesRFQLine } from "~/modules/sales";import {OpportunityDocuments,OpportunityNotes,OpportunityState,- SalesRFQForm,salesRfqValidator,upsertSalesRFQ,} from "~/modules/sales";-import { getCustomFields, setCustomFields } from "~/utils/form";+import { setCustomFields } from "~/utils/form";import { path } from "~/utils/path";export async function action({ request, params }: ActionFunctionArgs) {@@ -80,35 +73,18 @@ export default function SalesRFQDetailsRoute() {if (!rfqData) throw new Error("Could not find rfq data");- const initialValues = {- customerContactId: rfqData?.rfqSummary?.customerContactId ?? "",- customerLocationId: rfqData?.rfqSummary?.customerLocationId ?? "",- customerId: rfqData?.rfqSummary?.customerId ?? "",- customerReference: rfqData?.rfqSummary?.customerReference ?? "",- expirationDate: rfqData?.rfqSummary?.expirationDate- ? parseDate(rfqData?.rfqSummary?.expirationDate).toString()- : "",- id: rfqData?.rfqSummary?.id ?? "",- locationId: rfqData?.rfqSummary?.locationId ?? "",- rfqDate: rfqData?.rfqSummary?.rfqDate- ? parseDate(rfqData?.rfqSummary?.rfqDate).toString()- : "",- rfqId: rfqData?.rfqSummary?.rfqId ?? "",- status: rfqData?.rfqSummary?.status ?? ("Draft" as SalesRFQStatusType),- salesPersonId: rfqData?.rfqSummary?.salesPersonId ?? "",-- ...getCustomFields(rfqData.rfqSummary?.customFields ?? {}),- };-return (<VStack spacing={2}><OpportunityState- key={`state-${initialValues.id}`}+ key={`state-${rfqId}`}opportunity={rfqData?.opportunity!}/>- <SalesRFQForm- key={`${initialValues.id}:${initialValues.status}`}- initialValues={initialValues}+ <OpportunityNotes+ key={`notes-${rfqId}`}+ id={rfqData.rfqSummary.id}+ table="salesRfq"+ internalNotes={rfqData.rfqSummary.internalNotes as JSONContent}+ externalNotes={rfqData.rfqSummary.externalNotes as JSONContent}/><Suspensekey={`documents-${rfqId}`}@@ -129,13 +105,6 @@ export default function SalesRFQDetailsRoute() {)}</Await></Suspense>- <OpportunityNotes- key={`notes-${rfqId}`}- id={rfqData.rfqSummary.id}- table="salesRfq"- internalNotes={rfqData.rfqSummary.internalNotes as JSONContent}- externalNotes={rfqData.rfqSummary.externalNotes as JSONContent}- /></VStack>);}diff --git a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsxindex 8ff88aa373..dadb4b70be 100644--- a/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx+++ b/apps/carbon/app/routes/x+/sales-rfq+/$rfqId.tsx@@ -23,6 +23,7 @@ import {getSalesRFQLines,SalesRFQExplorer,SalesRFQHeader,+ SalesRFQProperties,} from "~/modules/sales";import { error, getCarbonServiceRole } from "@carbon/auth";@@ -170,11 +171,16 @@ export default function SalesRFQRoute() {</ResizablePanel><ResizableHandle withHandle /><ResizablePanel order={2} className="z-1">- <ScrollArea className="h-[calc(100vh-99px)]">- <VStack spacing={2} className="p-2">- <Outlet />- </VStack>- </ScrollArea>+ <div className="flex h-[calc(100vh-99px)] w-full">+ <div className="flex h-full w-full overflow-y-auto">+ <ScrollArea className="h-[calc(100vh-99px)] w-full">+ <VStack spacing={2} className="p-2">+ <Outlet />+ </VStack>+ </ScrollArea>+ </div>+ <SalesRFQProperties />+ </div></ResizablePanel></ResizablePanelGroup>)}diff --git a/apps/carbon/app/routes/x+/sales-rfq+/update.tsx b/apps/carbon/app/routes/x+/sales-rfq+/update.tsxnew file mode 100644index 0000000000..deb003ed18--- /dev/null+++ b/apps/carbon/app/routes/x+/sales-rfq+/update.tsx@@ -0,0 +1,43 @@+import { requirePermissions } from "@carbon/auth/auth.server";+import { json, type ActionFunctionArgs } from "@vercel/remix";++export async function action({ request }: ActionFunctionArgs) {+ const { client, userId } = await requirePermissions(request, {+ update: "sales",+ });++ const formData = await request.formData();+ const ids = formData.getAll("ids");+ const field = formData.get("field");+ const value = formData.get("value");++ if (+ typeof field !== "string" ||+ (typeof value !== "string" && value !== null)+ ) {+ return json({ error: { message: "Invalid form data" }, data: null });+ }++ switch (field) {+ case "customerContactId":+ case "customerId":+ case "customerLocationId":+ case "customerReference":+ case "expirationDate":+ case "locationId":+ case "rfqDate":+ case "salesPersonId":+ return json(+ await client+ .from("salesRfq")+ .update({+ [field]: value ? value : null,+ updatedBy: userId,+ updatedAt: new Date().toISOString(),+ })+ .in("id", ids as string[])+ );+ default:+ return json({ error: { message: "Invalid field" }, data: null });+ }+}diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.tsindex e394aff2ac..6a769e4bcd 100644--- a/apps/carbon/app/utils/path.ts+++ b/apps/carbon/app/utils/path.ts@@ -124,6 +124,10 @@ export const path = {generatePath(`${x}/people/attributes/list/${id}`),bulkEditPermissions: `${x}/users/bulk-edit-permissions`,bulkUpdateItems: `${x}/items/update`,+ bulkUpdateJob: `${x}/job/update`,+ bulkUpdateQuote: `${x}/quote/update`,+ bulkUpdateSalesOrder: `${x}/sales-order/update`,+ bulkUpdateSalesRfq: `${x}/sales-rfq/update`,chartOfAccount: (id: string) =>generatePath(`${x}/accounting/charts/${id}`),chartOfAccounts: `${x}/accounting/charts`,diff --git a/packages/form/src/components/Combobox.tsx b/packages/form/src/components/Combobox.tsxindex d4391314b2..50caa645a8 100644--- a/packages/form/src/components/Combobox.tsx+++ b/packages/form/src/components/Combobox.tsx@@ -7,6 +7,7 @@ import {FormLabel,} from "@carbon/react";import { useEffect } from "react";+import { flushSync } from "react-dom";import { useControlField, useField } from "../hooks";export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {@@ -16,6 +17,10 @@ export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {isOptional?: boolean;helperText?: string;onChange?: (newValue: { value: string; label: string } | null) => void;+ inline?: (+ value: string,+ options: { value: string; label: string; helper?: string }[]+ ) => React.ReactNode;};const Combobox = ({@@ -28,6 +33,7 @@ const Combobox = ({}: ComboboxProps) => {const { getInputProps, error } = useField(name);const [value, setValue] = useControlField<string | undefined>(name);+useEffect(() => {if (props.value !== null && props.value !== undefined)setValue(props.value ?? "");@@ -61,8 +67,10 @@ const Combobox = ({{...props}value={value}onChange={(newValue) => {- setValue(newValue ?? "");- onChange(newValue ?? "");+ flushSync(() => {+ setValue(newValue?.replace(/"/g, '\\"') ?? "");+ });+ onChange(newValue?.replace(/"/g, '\\"') ?? "");}}isClearable={isOptional && !props.isReadOnly}isLoading={isLoading}diff --git a/packages/form/src/components/CreatableCombobox.tsx b/packages/form/src/components/CreatableCombobox.tsxindex e6a851c325..482dc7f728 100644--- a/packages/form/src/components/CreatableCombobox.tsx+++ b/packages/form/src/components/CreatableCombobox.tsx@@ -8,6 +8,7 @@ import {} from "@carbon/react";import { forwardRef, useEffect } from "react";+import { flushSync } from "react-dom";import { useControlField, useField } from "../hooks";export type CreatableComboboxProps = Omit<@@ -18,6 +19,10 @@ export type CreatableComboboxProps = Omit<label?: string;helperText?: string;isOptional?: boolean;+ inline?: (+ value: string,+ options: { value: string; label: string; helper?: string }[]+ ) => React.ReactNode;onChange?: (newValue: { value: string; label: string } | null) => void;};@@ -59,13 +64,15 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(ref={ref}{...props}value={value?.replace(/"/g, '\\"')}- onChange={(newValue) => {- setValue(newValue?.replace(/"/g, '\\"') ?? "");- onChange(newValue?.replace(/"/g, '\\"') ?? "");- }}isClearable={isOptional && !props.isReadOnly}label={label}className="w-full"+ onChange={(newValue) => {+ flushSync(() => {+ setValue(newValue?.replace(/"/g, '\\"') ?? "");+ });+ onChange(newValue?.replace(/"/g, '\\"') ?? "");+ }}/>{error ? (diff --git a/packages/form/src/components/DatePicker.tsx b/packages/form/src/components/DatePicker.tsxindex c182d99049..56a3cf96ee 100644--- a/packages/form/src/components/DatePicker.tsx+++ b/packages/form/src/components/DatePicker.tsx@@ -1,21 +1,25 @@+import { useFormContext } from "@carbon/form";import {DatePicker as DatePickerBase,FormControl,FormErrorMessage,FormLabel,} from "@carbon/react";+import { formatDate } from "@carbon/utils";import type { CalendarDate } from "@internationalized/date";import { getLocalTimeZone, parseDate, toZoned } from "@internationalized/date";import { useState } from "react";+import { flushSync } from "react-dom";import { useField } from "../hooks";type DatePickerProps = {name: string;label?: string;- onChange?: (date: CalendarDate) => void;isDisabled?: boolean;minValue?: CalendarDate;maxValue?: CalendarDate;+ inline?: boolean;+ onChange?: (date: string | null) => void;};const DatePicker = ({@@ -24,24 +28,43 @@ const DatePicker = ({isDisabled = false,minValue,maxValue,+ inline = false,onChange,}: DatePickerProps) => {- const { error, defaultValue, validate } = useField(name);+ const { validate } = useFormContext();+ const { error, defaultValue, validate: validateField } = useField(name);const [date, setDate] = useState<CalendarDate | undefined>(defaultValue ? parseDate(defaultValue) : undefined);- const handleChange = (date: CalendarDate) => {- setDate(date);- onChange?.(date);- validate();+ const handleChange = async (newDate: CalendarDate) => {+ const formattedDate = newDate+ ? toZoned(newDate, getLocalTimeZone()).toAbsoluteString()+ : null;+ flushSync(() => {+ setDate(newDate);+ });+ if (inline) {+ const result = await validate();+ if (result.error) {+ setDate(date);+ } else {+ onChange?.(formattedDate);+ }+ } else {+ validateField();+ onChange?.(formattedDate);+ }};- // Convert local time to UTC for storageconst utcValue = date? toZoned(date, getLocalTimeZone()).toAbsoluteString(): "";+ const DatePickerPreview = (+ <span className="flex-grow line-clamp-1">{formatDate(utcValue)}</span>+ );+return (<FormControl isInvalid={!!error}>{label && <FormLabel htmlFor={name}>{label}</FormLabel>}@@ -52,6 +75,7 @@ const DatePicker = ({minValue={minValue}maxValue={maxValue}onChange={handleChange}+ inline={inline ? DatePickerPreview : undefined}/>{error && <FormErrorMessage>{error}</FormErrorMessage>}</FormControl>diff --git a/packages/form/src/components/InputControlled.tsx b/packages/form/src/components/InputControlled.tsxindex 14d102ccbd..ac2e5e046f 100644--- a/packages/form/src/components/InputControlled.tsx+++ b/packages/form/src/components/InputControlled.tsx@@ -1,26 +1,32 @@+import { useFormContext } from "@carbon/form";import type { InputProps } from "@carbon/react";import {FormControl,FormErrorMessage,FormHelperText,FormLabel,+ HStack,+ IconButton,Input as InputBase,InputGroup,InputLeftAddon,InputRightAddon,+ VStack,} from "@carbon/react";-import type { ChangeEvent } from "react";-import { forwardRef, useEffect } from "react";+import type { ChangeEvent, ReactNode } from "react";+import { forwardRef, useEffect, useRef, useState } from "react";+import { LuPlus, LuSettings2 } from "react-icons/lu";import { useControlField, useField } from "../hooks";type FormInputControlledProps = Omit<InputProps, "value" | "onChange"> & {name: string;- label?: string;+ label?: ReactNode;isUppercase?: boolean;isRequired?: boolean;helperText?: string;prefix?: string;suffix?: string;+ inline?: boolean;value: string;onChange?: (newValue: string) => void;};@@ -38,17 +44,28 @@ const InputControlled = forwardRef<HTMLInputElement, FormInputControlledProps>(className,onChange,isUppercase,+ inline = false,+ onBlur,...rest},ref) => {+ const { validate } = useFormContext();const { getInputProps, error } = useField(name);const [controlValue, setControlValue] = useControlField<string>(name);+ const [inlineMode, setInlineMode] = useState(inline);+ const inputRef = useRef<HTMLInputElement>(null);useEffect(() => {setControlValue(isUppercase ? uppercase(value) : value);}, [isUppercase, setControlValue, value]);+ useEffect(() => {+ if (inline && !inlineMode) {+ inputRef.current?.focus();+ }+ }, [inline, inlineMode]);+const handleChange = (e: ChangeEvent<HTMLInputElement>) => {setControlValue(e.target.value);if (onChange && typeof onChange === "function") {@@ -56,17 +73,71 @@ const InputControlled = forwardRef<HTMLInputElement, FormInputControlledProps>(}};- return (+ return inlineMode ? (+ <VStack>+ {label && (+ <span className="text-xs text-muted-foreground">{label}</span>+ )}+ <HStack spacing={0} className="w-full justify-between">+ {value && <span className="flex-grow line-clamp-1">{value}</span>}+ <IconButton+ icon={value ? <LuSettings2 /> : <LuPlus />}+ aria-label={value ? "Edit" : "Add"}+ size="sm"+ variant="secondary"+ onClick={() => setInlineMode(false)}+ />+ </HStack>+ </VStack>+ ) : (<FormControlisInvalid={!!error}isRequired={isRequired}className={className}>{label && <FormLabel htmlFor={name}>{label}</FormLabel>}- <InputGroup>- {prefix && <InputLeftAddon children={prefix} />}+ {prefix || suffix ? (+ <InputGroup>+ {prefix && <InputLeftAddon children={prefix} />}+ <InputBase+ ref={(node) => {+ if (typeof ref === "function") {+ ref(node);+ } else if (ref) {+ ref.current = node;+ }+ inputRef.current = node;+ }}+ {...getInputProps({+ id: name,+ ...rest,+ // @ts-ignore+ value: controlValue,+ })}+ onChange={handleChange}+ value={controlValue}+ onBlur={async (e) => {+ if (inline) {+ const result = await validate();+ if (!result.error) {+ onBlur?.(e);+ setInlineMode(true);+ }+ }+ }}+ />+ {suffix && <InputRightAddon children={suffix} />}+ </InputGroup>+ ) : (<InputBase- ref={ref}+ ref={(node) => {+ if (typeof ref === "function") {+ ref(node);+ } else if (ref) {+ ref.current = node;+ }+ inputRef.current = node;+ }}{...getInputProps({id: name,...rest,@@ -75,9 +146,19 @@ const InputControlled = forwardRef<HTMLInputElement, FormInputControlledProps>(})}onChange={handleChange}value={controlValue}+ onBlur={async (e) => {+ if (inline) {+ const result = await validate();+ if (!result.error) {+ onBlur?.(e);+ setInlineMode(true);+ }+ } else {+ onBlur?.(e);+ }+ }}/>- {suffix && <InputRightAddon children={suffix} />}- </InputGroup>+ )}{helperText && <FormHelperText>{helperText}</FormHelperText>}{error && <FormErrorMessage>{error}</FormErrorMessage>}</FormControl>diff --git a/packages/form/src/components/NumberControlled.tsx b/packages/form/src/components/NumberControlled.tsxindex 1d83fb9dee..c778a19ea1 100644--- a/packages/form/src/components/NumberControlled.tsx+++ b/packages/form/src/components/NumberControlled.tsx@@ -4,24 +4,35 @@ import {FormErrorMessage,FormHelperText,FormLabel,+ HStack,+ IconButton,NumberDecrementStepper,NumberField,NumberIncrementStepper,NumberInput,NumberInputGroup,NumberInputStepper,+ VStack,} from "@carbon/react";-import { forwardRef, useEffect } from "react";-import { LuChevronDown, LuChevronUp } from "react-icons/lu";+import { useFormContext } from "@carbon/form";+import type { ReactNode } from "react";+import { forwardRef, useEffect, useRef, useState } from "react";+import {+ LuChevronDown,+ LuChevronUp,+ LuPlus,+ LuSettings2,+} from "react-icons/lu";import { useControlField, useField } from "../hooks";type FormNumberProps = NumberFieldProps & {name: string;- label?: string;+ label?: ReactNode;isRequired?: boolean;helperText?: string;value: number;+ inline?: boolean;onChange?: (newValue: number) => void;};@@ -35,23 +46,52 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(helperText,value,onChange,+ inline = false,+ onBlur,...rest},ref) => {+ const { validate } = useFormContext();const { getInputProps, error } = useField(name);const [controlValue, setControlValue] = useControlField<number>(name);+ const [inlineMode, setInlineMode] = useState(inline);+ const inputRef = useRef<HTMLInputElement>(null);useEffect(() => {setControlValue(value);}, [setControlValue, value]);+ useEffect(() => {+ if (inline && !inlineMode) {+ inputRef.current?.focus();+ }+ }, [inline, inlineMode]);+const handleChange = (newValue: number) => {setControlValue(newValue);onChange?.(newValue);};- return (+ return inlineMode ? (+ <VStack>+ {label && (+ <span className="text-xs text-muted-foreground">{label}</span>+ )}+ <HStack spacing={0} className="w-full justify-between">+ {value !== undefined && (+ <span className="flex-grow line-clamp-1">{value}</span>+ )}+ <IconButton+ icon={value !== undefined ? <LuSettings2 /> : <LuPlus />}+ aria-label={value !== undefined ? "Edit" : "Add"}+ size="sm"+ variant="secondary"+ onClick={() => setInlineMode(false)}+ />+ </HStack>+ </VStack>+ ) : (<FormControl isInvalid={!!error} isRequired={isRequired}>{label && <FormLabel htmlFor={name}>{label}</FormLabel>}<NumberField@@ -61,6 +101,17 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(})}value={controlValue}onChange={handleChange}+ onBlur={async (e) => {+ if (inline) {+ const result = await validate();+ if (!result.error) {+ onBlur?.(e);+ setInlineMode(true);+ }+ } else {+ onBlur?.(e);+ }+ }}><NumberInputGroup className="relative"><NumberInput isReadOnly={isReadOnly} />diff --git a/packages/form/src/components/Select.tsx b/packages/form/src/components/Select.tsxindex 05a0a03e1b..37308e6124 100644--- a/packages/form/src/components/Select.tsx+++ b/packages/form/src/components/Select.tsx@@ -26,6 +26,10 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {onChange?: (newValue: { value: string; label: string | JSX.Element } | null) => void;+ inline?: (+ value: string,+ options: { value: string; label: string | JSX.Element }[]+ ) => JSX.Element;};const Select = ({@@ -34,6 +38,8 @@ const Select = ({helperText,isOptional = false,isLoading,+ inline,+ options,...props}: SelectProps) => {const { getInputProps, error } = useField(name);@@ -41,12 +47,14 @@ const Select = ({const onChange = (value: string) => {if (value) {- props?.onChange?.(props.options.find((o) => o.value === value) ?? null);+ props?.onChange?.(options.find((o) => o.value === value) ?? null);} else {props?.onChange?.(null);}};+ const inlinePreview = !!inline;+return (<FormControl isInvalid={!!error} className={props.className}>{label && (@@ -54,6 +62,7 @@ const Select = ({{label}</FormLabel>)}+<input{...getInputProps({id: name,@@ -65,6 +74,7 @@ const Select = ({/><SelectBase{...props}+ options={options}value={value}onChange={(newValue) => {setValue(newValue ?? "");diff --git a/packages/form/src/components/SelectControlled.tsx b/packages/form/src/components/SelectControlled.tsxindex 3a47f3f5c1..496f4bf141 100644--- a/packages/form/src/components/SelectControlled.tsx+++ b/packages/form/src/components/SelectControlled.tsx@@ -15,8 +15,10 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {label?: string;helperText?: string;isOptional?: boolean;- options: { value: string | number; label: string }[];- onChange?: (newValue: { value: string; label: string } | null) => void;+ options: { value: string | number; label: string | JSX.Element }[];+ onChange?: (+ newValue: { value: string; label: string | JSX.Element } | null+ ) => void;};const SelectControlled = ({diff --git a/packages/react/src/Combobox.tsx b/packages/react/src/Combobox.tsxindex 88c407a2a1..27d1da2012 100644--- a/packages/react/src/Combobox.tsx+++ b/packages/react/src/Combobox.tsx@@ -1,7 +1,7 @@import { useVirtualizer } from "@tanstack/react-virtual";import type { ComponentPropsWithoutRef } from "react";import { forwardRef, useMemo, useRef, useState } from "react";-import { LuCheck, LuX } from "react-icons/lu";+import { LuCheck, LuPlus, LuSettings2, LuX } from "react-icons/lu";import {Command,CommandGroup,@@ -31,6 +31,10 @@ export type ComboboxProps = Omit<isReadOnly?: boolean;placeholder?: string;onChange?: (selected: string) => void;+ inline?: (+ value: string,+ options: { value: string; label: string; helper?: string }[]+ ) => React.ReactNode;itemHeight?: number;};@@ -45,34 +49,59 @@ const Combobox = forwardRef<HTMLButtonElement, ComboboxProps>(isReadOnly,placeholder,onChange,+ inline,itemHeight = 40,...props},ref) => {const [open, setOpen] = useState(false);+ const isInlinePreview = !!inline;return (- <HStack spacing={1}>+ <HStack+ className={cn(isInlinePreview ? "w-full" : "min-w-0 flex-grow")}+ spacing={isInlinePreview ? 2 : 1}+ >+ {isInlinePreview && value && (+ <span className="flex-grow line-clamp-1">+ {inline(value, options)}+ </span>+ )}+<Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>- <CommandTrigger- size={size}- role="combobox"- className={cn("min-w-[160px]", !value && "text-muted-foreground")}- icon={isLoading ? <Spinner /> : undefined}- ref={ref}- {...props}- onClick={() => setOpen(true)}- >- {value ? (- options.find((option) => option.value === value)?.label- ) : (- <span className="!text-muted-foreground">- {placeholder ?? "Select"}- </span>- )}- </CommandTrigger>+ {inline ? (+ <IconButton+ size={size ?? "sm"}+ variant="secondary"+ aria-label={value ? "Edit" : "Add"}+ icon={value ? <LuSettings2 /> : <LuPlus />}+ ref={ref}+ onClick={() => setOpen(true)}+ />+ ) : (+ <CommandTrigger+ size={size}+ role="combobox"+ className={cn(+ "min-w-[160px]",+ !value && "text-muted-foreground"+ )}+ icon={isLoading ? <Spinner /> : undefined}+ ref={ref}+ {...props}+ onClick={() => setOpen(true)}+ >+ {value ? (+ options.find((option) => option.value === value)?.label+ ) : (+ <span className="!text-muted-foreground">+ {placeholder ?? "Select"}+ </span>+ )}+ </CommandTrigger>+ )}</PopoverTrigger><PopoverContentalign="start"diff --git a/packages/react/src/CreateableCombobox.tsx b/packages/react/src/CreateableCombobox.tsxindex f04d32ba65..5d13d6ad63 100644--- a/packages/react/src/CreateableCombobox.tsx+++ b/packages/react/src/CreateableCombobox.tsx@@ -1,7 +1,7 @@import { useVirtualizer } from "@tanstack/react-virtual";import type { ComponentPropsWithoutRef } from "react";import { forwardRef, useMemo, useRef, useState } from "react";-import { LuCheck, LuX } from "react-icons/lu";+import { LuCheck, LuPlus, LuSettings2, LuX } from "react-icons/lu";import {Command,CommandGroup,@@ -30,6 +30,10 @@ export type CreatableComboboxProps = Omit<isReadOnly?: boolean;label?: string;placeholder?: string;+ inline?: (+ value: string,+ options: { value: string; label: string; helper?: string }[]+ ) => React.ReactNode;onChange?: (selected: string) => void;onCreateOption?: (inputValue: string) => void;itemHeight?: number;@@ -47,38 +51,60 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(placeholder,onChange,label,- onCreateOption,itemHeight = 40,+ inline,+ onCreateOption,...props},ref) => {const [open, setOpen] = useState(false);const [search, setSearch] = useState("");+ const isInlinePreview = !!inline;return (- <HStack className="min-w-0 flex-grow" spacing={1}>+ <HStack+ className={cn(isInlinePreview ? "w-full" : "min-w-0 flex-grow")}+ spacing={1}+ >+ {isInlinePreview && value && (+ <span className="flex-grow line-clamp-1">+ {inline(value, options)}+ </span>+ )}+<Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>- <CommandTrigger- size={size}- role="combobox"- className={cn(- "min-w-[160px]",- !value && "text-muted-foreground truncate"- )}- ref={ref}- {...props}- onClick={() => setOpen(true)}- >- {value ? (- options.find((option) => option.value === value)?.label- ) : (- <span className="!text-muted-foreground">- {placeholder ?? "Select"}- </span>- )}- </CommandTrigger>+ {inline ? (+ <IconButton+ size={size ?? "sm"}+ variant="secondary"+ aria-label={value ? "Edit" : "Add"}+ icon={value ? <LuSettings2 /> : <LuPlus />}+ ref={ref}+ onClick={() => setOpen(true)}+ />+ ) : (+ <CommandTrigger+ size={size}+ role="combobox"+ className={cn(+ "min-w-[160px]",+ !value && "text-muted-foreground truncate"+ )}+ ref={ref}+ {...props}+ onClick={() => setOpen(true)}+ >+ {value ? (+ options.find((option) => option.value === value)?.label+ ) : (+ <span className="!text-muted-foreground">+ {placeholder ?? "Select"}+ </span>+ )}+ </CommandTrigger>+ )}</PopoverTrigger><PopoverContentalign="start"@@ -100,11 +126,11 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(</Popover>{isClearable && !isReadOnly && value && (<IconButton- variant="ghost"+ variant={isInlinePreview ? "secondary" : "ghost"}aria-label="Clear"icon={<LuX />}onClick={() => onChange?.("")}- size={size === "sm" ? "md" : size}+ size={isInlinePreview ? "sm" : size}/>)}</HStack>diff --git a/packages/react/src/Date/DatePicker.tsx b/packages/react/src/Date/DatePicker.tsxindex 3f27295a2d..6e25b0a7f4 100644--- a/packages/react/src/Date/DatePicker.tsx+++ b/packages/react/src/Date/DatePicker.tsx@@ -2,16 +2,27 @@ import type { CalendarDate } from "@internationalized/date";import { useDatePicker } from "@react-aria/datepicker";import { useDatePickerState } from "@react-stately/datepicker";import type { DatePickerProps } from "@react-types/datepicker";+import type { ReactNode } from "react";import { useRef } from "react";-import { LuBan } from "react-icons/lu";+import { LuBan, LuCalendarClock } from "react-icons/lu";+import { Button } from "../Button";import { HStack } from "../HStack";+import { IconButton } from "../IconButton";import { InputGroup } from "../Input";+import {+ Popover,+ PopoverContent,+ PopoverFooter,+ PopoverTrigger,+} from "../Popover";import { useOutsideClick } from "../hooks";import { FieldButton } from "./components/Button";import { Calendar } from "./components/Calendar";import DateField from "./components/DateField";-import { Popover } from "./components/Popover";-const DatePicker = (props: DatePickerProps<CalendarDate>) => {++const DatePicker = (+ props: DatePickerProps<CalendarDate> & { inline?: ReactNode }+) => {const state = useDatePickerState({...props,shouldCloseOnSelect: false,@@ -26,29 +37,52 @@ const DatePicker = (props: DatePickerProps<CalendarDate>) => {});return (- <div className="relative inline-flex flex-col w-full">- <HStack className="w-full" spacing={0}>- <InputGroup- {...groupProps}- ref={ref}- className="w-full inline-flex rounded-r-none"- >- <div className="flex w-full px-4 py-2">- <DateField {...fieldProps} />- {state.isInvalid && (- <LuBan className="!text-destructive-foreground absolute right-[12px] top-[12px]" />- )}- </div>- </InputGroup>-- <FieldButton {...buttonProps} isPressed={state.isOpen} />- </HStack>- {state.isOpen && (- <Popover {...dialogProps} onClose={() => state.setOpen(false)}>+ <Popover open={state.isOpen} onOpenChange={state.setOpen}>+ <div className="relative inline-flex flex-col w-full">+ <HStack className="w-full" spacing={0}>+ {props.inline ? (+ <>+ <div className="flex-grow">{props.inline}</div>+ <PopoverTrigger asChild>+ <IconButton+ icon={<LuCalendarClock />}+ variant="secondary"+ size="sm"+ aria-label="Open date picker"+ {...buttonProps}+ />+ </PopoverTrigger>+ </>+ ) : (+ <>+ <InputGroup+ {...groupProps}+ ref={ref}+ className="w-full inline-flex rounded-r-none"+ >+ <div className="flex w-full px-4 py-2">+ <DateField {...fieldProps} />+ {state.isInvalid && (+ <LuBan className="!text-destructive-foreground absolute right-[12px] top-[12px]" />+ )}+ </div>+ </InputGroup>+ <PopoverTrigger>+ <FieldButton {...buttonProps} isPressed={state.isOpen} />+ </PopoverTrigger>+ </>+ )}+ </HStack>+ <PopoverContent align="end" {...dialogProps}><Calendar {...calendarProps} />- </Popover>- )}- </div>+ <PopoverFooter>+ <Button onClick={() => state.setValue(null)} variant="secondary">+ Clear+ </Button>+ </PopoverFooter>+ </PopoverContent>+ </div>+ </Popover>);};diff --git a/packages/react/src/IconButton.tsx b/packages/react/src/IconButton.tsxindex b165cb3b39..61e1eff1a5 100644--- a/packages/react/src/IconButton.tsx+++ b/packages/react/src/IconButton.tsx@@ -11,8 +11,17 @@ export interface IconButtonPropsisRound?: boolean;}+const iconSizes = {+ sm: "w-4 h-4",+ md: "w-5 h-5",+ lg: "w-6 h-6",+} as const;+const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(- ({ icon, "aria-label": ariaLabel, isRound, children, ...props }, ref) => {+ (+ { icon, "aria-label": ariaLabel, isRound, children, size = "md", ...props },+ ref+ ) => {/*** Passing the icon as prop or children should work*/@@ -21,7 +30,7 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(? cloneElement(element as any, {"aria-hidden": true,focusable: false,- className: "w-5 h-5",+ className: iconSizes[size],}): null;@@ -31,6 +40,7 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(ref={ref}isIconisRound={isRound}+ size={size}{...props}>{_children}