mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
Add files via upload
This commit is contained in:
26
src/providers/ThemeColorsProvider.tsx
Normal file
26
src/providers/ThemeColorsProvider.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { themeColorsApi } from '../api/themeColors'
|
||||
import { DEFAULT_THEME_COLORS } from '../types/theme'
|
||||
import { applyThemeColors } from '../hooks/useThemeColors'
|
||||
|
||||
interface ThemeColorsProviderProps {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export function ThemeColorsProvider({ children }: ThemeColorsProviderProps) {
|
||||
const { data: colors } = useQuery({
|
||||
queryKey: ['theme-colors'],
|
||||
queryFn: themeColorsApi.getColors,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 1,
|
||||
})
|
||||
|
||||
// Apply colors on mount and when they change
|
||||
useEffect(() => {
|
||||
applyThemeColors(colors || DEFAULT_THEME_COLORS)
|
||||
}, [colors])
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
Reference in New Issue
Block a user