mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-11 11:47:50 +00:00
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
'use client';
|
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
import { useState, type ReactNode } from 'react';
|
|
import { Toaster } from 'sonner';
|
|
import { AuthProvider } from '@/lib/auth/AuthContext';
|
|
import { ProtectedRoute } from '@/lib/auth/ProtectedRoute';
|
|
import { ThemeProvider } from '@/components/theme-provider';
|
|
|
|
interface ProvidersProps {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export function Providers({ children }: ProvidersProps) {
|
|
const [queryClient] = useState(
|
|
() =>
|
|
new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 1000 * 60 * 5,
|
|
refetchOnWindowFocus: false,
|
|
retry: 2,
|
|
},
|
|
},
|
|
})
|
|
);
|
|
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<ThemeProvider
|
|
attribute='class'
|
|
defaultTheme='system'
|
|
enableSystem
|
|
disableTransitionOnChange
|
|
>
|
|
<AuthProvider>
|
|
<ProtectedRoute>
|
|
{children}
|
|
<Toaster position='top-right' />
|
|
</ProtectedRoute>
|
|
</AuthProvider>
|
|
<ReactQueryDevtools initialIsOpen={false} />
|
|
</ThemeProvider>
|
|
</QueryClientProvider>
|
|
);
|
|
}
|