Skip to content

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.

fix: theme select

Brad Barbin7f7f5f318a40
diff --git a/apps/erp/app/routes/x+/account+/theme.tsx b/apps/erp/app/routes/x+/account+/theme.tsx
new file mode 100644
index 0000000000..04e84b5308
--- /dev/null
+++ b/apps/erp/app/routes/x+/account+/theme.tsx
@@ -0,0 +1,39 @@
+import { assertIsPost } from "@carbon/auth";
+import { validationError, validator } from "@carbon/form";
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+import { themeValidator } from "~/modules/settings";
+import { getTheme, setTheme } from "~/services/theme.server";
+import type { Handle } from "~/utils/handle";
+import { path } from "~/utils/path";
+
+export const handle: Handle = {
+ breadcrumb: "Theme",
+ to: path.to.theme,
+};
+
+export async function loader({ request }: LoaderFunctionArgs) {
+ const theme = getTheme(request);
+
+ return json({
+ theme: theme ?? "zinc",
+ });
+}
+
+export async function action({ request }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const formData = await request.formData();
+
+ const validation = await validator(themeValidator).validate(formData);
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ return json(
+ {},
+ {
+ headers: { "Set-Cookie": setTheme(validation.data.theme) },
+ }
+ );
+}