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
dark mode toggle issue
Gaurav Bhatt48bc9e5dfd79
diff --git a/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx b/apps/erp/app/routes/mcp+/components/ThemeToggle.tsxindex 2a1a1b4c72..e0ed7671a4 100644--- a/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx+++ b/apps/erp/app/routes/mcp+/components/ThemeToggle.tsx@@ -1,27 +1,38 @@import { useMode } from "@carbon/react";import { LuMoon, LuSun } from "react-icons/lu";import { useFetcher } from "react-router";+import { startModeTransition } from "~/utils/dom";+import { path } from "~/utils/path";-// Uses the app's canonical mode mechanism: POST the new mode to the root action-// (public — works signed-out), which sets the cookie and flips the theme-// optimistically via useMode(). No reload.export function ThemeToggle() {const fetcher = useFetcher();const mode = useMode();const next = mode === "dark" ? "light" : "dark";+ const onClick = () => {+ // Persist host-only (no domain) so it survives regardless of the configured+ // cookie domain. The server's setMode adds a domain attribute that won't match+ // local/preview hosts, so its cookie gets dropped and the theme reverts on+ // revalidation — this host-only cookie is what getMode() reads instead.+ document.cookie = `mode=${next}; path=/; max-age=31536000; samesite=lax`;++ const formData = new FormData();+ formData.append("mode", next);+ startModeTransition(next, () => {+ fetcher.submit(formData, { method: "post", action: path.to.root });+ });+ };+return (- <fetcher.Form method="post" action="/">- <input type="hidden" name="mode" value={next} />- <button- type="submit"- aria-label={- mode === "dark" ? "Switch to light mode" : "Switch to dark mode"- }- className="inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border bg-card text-foreground hover:border-muted-foreground transition-[transform,border-color] duration-150 active:scale-[0.96]"- >- {mode === "dark" ? <LuSun size={16} /> : <LuMoon size={16} />}- </button>- </fetcher.Form>+ <button+ type="button"+ aria-label={+ mode === "dark" ? "Switch to light mode" : "Switch to dark mode"+ }+ onClick={onClick}+ className="inline-flex items-center justify-center w-9 h-9 rounded-lg border border-border bg-card text-foreground hover:border-muted-foreground transition-[transform,border-color] duration-150 active:scale-[0.96]"+ >+ {mode === "dark" ? <LuSun size={16} /> : <LuMoon size={16} />}+ </button>);}