feat(portal): add client settings routes and translations

This commit is contained in:
poyrazavsever
2026-07-21 12:49:55 +03:00
parent fcc6f2078a
commit 48f9d7bc87
15 changed files with 1720 additions and 68 deletions
+33
View File
@@ -0,0 +1,33 @@
"use server";
import { cookies } from "next/headers";
import { revalidatePath } from "next/cache";
import {
COLOR_MODE_COOKIE,
COLOR_MODE_COOKIE_MAX_AGE,
} from "@/lib/color-mode";
import { getServerConfig } from "@/server/config";
import { updateColorModePreference } from "@/server/settings/preferences";
import { requirePortalBackend } from "@/server/web/portal";
export async function savePortalColorModeAction(colorMode: string) {
try {
const { actor } = await requirePortalBackend();
const preferences = updateColorModePreference(actor, { colorMode });
const config = getServerConfig();
(await cookies()).set(COLOR_MODE_COOKIE, preferences.colorMode, {
httpOnly: false,
maxAge: COLOR_MODE_COOKIE_MAX_AGE,
path: "/",
sameSite: "lax",
secure: config.secureCookies,
});
revalidatePath("/", "layout");
revalidatePath("/portal", "layout");
revalidatePath("/portal/settings/appearance");
return { success: true, colorMode: preferences.colorMode };
} catch (error) {
console.error("Portal color mode update failed", error);
return { errorKey: "settings.appearance.errors.colorMode" };
}
}