2025-09-13 22:02:27 +01:00
|
|
|
import "@/styles/globals.css"
|
2025-09-14 10:59:49 +00:00
|
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
|
2025-09-14 18:12:29 +00:00
|
|
|
import { createRootRoute, Outlet } from "@tanstack/react-router"
|
2025-12-15 00:13:10 +00:00
|
|
|
import { Provider } from "jotai"
|
|
|
|
|
import { useHydrateAtoms } from "jotai/utils"
|
|
|
|
|
import { queryClientAtom } from "jotai-tanstack-query"
|
|
|
|
|
import type React from "react"
|
2025-10-05 20:49:41 +00:00
|
|
|
import { Toaster } from "@/components/ui/sonner"
|
2025-12-15 00:13:10 +00:00
|
|
|
import { defaultOnError } from "@/lib/error"
|
2025-09-21 15:12:05 +00:00
|
|
|
import { useKeyboardModifierListener } from "@/lib/keyboard"
|
2025-09-13 22:02:27 +01:00
|
|
|
|
|
|
|
|
export const Route = createRootRoute({
|
|
|
|
|
component: RootLayout,
|
|
|
|
|
})
|
|
|
|
|
|
2025-09-14 18:12:29 +00:00
|
|
|
const queryClient = new QueryClient({
|
|
|
|
|
defaultOptions: {
|
2025-12-15 00:13:10 +00:00
|
|
|
queries: {
|
|
|
|
|
throwOnError: false,
|
|
|
|
|
},
|
2025-09-14 18:12:29 +00:00
|
|
|
mutations: {
|
2025-12-15 00:13:10 +00:00
|
|
|
onError: defaultOnError,
|
2025-09-14 18:12:29 +00:00
|
|
|
throwOnError: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
2025-09-13 22:02:27 +01:00
|
|
|
|
2025-12-15 00:13:10 +00:00
|
|
|
function HydrateAtoms({ children }: React.PropsWithChildren) {
|
|
|
|
|
useHydrateAtoms(new Map([[queryClientAtom, queryClient]]))
|
|
|
|
|
return children
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-13 22:02:27 +01:00
|
|
|
function RootLayout() {
|
2025-09-21 15:12:05 +00:00
|
|
|
useKeyboardModifierListener()
|
|
|
|
|
|
2025-09-13 22:02:27 +01:00
|
|
|
return (
|
2025-09-14 10:59:49 +00:00
|
|
|
<QueryClientProvider client={queryClient}>
|
2025-12-15 00:13:10 +00:00
|
|
|
<Provider>
|
|
|
|
|
<HydrateAtoms>
|
|
|
|
|
<Outlet />
|
|
|
|
|
<Toaster />
|
|
|
|
|
</HydrateAtoms>
|
|
|
|
|
</Provider>
|
2025-09-14 10:59:49 +00:00
|
|
|
</QueryClientProvider>
|
2025-09-13 22:02:27 +01:00
|
|
|
)
|
|
|
|
|
}
|