useTheme.ts
1 import { type Theme } from "@/contexts/AppContext"; 2 import { useAppContext } from "@/hooks/useAppContext"; 3 4 /** 5 * Hook to get and set the active theme 6 * @returns Theme context with theme and setTheme 7 */ 8 export function useTheme(): { theme: Theme; setTheme: (theme: Theme) => void } { 9 const { config, updateConfig } = useAppContext(); 10 11 return { 12 theme: config.theme, 13 setTheme: (theme: Theme) => { 14 updateConfig((currentConfig) => ({ 15 ...currentConfig, 16 theme, 17 })); 18 } 19 } 20 }