18 lines
451 B
TypeScript
18 lines
451 B
TypeScript
"use client"
|
|
|
|
import { useAuthStore } from "@/store/auth"
|
|
import { useTheme } from "next-themes"
|
|
import { useEffect } from "react"
|
|
|
|
export function ThemeSyncEffect() {
|
|
const { setTheme } = useTheme()
|
|
const isAuthenticated = useAuthStore((s) => s.isAuthenticated)
|
|
const themePreference = useAuthStore((s) => s.themePreference)
|
|
|
|
useEffect(() => {
|
|
setTheme(themePreference)
|
|
}, [isAuthenticated, themePreference, setTheme])
|
|
|
|
return null
|
|
}
|