Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
style: avatar menu and max-w on layouts with no sidebar/table
Brad Barbin8aab3aa48dd1
diff --git a/apps/carbon/app/components/AvatarMenu.tsx b/apps/carbon/app/components/AvatarMenu.tsxnew file mode 100644index 0000000000..2584928ed3--- /dev/null+++ b/apps/carbon/app/components/AvatarMenu.tsx@@ -0,0 +1,166 @@+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuIcon,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+ DropdownMenuTrigger,+ Switch,+} from "@carbon/react";+import { themes } from "@carbon/utils";+import { Form, Link, useFetcher } from "@remix-run/react";+import { useRef, useState } from "react";+import { BsHexagon } from "react-icons/bs";+import {+ LuFileText,+ LuLogOut,+ LuMoon,+ LuPalette,+ LuSun,+ LuUser,+} from "react-icons/lu";+import { Avatar } from "~/components";+import { useUser } from "~/hooks";+import { useMode } from "~/hooks/useMode";+import { useTheme } from "~/hooks/useTheme";+import type { action } from "~/root";+import { path } from "~/utils/path";++const AvatarMenu = () => {+ const user = useUser();+ const name = `${user.firstName} ${user.lastName}`;++ const mode = useMode();+ const theme = useTheme();++ const nextMode = mode === "dark" ? "light" : "dark";+ const modeSubmitRef = useRef<HTMLButtonElement>(null);++ const fetcher = useFetcher<typeof action>();+ const [isOpen, setIsOpen] = useState(false);++ const onThemeChange = (t: string) => {+ const newTheme = themes.find((theme) => theme.name === t);+ if (!newTheme) return;+ const variables =+ mode === "dark" ? newTheme.cssVars.dark : newTheme.cssVars.light;++ const formData = new FormData();+ formData.append("theme", t);+ fetcher.submit(formData, { method: "post", action: path.to.theme });++ Object.entries(variables).forEach(([key, value]) => {+ document.body.style.setProperty(`--${key}`, value);+ });+ };++ const optimisticTheme =+ (fetcher?.formData?.get("theme") as string | null) ?? theme;++ return (+ <DropdownMenu open={isOpen} onOpenChange={setIsOpen}>+ <DropdownMenuTrigger className="outline-none focus-visible:outline-none">+ <Avatar path={user.avatarUrl} name={name} />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-56">+ <DropdownMenuLabel>Signed in as {name}</DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuItem asChild>+ <Link to={path.to.authenticatedRoot}>+ <DropdownMenuIcon icon={<BsHexagon />} />+ Dashboard+ </Link>+ </DropdownMenuItem>+ <DropdownMenuItem asChild>+ <Link to={path.to.profile}>+ <DropdownMenuIcon icon={<LuUser />} />+ Account Settings+ </Link>+ </DropdownMenuItem>+ <DropdownMenuItem asChild>+ <Link to={path.to.apiIntroduction}>+ <DropdownMenuIcon icon={<LuFileText />} />+ API Documentation+ </Link>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem onSelect={(e) => e.preventDefault()}>+ <div className="flex items-center justify-between w-full">+ <div className="flex items-center justify-start">+ <DropdownMenuIcon+ icon={mode === "dark" ? <LuMoon /> : <LuSun />}+ />+ Dark Mode+ </div>+ <div>+ <Switch+ checked={mode === "dark"}+ onCheckedChange={() => modeSubmitRef.current?.click()}+ />+ <fetcher.Form+ action={path.to.root}+ method="post"+ onSubmit={() => {+ document.body.removeAttribute("style");+ }}+ className="sr-only"+ >+ <input type="hidden" name="mode" value={nextMode} />+ <button ref={modeSubmitRef} className="sr-only" type="submit" />+ </fetcher.Form>+ </div>+ </div>+ </DropdownMenuItem>+ <DropdownMenuSub>+ <DropdownMenuSubTrigger>+ <DropdownMenuIcon icon={<LuPalette />} />+ Theme Color+ </DropdownMenuSubTrigger>+ <DropdownMenuSubContent>+ <DropdownMenuRadioGroup+ value={optimisticTheme}+ onValueChange={onThemeChange}+ >+ {themes.map((t) => (+ <DropdownMenuRadioItem+ key={t.name}+ value={t.name}+ onSelect={(e) => e.preventDefault()}+ style={+ {+ "--theme-primary": `hsl(${+ t?.activeColor[mode === "dark" ? "dark" : "light"]+ })`,+ } as React.CSSProperties+ }+ >+ <div className="flex items-center">+ <div className="w-4 h-4 rounded-full mr-2 bg-[--theme-primary]" />+ {t.label}+ </div>+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuRadioGroup>+ </DropdownMenuSubContent>+ </DropdownMenuSub>+ <DropdownMenuSeparator />+ <DropdownMenuItem onSelect={(e) => e.preventDefault()}>+ <Form method="post" action={path.to.logout}>+ <button type="submit" className="w-full flex items-center">+ <DropdownMenuIcon icon={<LuLogOut />} />+ <span>Sign Out</span>+ </button>+ </Form>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ );+};++export default AvatarMenu;diff --git a/apps/carbon/app/components/Hyperlink.tsx b/apps/carbon/app/components/Hyperlink.tsxindex 9d236f7e62..331de7722a 100644--- a/apps/carbon/app/components/Hyperlink.tsx+++ b/apps/carbon/app/components/Hyperlink.tsx@@ -14,7 +14,7 @@ const Hyperlink = ({<Linkprefetch="intent"className={cn(- "text-foreground hover:underline cursor-pointer font-semibold",+ "text-foreground hover:underline cursor-pointer font-medium",className)}{...props}diff --git a/apps/carbon/app/components/Layout/Navigation/DetailSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/DetailSidebar.tsxindex 303a587beb..47893ad480 100644--- a/apps/carbon/app/components/Layout/Navigation/DetailSidebar.tsx+++ b/apps/carbon/app/components/Layout/Navigation/DetailSidebar.tsx@@ -10,14 +10,14 @@ import {} from "@carbon/react";import { prettifyKeyboardShortcut } from "@carbon/utils";import { Link, useNavigate } from "@remix-run/react";-import type { IconType } from "react-icons";+import type { ReactNode } from "react";import { useOptimisticLocation } from "~/hooks";type DetailSidebarProps = {links: {name: string;to: string;- icon?: IconType;+ icon?: ReactNode;count?: number;shortcut?: string;}[];@@ -49,8 +49,12 @@ const DetailSidebar = ({ links }: DetailSidebarProps) => {variant={isActive ? "active" : "ghost"}className="w-full justify-start">- <Link to={route.to} prefetch="intent">- {route.icon && <route.icon className="mr-2" />}+ <Link+ to={route.to}+ prefetch="intent"+ className="flex items-center justify-start gap-2"+ >+ {route.icon}<span>{route.name}</span>{route.count !== undefined && (<Count count={route.count} className="ml-auto" />diff --git a/apps/carbon/app/components/Layout/Navigation/PrimaryNavigation.tsx b/apps/carbon/app/components/Layout/Navigation/PrimaryNavigation.tsxindex 9befc2b3ec..a938b7f955 100644--- a/apps/carbon/app/components/Layout/Navigation/PrimaryNavigation.tsx+++ b/apps/carbon/app/components/Layout/Navigation/PrimaryNavigation.tsx@@ -42,7 +42,10 @@ const PrimaryNavigation = () => {onMouseEnter={navigationPanel.onOpen}onMouseLeave={navigationPanel.onClose}>- <VStack spacing={1} className="flex flex-col justify-start h-full px-2">+ <VStack+ spacing={1}+ className="flex flex-col justify-between h-full px-2"+ ><VStack spacing={1}><Button isIcon asChild variant="ghost" size="lg"><Link to="/">diff --git a/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsx b/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsxdeleted file mode 100644index d2bb8c2b34..0000000000--- a/apps/carbon/app/components/Layout/Topbar/AvatarMenu.tsx+++ /dev/null@@ -1,47 +0,0 @@-import {- DropdownMenu,- DropdownMenuContent,- DropdownMenuIcon,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuSeparator,- DropdownMenuTrigger,-} from "@carbon/react";-import { Form, Link } from "@remix-run/react";-import { LuLogOut, LuUserCircle } from "react-icons/lu";-import { Avatar } from "~/components";-import { useUser } from "~/hooks";-import { path } from "~/utils/path";--const AvatarMenu = () => {- const user = useUser();- const name = `${user.firstName} ${user.lastName}`;-- return (- <DropdownMenu>- <DropdownMenuTrigger className="outline-none focus-visible:outline-none">- <Avatar path={user.avatarUrl} name={name} />- </DropdownMenuTrigger>- <DropdownMenuContent align="end" className="w-56">- <DropdownMenuLabel>Signed in as {name}</DropdownMenuLabel>- <DropdownMenuSeparator />- <DropdownMenuItem asChild>- <Link to={path.to.profile}>- <DropdownMenuIcon icon={<LuUserCircle />} />- My Profile- </Link>- </DropdownMenuItem>- <Form method="post" action={path.to.logout}>- <DropdownMenuItem asChild>- <button type="submit" className="w-full">- <DropdownMenuIcon icon={<LuLogOut />} />- <span>Sign Out</span>- </button>- </DropdownMenuItem>- </Form>- </DropdownMenuContent>- </DropdownMenu>- );-};--export default AvatarMenu;diff --git a/apps/carbon/app/components/Layout/Topbar/CreateMenu.tsx b/apps/carbon/app/components/Layout/Topbar/CreateMenu.tsxindex c2947aab9c..fe7bf2e547 100644--- a/apps/carbon/app/components/Layout/Topbar/CreateMenu.tsx+++ b/apps/carbon/app/components/Layout/Topbar/CreateMenu.tsx@@ -7,8 +7,101 @@ import {IconButton,} from "@carbon/react";import { Link } from "@remix-run/react";-import useCreate from "./useCreate";-import { LuPlus } from "react-icons/lu";++import {+ LuComponent,+ LuContainer,+ LuHardHat,+ LuPlus,+ LuShoppingCart,+ LuUserSquare,+ LuUsers,+} from "react-icons/lu";++import { useMemo } from "react";+import {+ RiProgress2Line,+ RiProgress4Line,+ RiProgress8Line,+} from "react-icons/ri";+import { usePermissions } from "~/hooks";++import type { Route } from "~/types";+import { path } from "~/utils/path";++function useCreate(): Route[] {+ const permissions = usePermissions();++ const result = useMemo(() => {+ let links: Route[] = [];+ if (permissions.can("create", "parts")) {+ links.push({+ name: "Part",+ to: path.to.newPart,+ icon: <LuComponent />,+ });+ }++ if (permissions.can("create", "production")) {+ links.push({+ name: "Job",+ to: path.to.newJob,+ icon: <LuHardHat />,+ });+ }++ if (permissions.can("create", "purchasing")) {+ links.push({+ name: "Purchase Order",+ to: path.to.newPurchaseOrder,+ icon: <LuShoppingCart />,+ });+ }++ if (permissions.can("create", "purchasing")) {+ links.push({+ name: "Supplier",+ to: path.to.newSupplier,+ icon: <LuContainer />,+ });+ }++ if (permissions.can("create", "sales")) {+ links.push({+ name: "Customer",+ to: path.to.newCustomer,+ icon: <LuUserSquare />,+ });+ links.push({+ name: "RFQ",+ to: path.to.newSalesRFQ,+ icon: <RiProgress2Line />,+ });+ links.push({+ name: "Quote",+ to: path.to.newQuote,+ icon: <RiProgress4Line />,+ });+ links.push({+ name: "Sales Order",+ to: path.to.newSalesOrder,+ icon: <RiProgress8Line />,+ });+ }++ if (permissions.can("create", "users")) {+ links.push({+ name: "Employee",+ to: path.to.newEmployee,+ icon: <LuUsers />,+ });+ }++ return links;+ }, [permissions]);++ return result.sort((a, b) => a.name.localeCompare(b.name));+}const CreateMenu = () => {const createLinks = useCreate();diff --git a/apps/carbon/app/components/Layout/Topbar/Topbar.tsx b/apps/carbon/app/components/Layout/Topbar/Topbar.tsxindex 586fcb40e3..e8ba6a78d7 100644--- a/apps/carbon/app/components/Layout/Topbar/Topbar.tsx+++ b/apps/carbon/app/components/Layout/Topbar/Topbar.tsx@@ -1,10 +1,8 @@import { HStack } from "@carbon/react";import { usePermissions } from "~/hooks";-import AvatarMenu from "./AvatarMenu";+import AvatarMenu from "../../AvatarMenu";import Breadcrumbs from "./Breadcrumbs";import CreateMenu from "./CreateMenu";-import HelpMenu from "./HelpMenu";-import ModeSwitcher from "./ModeSwitcher";import Search from "./Search";const Topbar = () => {@@ -16,8 +14,6 @@ const Topbar = () => {<HStack spacing={2} className="justify-end py-2">{permissions.is("employee") ? <Search /> : <div />}<CreateMenu />- <HelpMenu />- <ModeSwitcher /><AvatarMenu /></HStack></div>diff --git a/apps/carbon/app/components/Layout/Topbar/index.ts b/apps/carbon/app/components/Layout/Topbar/index.tsindex 65efcbb275..a2e3826434 100644--- a/apps/carbon/app/components/Layout/Topbar/index.ts+++ b/apps/carbon/app/components/Layout/Topbar/index.ts@@ -1,5 +1,3 @@-import AvatarMenu from "./AvatarMenu";import Topbar from "./Topbar";export default Topbar;-export { AvatarMenu };diff --git a/apps/carbon/app/components/Layout/Topbar/useCreate.tsx b/apps/carbon/app/components/Layout/Topbar/useCreate.tsxdeleted file mode 100644index 8c4bc4593e..0000000000--- a/apps/carbon/app/components/Layout/Topbar/useCreate.tsx+++ /dev/null@@ -1,92 +0,0 @@-import { useMemo } from "react";-import {- LuComponent,- LuContainer,- LuHardHat,- LuShoppingCart,- LuUserSquare,- LuUsers,-} from "react-icons/lu";-import {- RiProgress2Line,- RiProgress4Line,- RiProgress8Line,-} from "react-icons/ri";-import { usePermissions } from "~/hooks";--import type { Route } from "~/types";-import { path } from "~/utils/path";--export default function useCreate(): Route[] {- const permissions = usePermissions();-- const result = useMemo(() => {- let links: Route[] = [];- if (permissions.can("create", "parts")) {- links.push({- name: "Part",- to: path.to.newPart,- icon: <LuComponent />,- });- }-- if (permissions.can("create", "production")) {- links.push({- name: "Job",- to: path.to.newJob,- icon: <LuHardHat />,- });- }-- if (permissions.can("create", "purchasing")) {- links.push({- name: "Purchase Order",- to: path.to.newPurchaseOrder,- icon: <LuShoppingCart />,- });- }-- if (permissions.can("create", "purchasing")) {- links.push({- name: "Supplier",- to: path.to.newSupplier,- icon: <LuContainer />,- });- }-- if (permissions.can("create", "sales")) {- links.push({- name: "Customer",- to: path.to.newCustomer,- icon: <LuUserSquare />,- });- links.push({- name: "RFQ",- to: path.to.newSalesRFQ,- icon: <RiProgress2Line />,- });- links.push({- name: "Quote",- to: path.to.newQuote,- icon: <RiProgress4Line />,- });- links.push({- name: "Sales Order",- to: path.to.newSalesOrder,- icon: <RiProgress8Line />,- });- }-- if (permissions.can("create", "users")) {- links.push({- name: "Employee",- to: path.to.newEmployee,- icon: <LuUsers />,- });- }-- return links;- }, [permissions]);-- return result.sort((a, b) => a.name.localeCompare(b.name));-}diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.tsindex a27523f241..448090ebd4 100644--- a/apps/carbon/app/components/index.ts+++ b/apps/carbon/app/components/index.ts@@ -1,5 +1,6 @@import Assignee, { useOptimisticAssignment } from "./Assignee";import Avatar from "./Avatar";+import AvatarMenu from "./AvatarMenu";import { BreadcrumbItem, BreadcrumbLink, Breadcrumbs } from "./Breadcrumb";import CadModel from "./CadModel";import Contact from "./Contact";@@ -34,6 +35,7 @@ import Table from "./Table";export {Assignee,Avatar,+ AvatarMenu,BreadcrumbItem,BreadcrumbLink,Breadcrumbs,diff --git a/apps/carbon/app/hooks/useTheme.tsx b/apps/carbon/app/hooks/useTheme.tsxnew file mode 100644index 0000000000..f639b27655--- /dev/null+++ b/apps/carbon/app/hooks/useTheme.tsx@@ -0,0 +1,32 @@+import { useFetchers } from "@remix-run/react";++import { themeValidator } from "~/modules/settings";+import { path } from "~/utils/path";+import { useRouteData } from "./useRouteData";++export function useOptimisticTheme() {+ const fetchers = useFetchers();+ const themeFetcher = fetchers.find((f) => f.formAction === "/");++ if (themeFetcher && themeFetcher.formData) {+ const theme = { theme: themeFetcher.formData.get("theme") };+ const submission = themeValidator.safeParse(theme);++ if (submission.success) {+ return submission.data.theme;+ }+ }+}++export function useTheme() {+ const optimisticTheme = useOptimisticTheme();+ const routeData = useRouteData<{ theme: string }>(path.to.root);++ let theme = routeData?.theme ?? "carbon";++ if (optimisticTheme) {+ theme = optimisticTheme;+ }++ return theme;+}diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsxindex 81d07fb7a8..6a4c61e1d6 100644--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx@@ -6,13 +6,11 @@ import {CommandInput,CommandItem,HStack,- Heading,MenuIcon,MenuItem,Popover,PopoverContent,PopoverTrigger,- VStack,cn,useDisclosure,} from "@carbon/react";@@ -33,7 +31,6 @@ import { RxCheck } from "react-icons/rx";import { EmployeeAvatar, Hyperlink, Table } from "~/components";import { Enumerable } from "~/components/Enumerable";import { Confirm, ConfirmDelete } from "~/components/Modals";-import { useFilters } from "~/components/Table/components/Filter/useFilters";import { usePermissions, useUrlParams } from "~/hooks";import type { Document, DocumentLabel } from "~/modules/documents";import {@@ -59,7 +56,7 @@ const DocumentsTable = memo(const revalidator = useRevalidator();const [params] = useUrlParams();const filter = params.get("q");- const search = params.get("search");+// put rows in state for use with optimistic ui updatesconst [rows, setRows] = useState<Document[]>(data);// we have to do this useEffect silliness since we're putitng rows@@ -80,8 +77,6 @@ const DocumentsTable = memo(setLabel,} = useDocument();- const { hasFilters } = useFilters();-const [people] = usePeople();const moveDocumentModal = useDisclosure();const deleteDocumentModal = useDisclosure();@@ -478,31 +473,17 @@ const DocumentsTable = memo(return (<>- {count === 0 && !hasFilters && !search ? (- <HStack className="w-full h-screen flex items-start justify-center">- <VStack className="border rounded-md shadow-md w-96 mt-20">- <div className="w-full flex flex-col gap-4 items-center justify-center py-8 bg-gradient-to-bl from-card to-background rounded-lg text-center group ring-4 ring-transparent hover:ring-white/10">- <Heading size="h2">No Files Yet</Heading>- <p className="text-muted-foreground text-base font-light">- Start by uploading your first file- </p>- <DocumentCreateForm />- </div>- </VStack>- </HStack>- ) : (- <Table<Document>- actions={actions}- count={count}- columns={columns}- data={rows}- defaultColumnVisibility={defaultColumnVisibility}- primaryAction={- permissions.can("create", "documents") && <DocumentCreateForm />- }- renderContextMenu={renderContextMenu}- />- )}+ <Table<Document>+ actions={actions}+ count={count}+ columns={columns}+ data={rows}+ defaultColumnVisibility={defaultColumnVisibility}+ primaryAction={+ permissions.can("create", "documents") && <DocumentCreateForm />+ }+ renderContextMenu={renderContextMenu}+ />{selectedDocument && selectedDocument.id && (<>diff --git a/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx b/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsxindex 7ccf252620..431098b8d3 100644--- a/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx+++ b/apps/carbon/app/modules/inventory/ui/Inventory/InventoryTable.tsx@@ -1,11 +1,12 @@-import { Checkbox, Combobox, HStack, Heading, VStack } from "@carbon/react";+import { Button, Checkbox, Combobox, HStack } from "@carbon/react";+import { Link } from "@remix-run/react";import type { ColumnDef } from "@tanstack/react-table";import { memo, useMemo } from "react";+import { LuAlertTriangle, LuPlus } from "react-icons/lu";import {Hyperlink,ItemThumbnail,MethodItemTypeIcon,- New,Table,} from "~/components";import { Enumerable } from "~/components/Enumerable";@@ -203,17 +204,17 @@ const InventoryTable = memo(return (<>{count === 0 && !hasFilters ? (- <HStack className="w-full h-screen flex items-start justify-center">- <VStack className="border rounded-md shadow-md w-96 mt-20">- <div className="w-full flex flex-col gap-4 items-center justify-center py-8 bg-gradient-to-bl from-card to-background rounded-lg text-center group ring-4 ring-transparent hover:ring-white/10">- <Heading size="h2">No Items Yet</Heading>- <p className="text-muted-foreground text-base font-light">- Start by creating your first part- </p>- <New label="Part" to={path.to.newPart} />- </div>- </VStack>- </HStack>+ <div className="flex flex-col w-full h-full items-center justify-center gap-4">+ <div className="flex justify-center items-center h-12 w-12 rounded-full bg-foreground text-background">+ <LuAlertTriangle className="h-6 w-6" />+ </div>+ <span className="text-xs font-mono font-light text-foreground uppercase">+ No inventory items exists+ </span>+ <Button leftIcon={<LuPlus />} asChild>+ <Link to={path.to.newPart}>New Part</Link>+ </Button>+ </div>) : (<><Table<InventoryItem>diff --git a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptSidebar/useReceiptSidebar.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptSidebar/useReceiptSidebar.tsxindex 216f37744f..48afab9805 100644--- a/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptSidebar/useReceiptSidebar.tsx+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptSidebar/useReceiptSidebar.tsx@@ -17,7 +17,7 @@ export function useReceiptSidebar({name: "Details",to: "details",- icon: LuFileText,+ icon: <LuFileText />,shortcut: "Command+Shift+d",},{@@ -25,7 +25,7 @@ export function useReceiptSidebar(to: "lines",role: ["employee"],count: lines.length,- icon: LuList,+ icon: <LuList />,shortcut: "Command+Shift+l",},@@ -34,7 +34,7 @@ export function useReceiptSidebar(to: "notes",role: ["employee"],count: notes.length,- icon: LuStickyNote,+ icon: <LuStickyNote />,shortcut: "Command+Shift+n",},].filter(diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSidebar/usePurchaseInvoiceSidebar.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSidebar/usePurchaseInvoiceSidebar.tsxindex 9630fe968c..999b8bf0b8 100644--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSidebar/usePurchaseInvoiceSidebar.tsx+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceSidebar/usePurchaseInvoiceSidebar.tsx@@ -12,7 +12,7 @@ export function usePurchaseInvoiceSidebar({ lines = 0 }: Props) {{name: "Summary",to: "details",- icon: LuFileText,+ icon: <LuFileText />,shortcut: "Command+Shift+s",role: ["employee"],},@@ -20,7 +20,7 @@ export function usePurchaseInvoiceSidebar({ lines = 0 }: Props) {name: "Lines",to: "lines",count: lines,- icon: LuList,+ icon: <LuList />,shortcut: "Command+Shift+l",role: ["employee"],},@@ -28,7 +28,7 @@ export function usePurchaseInvoiceSidebar({ lines = 0 }: Props) {// name: "Payment",// to: "payment",// role: ["employee"],- // icon: BsCreditCard,+ // icon: <BsCreditCard />,// shortcut: "Command+Shift+p",// },].filter(diff --git a/apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsx b/apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsxindex 6681117e16..b55a729cb1 100644--- a/apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsx+++ b/apps/carbon/app/modules/people/ui/Person/PersonSidebar/usePersonSidebar.tsx@@ -1,23 +1,21 @@-import { BiSolidUserDetail } from "react-icons/bi";-import { CgProfile } from "react-icons/cg";-import { MdNote } from "react-icons/md";+import { LuHardHat, LuStickyNote, LuUser } from "react-icons/lu";export function usePersonSidebar() {return [{name: "Profile",to: "details",- icon: CgProfile,+ icon: <LuUser />,},{name: "Job",to: "job",- icon: BiSolidUserDetail,+ icon: <LuHardHat />,},{name: "Notes",to: "notes",- icon: MdNote,+ icon: <LuStickyNote />,},];}diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsxindex 140ca3e5cc..166950d231 100644--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx@@ -28,28 +28,28 @@ export function usePurchaseOrderSidebar({{name: "Summary",to: path.to.purchaseOrderDetails(orderId),- icon: LuFileText,+ icon: <LuFileText />,shortcut: "Command+Shift+s",},{name: "Lines",to: path.to.purchaseOrderLines(orderId),count: lines,- icon: LuList,+ icon: <LuList />,shortcut: "Command+Shift+l",},{name: "Delivery",to: path.to.purchaseOrderDelivery(orderId),role: ["employee", "supplier"],- icon: BsTruck,+ icon: <BsTruck />,shortcut: "Command+Shift+d",},{name: "Payment",to: path.to.purchaseOrderPayment(orderId),role: ["employee"],- icon: BsCreditCard,+ icon: <BsCreditCard />,shortcut: "Command+Shift+p",},{@@ -57,7 +57,7 @@ export function usePurchaseOrderSidebar({to: path.to.purchaseOrderInternalDocuments(orderId),role: ["employee"],count: internalDocuments,- icon: HiOutlineDocumentArrowDown,+ icon: <HiOutlineDocumentArrowDown />,shortcut: "Command+Shift+i",},{@@ -65,7 +65,7 @@ export function usePurchaseOrderSidebar({to: path.to.purchaseOrderExternalDocuments(orderId),role: ["employee", "supplier"],count: externalDocuments,- icon: HiOutlineDocumentArrowUp,+ icon: <HiOutlineDocumentArrowUp />,shortcut: "Command+Shift+e",},].filter(diff --git a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsxindex 9b9e2c2cc5..2f2ed8e98b 100644--- a/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx+++ b/apps/carbon/app/modules/purchasing/ui/Supplier/SupplierSidebar/useSupplierSidebar.tsx@@ -26,7 +26,7 @@ export function useSupplierSidebar({ contacts, locations }: Props) {{name: "Details",to: path.to.supplierDetails(supplierId),- icon: LuBuilding,+ icon: <LuBuilding />,shortcut: "Command+Shift+d",},{@@ -34,7 +34,7 @@ export function useSupplierSidebar({ contacts, locations }: Props) {to: path.to.supplierContacts(supplierId),role: ["employee"],count: contacts,- icon: LuContact,+ icon: <LuContact />,shortcut: "Command+Shift+c",},{@@ -42,35 +42,35 @@ export function useSupplierSidebar({ contacts, locations }: Props) {to: path.to.supplierLocations(supplierId),role: ["employee", "supplier"],count: locations,- icon: LuMapPin,+ icon: <LuMapPin />,shortcut: "Command+Shift+l",},{name: "Payments",to: path.to.supplierPayment(supplierId),role: ["employee"],- icon: LuCreditCard,+ icon: <LuCreditCard />,shortcut: "Command+Shift+p",},{name: "Processes",to: path.to.supplierProcesses(supplierId),role: ["employee"],- icon: TbRoute,+ icon: <TbRoute />,shortcut: "Command+Shift+r",},{name: "Shipping",to: path.to.supplierShipping(supplierId),role: ["employee"],- icon: LuTruck,+ icon: <LuTruck />,shortcut: "Command+Shift+s",},{name: "Accounting",to: path.to.supplierAccounting(supplierId),role: ["employee"],- icon: LuLandmark,+ icon: <LuLandmark />,shortcut: "Command+Shift+a",},].filter(diff --git a/apps/carbon/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx b/apps/carbon/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsxindex e1441d4443..79ae9519d0 100644--- a/apps/carbon/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx+++ b/apps/carbon/app/modules/sales/ui/Customer/CustomerSidebar/useCustomerSidebar.tsx@@ -24,7 +24,7 @@ export function useCustomerSidebar({ contacts, locations }: Props) {{name: "Details",to: path.to.customerDetails(customerId),- icon: LuBuilding,+ icon: <LuBuilding />,shortcut: "Command+Shift+d",},{@@ -32,7 +32,7 @@ export function useCustomerSidebar({ contacts, locations }: Props) {to: path.to.customerContacts(customerId),role: ["employee"],count: contacts,- icon: LuContact,+ icon: <LuContact />,shortcut: "Command+Shift+c",},{@@ -40,28 +40,28 @@ export function useCustomerSidebar({ contacts, locations }: Props) {to: path.to.customerLocations(customerId),role: ["employee", "customer"],count: locations,- icon: LuMapPin,+ icon: <LuMapPin />,shortcut: "Command+Shift+l",},{name: "Payments",to: path.to.customerPayment(customerId),role: ["employee"],- icon: LuCreditCard,+ icon: <LuCreditCard />,shortcut: "Command+Shift+p",},{name: "Shipping",to: path.to.customerShipping(customerId),role: ["employee"],- icon: LuTruck,+ icon: <LuTruck />,shortcut: "Command+Shift+s",},{name: "Accounting",to: path.to.customerAccounting(customerId),role: ["employee"],- icon: LuLandmark,+ icon: <LuLandmark />,shortcut: "Command+Shift+a",},].filter(diff --git a/apps/carbon/app/modules/settings/ui/Theme/ThemeForm.tsx b/apps/carbon/app/modules/settings/ui/Theme/ThemeForm.tsxindex 4db97efd0d..ba0af4797c 100644--- a/apps/carbon/app/modules/settings/ui/Theme/ThemeForm.tsx+++ b/apps/carbon/app/modules/settings/ui/Theme/ThemeForm.tsx@@ -1,10 +1,8 @@-import { ValidatedForm } from "@carbon/form";import {Button,Card,CardContent,CardDescription,- CardFooter,CardHeader,CardTitle,VStack,@@ -12,13 +10,12 @@ import {} from "@carbon/react";import type { Theme } from "@carbon/utils";import { themes } from "@carbon/utils";-import { useEffect, useState } from "react";+import { useFetcher } from "@remix-run/react";import { RxCheck } from "react-icons/rx";import type { z } from "zod";-import { Hidden, Submit } from "~/components/Form";import { useMode } from "~/hooks/useMode";-import type { Theme as ThemeValue } from "~/modules/settings";-import { themeValidator } from "~/modules/settings";+import type { themeValidator } from "~/modules/settings";+import type { Action } from "~/types";import { path } from "~/utils/path";type ThemeFormProps = {@@ -26,12 +23,10 @@ type ThemeFormProps = {};const ThemeForm = ({ theme: defaultValues }: ThemeFormProps) => {- const [theme, setTheme] = useState<ThemeValue>(defaultValues.theme);const mode = useMode();+ const fetcher = useFetcher<Action>();const onThemeChange = (t: Theme) => {- setTheme(t.name);-const variables = mode === "dark" ? t.cssVars.dark : t.cssVars.light;Object.entries(variables).forEach(([key, value]) => {@@ -39,40 +34,34 @@ const ThemeForm = ({ theme: defaultValues }: ThemeFormProps) => {});};- useEffect(() => {- const t = themes.find((t) => t.name === theme);- if (t) {- onThemeChange(t);- }-- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [mode]);+ const optimisticTheme =+ fetcher?.formData?.get("theme") ?? defaultValues.theme;return (<Card>- <ValidatedForm- method="post"- action={path.to.theme}- validator={themeValidator}- defaultValues={defaultValues}- >- <CardHeader>- <CardTitle>Theme</CardTitle>- <CardDescription>- This updates the theme for all users of the application- </CardDescription>- </CardHeader>- <CardContent>- <VStack spacing={4} className="max-w-[520px]">- <Hidden name="theme" value={theme} />- <div className="grid grid-cols-3 gap-4">- {themes.map((t) => {- const isActive = theme === t.name;- return (+ <CardHeader>+ <CardTitle>Theme</CardTitle>+ <CardDescription>+ This updates the theme for all users of the application+ </CardDescription>+ </CardHeader>+ <CardContent>+ <VStack spacing={4} className="max-w-[520px]">+ <div className="grid grid-cols-3 gap-4">+ {themes.map((t) => {+ const isActive = optimisticTheme === t.name;+ return (+ <fetcher.Form+ key={t.name}+ action={path.to.theme}+ method="post"+ onSubmit={() => onThemeChange(t)}+ >+ <input type="hidden" name="theme" value={t.name} /><Buttonkey={t.name}variant="secondary"- onClick={() => onThemeChange(t)}+ type="submit"className={cn("justify-start",isActive && "border-2 border-primary"@@ -94,15 +83,12 @@ const ThemeForm = ({ theme: defaultValues }: ThemeFormProps) => {</span>{t.label}</Button>- );- })}- </div>- </VStack>- </CardContent>- <CardFooter>- <Submit>Save</Submit>- </CardFooter>- </ValidatedForm>+ </fetcher.Form>+ );+ })}+ </div>+ </VStack>+ </CardContent></Card>);};diff --git a/apps/carbon/app/root.tsx b/apps/carbon/app/root.tsxindex 1f344458f0..8b8a853ad2 100644--- a/apps/carbon/app/root.tsx+++ b/apps/carbon/app/root.tsx@@ -25,6 +25,7 @@ import Background from "~/styles/background.css?url";import NProgress from "~/styles/nprogress.css?url";import Tailwind from "~/styles/tailwind.css?url";import { useMode } from "./hooks/useMode";+import { getTheme } from "./services/theme.server";import { modeValidator } from "./types/validators";// export const config = { runtime: "edge" };@@ -65,6 +66,7 @@ export async function loader({ request }: LoaderFunctionArgs) {SUPABASE_ANON_PUBLIC,},mode: getMode(request),+ theme: getTheme(request),result: sessionFlash?.result,},{diff --git a/apps/carbon/app/routes/x+/account+/_layout.tsx b/apps/carbon/app/routes/x+/account+/_layout.tsxindex b859664414..45c0fb8546 100644--- a/apps/carbon/app/routes/x+/account+/_layout.tsx+++ b/apps/carbon/app/routes/x+/account+/_layout.tsx@@ -1,7 +1,7 @@-import { VStack } from "@carbon/react";+import { Heading, VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";-import { ContentSidebar } from "~/components/Layout/Navigation";+import { DetailSidebar } from "~/components/Layout/Navigation";import { useAccountSubmodules } from "~/modules/account";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +20,24 @@ export default function AccountRoute() {const { links } = useAccountSubmodules();return (- <div className="grid w-full h-full grid-cols-[auto_1fr]">- <ContentSidebar links={links} />- <VStack spacing={0} className="h-full p-2">- <Outlet />- </VStack>- </div>+ <VStack+ className="flex w-full h-full items-center justify-start"+ spacing={4}+ >+ <div className="flex bg-card border-b border-border py-8 px-2 w-full justify-center">+ <div className="w-full max-w-[60rem]">+ <Heading size="h3">Account Settings</Heading>+ </div>+ </div>++ <div className="max-w-[60rem] w-full">+ <div className="grid grid-cols-1 md:grid-cols-[1fr_4fr] h-full w-full gap-8">+ <DetailSidebar links={links} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </div>+ </VStack>);}diff --git a/apps/carbon/app/routes/x+/customer+/_layout.tsx b/apps/carbon/app/routes/x+/customer+/_layout.tsxindex 03a090f771..eced999f87 100644--- a/apps/carbon/app/routes/x+/customer+/_layout.tsx+++ b/apps/carbon/app/routes/x+/customer+/_layout.tsx@@ -42,8 +42,10 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function CustomerRoute() {return (- <VStack spacing={4} className="h-full p-2">- <Outlet />- </VStack>+ <div className="flex h-full w-full justify-center">+ <VStack spacing={4} className="h-full p-2 w-full max-w-[80rem]">+ <Outlet />+ </VStack>+ </div>);}diff --git a/apps/carbon/app/routes/x+/person+/_layout.tsx b/apps/carbon/app/routes/x+/person+/_layout.tsxindex 4eed7207d5..775dedd4c9 100644--- a/apps/carbon/app/routes/x+/person+/_layout.tsx+++ b/apps/carbon/app/routes/x+/person+/_layout.tsx@@ -17,8 +17,10 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function PersonRoute() {return (- <VStack spacing={4} className="h-full p-2">- <Outlet />- </VStack>+ <div className="flex h-full w-full justify-center">+ <VStack spacing={4} className="h-full p-2 w-full max-w-[80rem]">+ <Outlet />+ </VStack>+ </div>);}diff --git a/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx b/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsxindex 3e1e512b94..ed6389300b 100644--- a/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx+++ b/apps/carbon/app/routes/x+/purchase-invoice+/_layout.tsx@@ -35,8 +35,10 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function PurchaseInvoiceRoute() {return (- <VStack spacing={4} className="h-full p-2">- <Outlet />- </VStack>+ <div className="flex h-full w-full justify-center">+ <VStack spacing={4} className="h-full p-2 w-full max-w-[80rem]">+ <Outlet />+ </VStack>+ </div>);}diff --git a/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx b/apps/carbon/app/routes/x+/purchase-order+/_layout.tsxindex 460c615963..75b6d8496c 100644--- a/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx+++ b/apps/carbon/app/routes/x+/purchase-order+/_layout.tsx@@ -38,8 +38,10 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function PurchaseOrderRoute() {return (- <VStack spacing={4} className="h-full p-2">- <Outlet />- </VStack>+ <div className="flex h-full w-full justify-center">+ <VStack spacing={4} className="h-full p-2 w-full max-w-[80rem]">+ <Outlet />+ </VStack>+ </div>);}diff --git a/apps/carbon/app/routes/x+/supplier+/_layout.tsx b/apps/carbon/app/routes/x+/supplier+/_layout.tsxindex 1ca244c205..d93c286ced 100644--- a/apps/carbon/app/routes/x+/supplier+/_layout.tsx+++ b/apps/carbon/app/routes/x+/supplier+/_layout.tsx@@ -42,8 +42,10 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function SupplierRoute() {return (- <VStack spacing={4} className="h-full p-2">- <Outlet />- </VStack>+ <div className="flex h-full w-full justify-center">+ <VStack spacing={4} className="h-full p-2 w-full max-w-[80rem]">+ <Outlet />+ </VStack>+ </div>);}diff --git a/apps/mes/app/routes/x+/jobs.tsx b/apps/mes/app/routes/x+/jobs.tsxindex dcccc9aa70..c376c0b6d5 100644--- a/apps/mes/app/routes/x+/jobs.tsx+++ b/apps/mes/app/routes/x+/jobs.tsx@@ -61,6 +61,7 @@ export async function loader({ request }: LoaderFunctionArgs) {export default function JobsRoute() {const payload = useLoaderData<typeof loader>();+return (<ResizablePanel defaultSize={defaultLayout[1]} minSize={30}><Tabs defaultValue="current">