File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
(auth)/leetcode-dashboard
(home)/components/landing-page Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
3
3
import { useAuth } from "@/components/auth/AuthContext" ;
4
+ import { useState , useEffect } from "react" ;
4
5
import LandingPage from "@/app/(home)/components/landing-page/LandingPage" ;
5
6
import LeetcodeDashboard from "./LeetcodeDashboard" ;
6
7
7
8
const Home = ( ) => {
8
9
const { token } = useAuth ( ) ;
10
+ const [ loading , setLoading ] = useState ( true ) ;
9
11
10
- return (
11
- token ? < LeetcodeDashboard /> : < LandingPage />
12
- ) ;
12
+ // Simulate token fetching or resolving logic
13
+ useEffect ( ( ) => {
14
+ if ( token !== undefined ) {
15
+ setLoading ( false ) ;
16
+ }
17
+ } , [ token ] ) ;
18
+
19
+ if ( loading ) {
20
+ return null ;
21
+ }
22
+
23
+ return token ? < LeetcodeDashboard /> : < LandingPage /> ;
13
24
} ;
14
25
15
- export default Home ;
26
+ export default Home ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const LandingPage = () => {
13
13
const googleLogin = useGoogleLogin ( {
14
14
onSuccess : ( response ) => {
15
15
login ( response ) ;
16
- // router.push("/leetcode-dashboard"); // Redirect to dashboard after successful login
16
+ router . push ( "/leetcode-dashboard" ) ; // Redirect to dashboard after successful login
17
17
} ,
18
18
onError : ( error ) => {
19
19
console . error ( "Login Failed:" , error ) ;
You can’t perform that action at this time.
0 commit comments