@@ -11,7 +11,6 @@ import CodespaceInvitation from "./Dashboard/AcceptInvite";
1111import ProfilePage from "./Dashboard/profile" ;
1212import SettingsPage from "./Dashboard/ProfileSetting" ;
1313import Homepage from "./Home/Homepage" ;
14-
1514import {
1615 BrowserRouter as Router ,
1716 Routes ,
@@ -23,14 +22,12 @@ import { supabase } from "./database/superbase";
2322import { type Session , type User } from "@supabase/supabase-js" ;
2423
2524function App ( ) {
26- // 🚩 allow undefined for loading state
2725 const [ session , setSession ] = useState < Session | null | undefined > ( undefined ) ;
2826 const lastTokenRef = useRef < string | undefined > ( undefined ) ;
2927
3028 useEffect ( ( ) => {
3129 console . log ( "App mounted" ) ;
3230
33- // 🚩 initial session check
3431 supabase . auth . getSession ( ) . then ( ( { data : { session } } ) => {
3532 setSession ( session ?? null ) ;
3633 if ( session ) upsertProfile ( session . user ) ;
@@ -64,10 +61,9 @@ function App() {
6461 if ( error ) console . error ( "Error upserting profile:" , error . message ) ;
6562 }
6663
67- // 🚩 ProtectedRoute now handles loading
6864 function ProtectedRoute ( { children } : { children : React . ReactNode } ) {
6965 if ( session === undefined ) {
70- return < div > </ div > ; // still checking session
66+ return < div > </ div > ;
7167 }
7268 return session ? children : < Navigate to = "/login" /> ;
7369 }
@@ -106,7 +102,12 @@ function App() {
106102 }
107103 />
108104
109- < Route path = "/codeeditor/:id" element = { < CodeEditorPage /> } />
105+ < Route path = "/codeeditor/:id"
106+ element = {
107+ < ProtectedRoute >
108+ < CodeEditorPage />
109+ </ ProtectedRoute > }
110+ />
110111 < Route
111112 path = "/codespace/sharebyemail/:invitationId"
112113 element = { < CodespaceInvitation /> }
0 commit comments