feat: tema ayarları Appwrite user prefs ile kalıcı hale getirildi
- saveThemePrefsAction: account.updatePrefs ile mevcut prefs'i merge eder - Dashboard layout'ta account.getPrefs ile prefs server-side yüklenir - PrefsInitializer: mount'ta dark/light, renk teması, radius, sidebar config'ini Appwrite'dan gelen initialPrefs ile uygular - ThemeCustomizer: renk teması / tweakcn / radius / sidebar değişikliği anında Appwrite'a kaydedilir; dark/light toggle useEffect ile izlenir - Sayfa yenileme ve farklı cihazda giriş sonrasında ayarlar korunur
This commit is contained in:
@@ -2,6 +2,8 @@ import { redirect } from "next/navigation";
|
||||
|
||||
import { getActiveContext } from "@/lib/appwrite/active-context";
|
||||
import { getLogoUrl } from "@/lib/appwrite/storage";
|
||||
import { createSessionClient } from "@/lib/appwrite/server";
|
||||
import type { ThemePrefs } from "@/lib/appwrite/theme-prefs-actions";
|
||||
import { DashboardShell } from "./dashboard-shell";
|
||||
|
||||
export default async function DashboardLayout({
|
||||
@@ -12,6 +14,14 @@ export default async function DashboardLayout({
|
||||
const ctx = await getActiveContext();
|
||||
if (!ctx) redirect("/onboarding");
|
||||
|
||||
let themePrefs: ThemePrefs = {};
|
||||
try {
|
||||
const { account } = await createSessionClient();
|
||||
themePrefs = await account.getPrefs<ThemePrefs>();
|
||||
} catch {
|
||||
// use defaults if prefs unavailable
|
||||
}
|
||||
|
||||
const company = {
|
||||
id: ctx.tenantId,
|
||||
name: ctx.settings?.officeName ?? "Çalışma alanı",
|
||||
@@ -24,7 +34,7 @@ export default async function DashboardLayout({
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardShell user={user} company={company}>
|
||||
<DashboardShell user={user} company={company} initialPrefs={themePrefs}>
|
||||
{children}
|
||||
</DashboardShell>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user