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
refactor: select component - part 5
Brad Barbinb3b3e3c7e4e2
diff --git a/apps/carbon/README.md b/apps/carbon/README.mdindex 52580ba9e2..9bf983838e 100644--- a/apps/carbon/README.md+++ b/apps/carbon/README.md@@ -3,9 +3,9 @@ERP Application built with:- [Remix](https://remix.run)-- [Chakra UI](https://chakra-ui.com/)- [Supabase](https://supabase.com/)- [Postgres](https://postgresql.org/)+- [shadcn](https://ui.shadcn.com/)- [Redis](https://redis.io)- [BullMQ](https://docs.bullmq.io)diff --git a/apps/carbon/app/components/CreateableCombobox.tsx b/apps/carbon/app/components/CreateableCombobox.tsxnew file mode 100644index 0000000000..dca8fa0678--- /dev/null+++ b/apps/carbon/app/components/CreateableCombobox.tsx@@ -0,0 +1,134 @@+import {+ Command,+ CommandGroup,+ CommandInput,+ CommandItem,+ CommandTrigger,+ HStack,+ IconButton,+ Popover,+ PopoverContent,+ PopoverTrigger,+ cn,+} from "@carbon/react";+import type { ComponentPropsWithoutRef } from "react";+import { forwardRef, useState } from "react";+import { MdClose } from "react-icons/md";+import { RxCheck } from "react-icons/rx";++export type CreatableComboboxProps = Omit<+ ComponentPropsWithoutRef<"button">,+ "onChange"+> & {+ size?: "sm" | "md" | "lg";+ value?: string;+ options: {+ label: string;+ value: string;+ }[];+ selected?: string[];+ isClearable?: boolean;+ isReadOnly?: boolean;+ placeholder?: string;+ onChange?: (selected: string) => void;+ onCreateOption?: (inputValue: string) => void;+};++const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(+ (+ {+ size,+ value,+ options,+ selected,+ isClearable,+ isReadOnly,+ placeholder,+ onChange,++ ...props+ },+ ref+ ) => {+ const [search, setSearch] = useState("");+ const isExactMatch = options.some(+ (option) => option.value.toLowerCase() === search.toLowerCase()+ );++ return (+ <HStack spacing={1}>+ <Popover>+ <PopoverTrigger asChild>+ <CommandTrigger+ size={size}+ role="combobox"+ className={cn("min-w-[160px]", !value && "text-muted-foreground")}+ ref={ref}+ {...props}+ >+ {value+ ? options.find((option) => option.value === value)?.label+ : placeholder ?? "Select"}+ </CommandTrigger>+ </PopoverTrigger>+ <PopoverContent className="min-w-[200px] w-[--radix-popover-trigger-width] p-0">+ <Command>+ <CommandInput+ value={search}+ onValueChange={setSearch}+ placeholder="Search..."+ className="h-9"+ />+ <CommandGroup>+ {options.map((option) => {+ const isSelected = !!selected?.includes(option.value);+ return (+ <CommandItem+ value={option.label}+ key={option.value}+ onSelect={() => {+ if (!isSelected) onChange?.(option.value);+ }}+ >+ {option.label}+ <RxCheck+ className={cn(+ "ml-auto h-4 w-4",+ isSelected || option.value === value+ ? "opacity-100"+ : "opacity-0"+ )}+ />+ </CommandItem>+ );+ })}+ {!isExactMatch && !!search && (+ <CommandItem+ onSelect={() => {+ props.onCreateOption?.(search);+ }}+ >+ <span>Create</span>+ <span className="ml-1 font-bold">{search}</span>+ </CommandItem>+ )}+ </CommandGroup>+ </Command>+ </PopoverContent>+ </Popover>+ {isClearable && !isReadOnly && value && (+ <IconButton+ variant="ghost"+ aria-label="Clear"+ icon={<MdClose />}+ onClick={() => onChange?.("")}+ size={size === "sm" ? "md" : size}+ />+ )}+ </HStack>+ );+ }+);+CreatableCombobox.displayName = "CreatableCombobox";++export default CreatableCombobox;diff --git a/apps/carbon/app/components/Form/CreatableCombobox.tsx b/apps/carbon/app/components/Form/CreatableCombobox.tsxnew file mode 100644index 0000000000..0ff67578b7--- /dev/null+++ b/apps/carbon/app/components/Form/CreatableCombobox.tsx@@ -0,0 +1,72 @@+import {+ FormControl,+ FormErrorMessage,+ FormHelperText,+ FormLabel,+} from "@carbon/react";++import { useControlField, useField } from "remix-validated-form";+import { CreatableCombobox as CreatableComboboxBase } from "~/components";+import type { CreatableComboboxProps as CreatableComboboxBaseProps } from "~/components/CreateableCombobox";++export type CreatableComboboxProps = Omit<+ CreatableComboboxBaseProps,+ "onChange"+> & {+ name: string;+ label?: string;+ helperText?: string;+ onChange?: (newValue: { value: string; label: string } | null) => void;+};++const CreatableCombobox = ({+ name,+ label,+ helperText,+ ...props+}: CreatableComboboxProps) => {+ const { getInputProps, error } = useField(name);+ const [value, setValue] = useControlField<string | undefined>(name);++ const onChange = (value: string) => {+ if (value) {+ props?.onChange?.(props.options.find((o) => o.value === value) ?? null);+ } else {+ props?.onChange?.(null);+ }+ };++ return (+ <FormControl isInvalid={!!error}>+ {label && <FormLabel htmlFor={name}>{label}</FormLabel>}+ <input+ {...getInputProps({+ id: name,+ })}+ type="hidden"+ name={name}+ id={name}+ value={value}+ />+ <CreatableComboboxBase+ {...props}+ value={value}+ onChange={(newValue) => {+ setValue(newValue ?? "");+ onChange(newValue ?? "");+ }}+ className="w-full"+ />++ {error ? (+ <FormErrorMessage>{error}</FormErrorMessage>+ ) : (+ helperText && <FormHelperText>{helperText}</FormHelperText>+ )}+ </FormControl>+ );+};++CreatableCombobox.displayName = "CreatableCombobox";++export default CreatableCombobox;diff --git a/apps/carbon/app/components/Form/CreatableMultiSelect.tsx b/apps/carbon/app/components/Form/CreatableMultiSelect.tsxdeleted file mode 100644index 46d28d45e1..0000000000--- a/apps/carbon/app/components/Form/CreatableMultiSelect.tsx+++ /dev/null@@ -1,101 +0,0 @@-import {- CreatableSelect,- FormControl,- FormErrorMessage,- FormHelperText,- FormLabel,-} from "@carbon/react";-import { useControlField, useField } from "remix-validated-form";-import type { SelectProps } from "./Select";--export type CreatableMultiSelectProps = Omit<SelectProps, "onChange"> & {- onChange?: (- newValue: { value: string | number; label: string }[] | null- ) => void;- onUsingCreatedChanged?: (usingCreated: boolean) => void;-};--const Select = ({- name,- label,- options,- helperText,- isLoading,- isReadOnly,- placeholder,- onChange,- onUsingCreatedChanged,- ...props-}: CreatableMultiSelectProps) => {- const { error } = useField(name);- const [value, setValue] = useControlField<string[]>(name);-- const handleChange = (- newValue: { value: string | number; label: string }[] | null- ) => {- setValue(newValue?.map((option) => option.value.toString()) ?? []);- onChange?.(newValue);- onUsingCreatedChanged?.(false);- };-- const onCreateOption = (inputValue: string) => {- setValue([...value, inputValue]);- onChange?.(- value.map((value) => ({- value,- label: value,- }))- );- onUsingCreatedChanged?.(true);- };-- const optionsWithCreation = options- .concat(- value.map((value) => ({- value,- label: value,- }))- )- .filter((v, i, a) => a.findIndex((v2) => v2.label === v.label) === i);-- const selectedValues =- optionsWithCreation.filter((option) =>- value.some((v) => option.value === v)- ) ?? [];-- return (- <FormControl isInvalid={!!error}>- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}- {value.map((v, index) => (- <input- key={`${name}[${index}]`}- type="hidden"- name={`${name}[${index}]`}- value={v}- />- ))}- <CreatableSelect- {...props}- value={selectedValues}- isClearable- isLoading={isLoading}- isMulti- options={options}- placeholder={placeholder}- w="full"- onCreateOption={onCreateOption}- // @ts-ignore- onChange={handleChange}- />- {error ? (- <FormErrorMessage>{error}</FormErrorMessage>- ) : (- helperText && <FormHelperText>{helperText}</FormHelperText>- )}- </FormControl>- );-};--Select.displayName = "Select";--export default Select;diff --git a/apps/carbon/app/components/Form/CreatableSelect.tsx b/apps/carbon/app/components/Form/CreatableSelect.tsxdeleted file mode 100644index 2fb2144e8a..0000000000--- a/apps/carbon/app/components/Form/CreatableSelect.tsx+++ /dev/null@@ -1,85 +0,0 @@-import {- CreatableSelect,- FormControl,- FormErrorMessage,- FormHelperText,- FormLabel,-} from "@carbon/react";-import { useControlField, useField } from "remix-validated-form";--import type { SelectProps } from "./Select";--export type CreatableSelectProps = Omit<SelectProps, "onChange"> & {- onChange?: (- newValue: { value: string | number; label: string } | null- ) => void;- onUsingCreatedChanged?: (usingCreated: boolean) => void;-};--const Select = ({- name,- label,- options,- helperText,- isLoading,- isReadOnly,- placeholder,- onChange,- onUsingCreatedChanged,- ...props-}: CreatableSelectProps) => {- const { getInputProps, error } = useField(name);- const [value, setValue] = useControlField<string>(name);-- const handleChange = (- newValue: { value: string | number; label: string } | null- ) => {- setValue(newValue?.value.toString() ?? "");- onChange?.(newValue);- onUsingCreatedChanged?.(false);- };-- const onCreateOption = (inputValue: string) => {- setValue(inputValue);- onChange?.({ value: inputValue, label: inputValue });- onUsingCreatedChanged?.(true);- };-- const optionsWithCreation = options.find((option) => option.value === value)- ? options- : options.concat({ value, label: value });-- const selectedValue = optionsWithCreation.find(- (option) => option.value === value- );-- return (- <FormControl isInvalid={!!error}>- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}- <CreatableSelect- {...getInputProps({- // @ts-ignore- id: name,- })}- {...props}- value={selectedValue}- isClearable- isLoading={isLoading}- options={options}- placeholder={placeholder}- w="full"- onCreateOption={onCreateOption}- onChange={handleChange}- />- {error ? (- <FormErrorMessage>{error}</FormErrorMessage>- ) : (- helperText && <FormHelperText>{helperText}</FormHelperText>- )}- </FormControl>- );-};--Select.displayName = "Select";--export default Select;diff --git a/apps/carbon/app/components/Form/CustomerContact.tsx b/apps/carbon/app/components/Form/CustomerContact.tsxindex 18a5f5ac70..8b4227c69f 100644--- a/apps/carbon/app/components/Form/CustomerContact.tsx+++ b/apps/carbon/app/components/Form/CustomerContact.tsx@@ -14,7 +14,7 @@ type CustomerContactSelectProps = Omit<"options" | "onChange"> & {customer?: string;- onChange?: (customer: CustomerContactType | null) => void;+ onChange?: (customer: CustomerContactType["contact"] | null) => void;};const CustomerContact = (props: CustomerContactSelectProps) => {@@ -46,7 +46,7 @@ const CustomerContact = (props: CustomerContactSelectProps) => {(contact) => contact.id === newValue?.value) ?? null;- props.onChange?.(contact as CustomerContactType | null);+ props.onChange?.(contact?.contact ?? null);};return (diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.tsindex c382036782..4d54824fe3 100644--- a/apps/carbon/app/components/Form/index.ts+++ b/apps/carbon/app/components/Form/index.ts@@ -7,8 +7,7 @@ import Array from "./Array";import Boolean from "./Boolean";import Color from "./Color";import Combobox from "./Combobox";-import CreatableMultiSelect from "./CreatableMultiSelect";-import CreatableSelect from "./CreatableSelect";+import CreatableCombobox from "./CreatableCombobox";import Currency from "./Currency";import Customer from "./Customer";import CustomerContact from "./CustomerContact";@@ -53,8 +52,7 @@ export {Boolean,Color,Combobox,- CreatableMultiSelect,- CreatableSelect,+ CreatableCombobox,Currency,Customer,CustomerContact,diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.tsindex 86a49aa92a..eb56862b9a 100644--- a/apps/carbon/app/components/index.ts+++ b/apps/carbon/app/components/index.ts@@ -2,7 +2,8 @@ import Address from "./Address";import Avatar from "./Avatar";import Combobox from "./Combobox";import Contact from "./Contact";+import CreatableCombobox from "./CreateableCombobox";import Select from "./Select";import Table from "./Table";-export { Address, Avatar, Combobox, Contact, Select, Table };+export { Address, Avatar, Combobox, Contact, CreatableCombobox, Select, Table };diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/DocumentsTable.tsxindex cb8f311cd2..fc1c595257 100644--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/DocumentsTable.tsx+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/DocumentsTable.tsx@@ -1,5 +1,4 @@import {- CreatableSelect,HStack,HoverCard,HoverCardContent,@@ -19,12 +18,13 @@ import {TagLabel,Text,} from "@chakra-ui/react";+import { useRevalidator } from "@remix-run/react";import type { ColumnDef } from "@tanstack/react-table";import { memo, useCallback, useEffect, useMemo, useState } from "react";import { BsPencilSquare, BsStar, BsStarFill } from "react-icons/bs";import { IoMdAdd, IoMdTrash } from "react-icons/io";import { VscOpenPreview } from "react-icons/vsc";-import { Avatar, Table } from "~/components";+import { Avatar, CreatableCombobox, Table } from "~/components";import { Confirm, ConfirmDelete } from "~/components/Modals";import { useUrlParams } from "~/hooks";import type { Document, DocumentLabel } from "~/modules/documents";@@ -39,6 +39,8 @@ type DocumentsTableProps = {};const DocumentsTable = memo(({ data, count, labels }: DocumentsTableProps) => {+ console.log(labels);+ const revalidator = useRevalidator();const [params] = useUrlParams();const filter = params.get("q");// put rows in state for use with optimistic ui updates@@ -215,22 +217,19 @@ const DocumentsTable = memo(({ data, count, labels }: DocumentsTableProps) => {</Tag></PopoverTrigger><PopoverContent className="w-[300px] p-0">- <CreatableSelect- defaultValue={- row.original.labels.map((label) => ({- value: label,- label: label,- })) ?? []- }- isClearable- isMulti+ <CreatableComboboxoptions={labelOptions}- onChange={(newValues) =>- onLabel(- row.original,- newValues.map((v) => v.value)- )+ selected={row.original.labels}+ onChange={(newValue) =>+ onLabel(row.original, [...row.original.labels, newValue])}+ onCreateOption={async (newValue) => {+ await onLabel(row.original, [+ ...row.original.labels,+ newValue,+ ]);+ revalidator.revalidate();+ }}/></PopoverContent></Popover>@@ -288,6 +287,7 @@ const DocumentsTable = memo(({ data, count, labels }: DocumentsTableProps) => {onDeleteLabel,onFavorite,onLabel,+ revalidator,setLabel,]);diff --git a/apps/carbon/app/modules/parts/parts.models.ts b/apps/carbon/app/modules/parts/parts.models.tsindex 0d7049263a..ed9b231874 100644--- a/apps/carbon/app/modules/parts/parts.models.ts+++ b/apps/carbon/app/modules/parts/parts.models.ts@@ -79,7 +79,6 @@ export const partInventoryValidator = withZod(partId: z.string().min(1, { message: "Part ID is required" }),locationId: z.string().min(20, { message: "Location is required" }),defaultShelfId: zfd.text(z.string().optional()),- hasNewShelf: z.enum(["true", "false"]),}));diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.tsindex b08e23528c..fbd9d77ed7 100644--- a/apps/carbon/app/modules/parts/parts.service.ts+++ b/apps/carbon/app/modules/parts/parts.service.ts@@ -400,7 +400,7 @@ export async function upsertPartInventory(locationId: string;createdBy: string;}- | (Omit<TypeOfValidator<typeof partInventoryValidator>, "hasNewShelf"> & {+ | (TypeOfValidator<typeof partInventoryValidator> & {updatedBy: string;})) {diff --git a/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/PartInventoryForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/PartInventoryForm.tsxindex 990b80d9b7..ad958b64f5 100644--- a/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/PartInventoryForm.tsx+++ b/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/PartInventoryForm.tsx@@ -9,11 +9,12 @@ import {VStack,} from "@carbon/react";import { Grid } from "@chakra-ui/react";-import { useState } from "react";+import { useRevalidator } from "@remix-run/react";import { ValidatedForm } from "remix-validated-form";import { Combobox } from "~/components";-import { CreatableSelect, Hidden, Number, Submit } from "~/components/Form";-import { usePermissions } from "~/hooks";+import { CreatableCombobox, Hidden, Number, Submit } from "~/components/Form";+import { usePermissions, useUser } from "~/hooks";+import { useSupabase } from "~/lib/supabase";import type { PartQuantities } from "~/modules/parts";import { partInventoryValidator } from "~/modules/parts";import type { ListItem } from "~/types";@@ -21,10 +22,7 @@ import type { TypeOfValidator } from "~/types/validators";import { path } from "~/utils/path";type PartInventoryFormProps = {- initialValues: Omit<- TypeOfValidator<typeof partInventoryValidator>,- "hasNewShelf"- >;+ initialValues: TypeOfValidator<typeof partInventoryValidator>;quantities: PartQuantities;locations: ListItem[];shelves: string[];@@ -37,7 +35,10 @@ const PartInventoryForm = ({shelves,}: PartInventoryFormProps) => {const permissions = usePermissions();- const [hasNewShelf, setHasNewShelf] = useState(false);+ const { supabase } = useSupabase();+ const user = useUser();+ const revalidator = useRevalidator();+const shelfOptions = shelves.map((shelf) => ({ value: shelf, label: shelf }));const locationOptions = locations.map((location) => ({label: location.name,@@ -74,7 +75,7 @@ const PartInventoryForm = ({<CardContent><Hidden name="partId" /><Hidden name="locationId" />- <Hidden name="hasNewShelf" value={hasNewShelf.toString()} />+<GridgridTemplateColumns={["1fr", "1fr", "1fr 1fr 1fr"]}gridColumnGap={8}@@ -82,14 +83,22 @@ const PartInventoryForm = ({w="full"><VStack>- <CreatableSelect- options={shelfOptions}+ <CreatableComboboxname="defaultShelfId"label="Default Shelf"- onUsingCreatedChanged={setHasNewShelf}- // @ts-ignore- w="full"+ options={shelfOptions}+ onCreateOption={async (option) => {+ const response = await supabase?.from("shelf").insert({+ id: option,+ locationId: initialValues.locationId,+ createdBy: user.id,+ });+ if (response && response.error === null)+ revalidator.revalidate();+ }}+ className="w-full"/>+<Numbername="quantityOnHand"label="Quantity On Hand"diff --git a/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/CreateCustomerModal.tsx b/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/CreateCustomerModal.tsxindex 5a8bda41b9..a6927eb036 100644--- a/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/CreateCustomerModal.tsx+++ b/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/CreateCustomerModal.tsx@@ -11,13 +11,13 @@ import {ModalHeader,ModalOverlay,ModalTitle,- ReactSelect,VStack,} from "@carbon/react";import { Grid } from "@chakra-ui/react";import { useFetcher, useNavigate } from "@remix-run/react";import { useEffect, useMemo, useRef, useState } from "react";import { ValidatedForm, useControlField, useField } from "remix-validated-form";+import { Combobox } from "~/components";import { Customer, Submit } from "~/components/Form";import { useUrlParams } from "~/hooks";import type {@@ -156,16 +156,10 @@ const CustomerContact = ({[customerContactFetcher.data]);- const handleChange = (- selection: {- value: string | number;- label: string;- } | null- ) => {- const newValue = selection === null ? null : (selection.value as string);- setValue(newValue);+ const handleChange = (newValue: string) => {+ setValue(newValue ?? "");if (onChange && typeof onChange === "function") {- if (newValue === null) onChange(newValue);+ if (!newValue) onChange(null);const contact = customerContactFetcher.data?.data?.find((c) => c.id === newValue);@@ -174,31 +168,24 @@ const CustomerContact = ({}};- const controlledValue = useMemo(- // @ts-ignore- () => options.find((option) => option.value === value),- [value, options]- );-// so that we can call onChange on loaduseEffect(() => {- if (controlledValue && controlledValue.value === defaultValue) {- handleChange(controlledValue);+ if (value && value === defaultValue) {+ handleChange(value);}// eslint-disable-next-line react-hooks/exhaustive-deps- }, [controlledValue?.value]);+ }, [value, customerContactFetcher.data?.data]);return (<FormControl isInvalid={!!error}><FormLabel htmlFor={name}>Customer Contact</FormLabel><input type="hidden" name={name} id={name} value={value ?? ""} />- <ReactSelect+ <Comboboxid={name}- value={controlledValue}+ value={value ?? undefined}options={options}onChange={handleChange}- isClearable- w="full"+ className="w-full"/>{error && <FormErrorMessage>{error}</FormErrorMessage>}</FormControl>diff --git a/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx b/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsxindex c144648a3e..5ec8593c14 100644--- a/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx+++ b/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx@@ -10,13 +10,13 @@ import {ModalFooter,ModalHeader,ModalTitle,- ReactSelect,VStack,} from "@carbon/react";import { Grid } from "@chakra-ui/react";import { useFetcher, useNavigate } from "@remix-run/react";import { useEffect, useMemo, useRef, useState } from "react";import { ValidatedForm, useControlField, useField } from "remix-validated-form";+import { Combobox } from "~/components";import { Submit, Supplier } from "~/components/Form";import { useUrlParams } from "~/hooks";import type {@@ -153,16 +153,10 @@ const SupplierContact = ({[supplierContactFetcher.data]);- const handleChange = (- selection: {- value: string | number;- label: string;- } | null- ) => {- const newValue = selection === null ? null : (selection.value as string);- setValue(newValue);+ const handleChange = (newValue: string) => {+ setValue(newValue ?? "");if (onChange && typeof onChange === "function") {- if (newValue === null) onChange(newValue);+ if (!newValue) onChange(null);const contact = supplierContactFetcher.data?.data?.find((c) => c.id === newValue);@@ -171,31 +165,24 @@ const SupplierContact = ({}};- const controlledValue = useMemo(- // @ts-ignore- () => options.find((option) => option.value === value),- [value, options]- );-// so that we can call onChange on loaduseEffect(() => {- if (controlledValue && controlledValue.value === defaultValue) {- handleChange(controlledValue);+ if (value && value === defaultValue) {+ handleChange(value);}// eslint-disable-next-line react-hooks/exhaustive-deps- }, [controlledValue?.value]);+ }, [value, supplierContactFetcher.data?.data]);return (<FormControl isInvalid={!!error}><FormLabel htmlFor={name}>Supplier Contact</FormLabel><input type="hidden" name={name} id={name} value={value ?? ""} />- <ReactSelect+ <Comboboxid={name}- value={controlledValue}+ value={value ?? undefined}options={options}onChange={handleChange}- isClearable- w="full"+ className="w-full"/>{error && <FormErrorMessage>{error}</FormErrorMessage>}</FormControl>diff --git a/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx b/apps/carbon/app/routes/x+/part+/$partId.inventory.tsxindex 703500d249..2ee68df1bf 100644--- a/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx+++ b/apps/carbon/app/routes/x+/part+/$partId.inventory.tsx@@ -8,7 +8,6 @@ import {getPartInventory,getPartQuantities,getShelvesList,- insertShelf,partInventoryValidator,upsertPartInventory,} from "~/modules/parts";@@ -136,25 +135,7 @@ export async function action({ request, params }: ActionFunctionArgs) {return validationError(validation.error);}- const { hasNewShelf, ...update } = validation.data;-- if (hasNewShelf === "true" && update.defaultShelfId) {- const createShelf = await insertShelf(- client,- update.defaultShelfId,- update.locationId,- userId- );- if (createShelf.error) {- return redirect(- path.to.partInventory(partId),- await flash(- request,- error(createShelf.error, "Failed to create new shelf")- )- );- }- }+ const { ...update } = validation.data;const updatePartInventory = await upsertPartInventory(client, {...update,diff --git a/www/pages/develop/tech-stack.mdx b/www/pages/develop/tech-stack.mdxindex d086389b78..43ce4ce2e1 100644--- a/www/pages/develop/tech-stack.mdx+++ b/www/pages/develop/tech-stack.mdx@@ -1,6 +1,6 @@---title: Carbon ERP Tech Stack-description: TypeScript, React, Chakra UI, Remix, Supabase+description: TypeScript, React, shadcn, Remix, Supabase---# Tech Stack@@ -11,7 +11,7 @@ Our tech stack aims to be as simple as possible, while still being powerful enou- [React](https://reactjs.org) for the frontend- [Remix](https://remix.run) for the routing and compiling- [Supabase](https://supabase.io) for the database and authentication-- [Chakra UI](https://chakra-ui.com) for the UI components+- [shadcn](https://ui.shadcn.com) (Tailwind, Radix, cva) for the UI componentsWe also use [Redis](https://redis.io) for caching and queues and [Vercel](https://vercel.com) for hosting, though in most cases you probably won't interact with those.@@ -133,24 +133,20 @@ But unlike a raw SQL query, the data that we get back is strongly-typed, neatly-{/* TODO: explain why this is actually a bad setup for joins -- recommend putting joins in SQL VIEWs and then using the supabase client to supabase.from("view").select("*") */}-## Chakra UI+## shadcn-[Chakra UI](https://chakra-ui.com) is a flexible component library that gives us accessibility, full-control, and simplicty. It implements the WAI-ARIA spec behaviors with some basic primitive components (like Button and Modal) while providing an easy-to-modify API for customizing the design.+[shadcn](https://ui.shadcn.com) is an open source starting point for a component library that combines [Radix UI](https://radix-ui.com) with [Tailwind](https://tailwindcss.com) to provide beautiful, accessibile primitives for our `@carbon/react` component package. While the underlying implementation details are [a little complex](https://cva.style/docs/getting-started/variants), the developer experience is extremely simple.-While it's not the most performant choice, it provides an easy-to-use developer experience that should allow contributors to quickly build out new features without an expertise in CSS.--Here's an example of a Chakra UI button:+Here's an example of a button:```jsx-import { Button } from "@chakra-ui/react";+import { Button } from "@carbon/react";function App() {return (- <Button size="lg" variant="outline">+ <Button size="lg" variant="secondary">Click me</Button>);}```--There are a lot of other component libraries out there, but we chose Chakra UI because it gives us a lot of flexibility while providing great user and developer experience. We're hopeful that Chakra will implement Panda under the hood in v4, which will give us high-level performance. If we had time, we'd probably move everything over to Radix + Tailwind (assuming we could keep things super simple for the developer).