Added a lib for client settings #3

This commit is contained in:
2025-10-02 11:04:07 +02:00
parent 39b7d58a24
commit fe89e38067
2 changed files with 33 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { ClientSettings } from "@/types/config";
import Cookies from "js-cookie";
const defaultSettings: ClientSettings = {
theme: "dark",
};
export function getClientSettings(): ClientSettings {
const s_cookie = Cookies.get("settings");
let parsed: Partial<ClientSettings> = {};
if (s_cookie) {
try {
parsed = JSON.parse(s_cookie);
} catch {
parsed = {};
}
}
return {
...defaultSettings,
...parsed,
};
}
export function setClientSettings(value?: ClientSettings) {
Cookies.set("settings", JSON.stringify(value || defaultSettings));
}
+5
View File
@@ -0,0 +1,5 @@
export interface ClientSettings {
theme: "light" | "dark";
}
export interface AccountSettings {}