Skip to content

Commit

Permalink
Fix rendering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnie4k committed Dec 14, 2024
1 parent 5148109 commit 03490af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
19 changes: 3 additions & 16 deletions src/app/landing/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
"use client";

import AuthGuard from "@/components/authGuard/authGuard";
import Landing from "@/components/landing/landing";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

export default function LandingPage() {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false, // default: true
},
},
});

return (
<QueryClientProvider client={queryClient}>
<AuthGuard>
<Landing />
</AuthGuard>
</QueryClientProvider>
<AuthGuard>
<Landing />
</AuthGuard>
);
}
19 changes: 3 additions & 16 deletions src/app/past/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
"use client";

import AuthGuard from "@/components/authGuard/authGuard";
import Past from "@/components/past/past";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

export default function PastPage() {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false, // default: true
},
},
});

return (
<QueryClientProvider client={queryClient}>
<AuthGuard>
<Past />
</AuthGuard>
</QueryClientProvider>
<AuthGuard>
<Past />
</AuthGuard>
);
}
11 changes: 10 additions & 1 deletion src/components/authGuard/authGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ import { User } from "@/models/user";
import ApiClient from "@/services/apiClient";
import { useUserStore } from "@/stores/useUserStore";
import { Constants } from "@/utils/constants";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import errorToast from "../system/errorToast";

export default function AuthGuard({ children }: { children: React.ReactNode }) {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false, // default: true
},
},
});

const apiClient = ApiClient.createInstance();

const { user, setUser } = useUserStore();
Expand Down Expand Up @@ -51,5 +60,5 @@ export default function AuthGuard({ children }: { children: React.ReactNode }) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isLoading]);

return <>{children}</>;
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
}

0 comments on commit 03490af

Please sign in to comment.