diff --git a/src/app/(protected)/goals/[goalId]/page.tsx b/src/app/(protected)/goals/[goalId]/page.tsx index ba0cc6c..5d50b0f 100644 --- a/src/app/(protected)/goals/[goalId]/page.tsx +++ b/src/app/(protected)/goals/[goalId]/page.tsx @@ -29,13 +29,6 @@ export default async function GoalsPage({ params }: GoalsPageProps) { auth: "access", }), }), - queryClient.prefetchQuery({ - queryKey: goalsQueryKeys.list(), - queryFn: () => - backendFetch("/goals", { - auth: "access", - }), - }), ]); return ( diff --git a/src/app/(protected)/layout.tsx b/src/app/(protected)/layout.tsx index aef9748..8a056a8 100644 --- a/src/app/(protected)/layout.tsx +++ b/src/app/(protected)/layout.tsx @@ -1,6 +1,9 @@ +import { GoalResponse } from "@/api/types/goal"; import ProtectedContent from "@/app/(protected)/_components/ProtectedContent"; import { AuthUser } from "@/hooks/queries/auth/queryKeys"; +import goalsQueryKeys from "@/hooks/queries/goals/queryKeys"; import { backendFetch } from "@/lib/backend"; +import { dehydrate, HydrationBoundary, QueryClient } from "@tanstack/react-query"; import { redirect } from "next/navigation"; import NavigationDesktop from "./_components/navigation/NavigationDesktop"; @@ -13,6 +16,7 @@ export default async function ProtectedLayout({ children, modal, }: ProtectedLayoutProps) { + const queryClient = new QueryClient(); let user: AuthUser; try { @@ -21,18 +25,25 @@ export default async function ProtectedLayout({ redirect("/login"); } + await queryClient.prefetchQuery({ + queryKey: goalsQueryKeys.list(), + queryFn: () => backendFetch("/goals", { auth: "access" }), + }); + return ( - -
-
- -
+ + +
+
+ +
-
- {children} - {modal} -
-
-
+
+ {children} + {modal} +
+
+
+ ); }