| 1 | "use client"; |
| 2 | |
| 3 | import { QueryClientProvider } from |
| 4 | import { ThemeProvider } |
| 5 | import Link from "next/link |
| 6 | import { useRouter } |
| 7 | import type { ReactNode |
| 8 | |
| 9 | import { AuthProvider } |
| 10 | import { ThemeEffects } |
| 11 | import { authClient } |
| 12 | import { avatar } |
| 13 | import { usernamePlugin } |
| 14 | import { organizationPlugin } |
| 15 | import { organizationRoleLabels } |
| 16 | import { apiKeyPlugin } |
| 17 | |
| 18 | import { getQueryClient } |
| 19 | import { APP_THEME_IDS } |
| 20 | |
| 21 | export function Providers({ |
| 22 | const router = |
| 23 | const queryClient = |
| 24 | |
| 25 | return ( |
| 26 | <ThemeProvider |
| 27 | attribute="class" |
| 28 | defaultTheme="system" |
| 29 | enableSystem |
| 30 | disableTransitionOnChange |
| 31 | themes={APP_THEME_IDS} |
| 32 | > |
| 33 | <ThemeEffects /> |
| 34 | <QueryClientProvider client={ |
| 35 | <AuthProvider |
| 36 | authClient={authClient} |
| 37 | avatar={avatar} |
| 38 | redirectTo="/dashboard" |
| 39 | plugins={[ |
| 40 | usernamePlugin(), |
| 41 | apiKeyPlugin(), |
| 42 | organizationPlugin({ |
| 43 | creatorRole: "owner", |
| 44 | roles: organizationRoleLabels, |
| 45 | teams: true, |
| 46 | }), |
| 47 | ]} |
| 48 | navigate={({ to |
| 49 | replace ? router. |
| 50 | } |
| 51 | Link={Link} |
| 52 | > |
| 53 | {children} |
| 54 | </AuthProvider> |
| 55 | </QueryClientProvider> |
| 56 | </ThemeProvider> |
| 57 | ); |
| 58 | } |