Skip to content

Commit

Permalink
fix: on page reload Insights page redirecting to Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepak Paul committed Aug 7, 2023
1 parent c4c5609 commit fcb24ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions layouts/private-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useUser } from "@supabase/auth-helpers-react";
import { useSessionContext, useUser } from "@supabase/auth-helpers-react";
import { useRouter } from "next/router";
import React, { useEffect } from "react";
import useSession from "lib/hooks/useSession";
Expand All @@ -11,12 +11,13 @@ interface PrivateWrapperProps {
const PrivateWrapper = ({ isPrivateRoute = false, children }: PrivateWrapperProps) => {
const user = useUser();
const router = useRouter();
const { isLoading } = useSessionContext();
const { session: isValid } = useSession(true);

async function checkSession() {
if (router.asPath?.includes("login")) return;

if (!isValid) {
if (!isValid && !isLoading) {
router.replace("/javascript/dashboard/filter/recent");
}
}
Expand Down

0 comments on commit fcb24ec

Please sign in to comment.