mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-08 03:08:21 +00:00
23 lines
749 B
TypeScript
23 lines
749 B
TypeScript
import { type ActionFunctionArgs, json, redirect } from "@remix-run/cloudflare";
|
|
|
|
import { isTheme } from "~/lib/theme-provider";
|
|
import { getThemeSession } from "~/lib/theme.server";
|
|
|
|
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
const themeSession = await getThemeSession(request);
|
|
const requestText = await request.text();
|
|
const form = new URLSearchParams(requestText);
|
|
const theme = form.get("theme");
|
|
|
|
if (!isTheme(theme)) {
|
|
return json({
|
|
success: false,
|
|
message: `theme value of ${theme} is not a valid theme`,
|
|
});
|
|
}
|
|
|
|
themeSession.setTheme(theme);
|
|
return json({ success: true }, { headers: { "Set-Cookie": await themeSession.commit() } });
|
|
};
|
|
|
|
export const loader = () => redirect("/", { status: 404 });
|