File tree Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Expand file tree Collapse file tree 5 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 1+ import  {  Auth  }  from  "@supabase/ui" ; 
2+ import  Link  from  "next/link" ; 
3+ import  React  from  "react" ; 
4+ 
5+ export  function  Navigation ( )  { 
6+   const  user  =  Auth . useUser ( ) ; 
7+   return  ( 
8+     < div > 
9+       SupaNews{ " " } 
10+       { user . user  ===  null  ? ( 
11+         < Link  href = "/login" > login</ Link > 
12+       )  : ( 
13+         < > 
14+           < Link  href = "/account" > account</ Link > 
15+           < Link  href = "/logout" > logout</ Link > 
16+         </ > 
17+       ) } 
18+     </ div > 
19+   ) ; 
20+ } 
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Auth } from "@supabase/ui";
44
55const  SupabaseClientContext  =  React . createContext < SupabaseClient  |  null > ( null ) ; 
66
7- export  function  SupabaseProvider ( props : {  children : React . ReactElement  } )  { 
7+ export  function  SupabaseProvider ( props : {  children : React . ReactNode  } )  { 
88  const  [ client ]  =  React . useState ( ( )  => 
99    createClient ( 
1010      process . env . NEXT_PUBLIC_SUPABASE_URL ! , 
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from "react";
22import  {  createClient ,  Provider  }  from  "urql" ; 
33import  {  useSupabaseClient  }  from  "./supabase" ; 
44
5- export  function  UrqlProvider ( props : {  children : React . ReactElement  } )  { 
5+ export  function  UrqlProvider ( props : {  children : React . ReactNode  } )  { 
66  const  supabaseClient  =  useSupabaseClient ( ) ; 
77
88  function  getHeaders ( ) : Record < string ,  string >  { 
Original file line number Diff line number Diff line change @@ -2,11 +2,13 @@ import "../styles/globals.css";
22import  type  {  AppProps  }  from  "next/app" ; 
33import  {  UrqlProvider  }  from  "../lib/urql" ; 
44import  {  SupabaseProvider  }  from  "../lib/supabase" ; 
5+ import  {  Navigation  }  from  "../lib/navigation" ; 
56
67function  MyApp ( {  Component,  pageProps } : AppProps )  { 
78  return  ( 
89    < SupabaseProvider > 
910      < UrqlProvider > 
11+         < Navigation  /> 
1012        < Component  { ...pageProps }  /> 
1113      </ UrqlProvider > 
1214    </ SupabaseProvider > 
Original file line number Diff line number Diff line change 1+ import  React  from  "react" ; 
2+ import  type  {  NextPage  }  from  "next" ; 
3+ import  {  Auth  }  from  "@supabase/ui" ; 
4+ import  {  useSupabaseClient  }  from  "../lib/supabase" ; 
5+ import  {  useRouter  }  from  "next/router" ; 
6+ 
7+ const  LogOut : NextPage  =  ( )  =>  { 
8+   const  supabaseClient  =  useSupabaseClient ( ) ; 
9+   const  router  =  useRouter ( ) ; 
10+ 
11+   React . useEffect ( ( )  =>  { 
12+     supabaseClient . auth . signOut ( ) . then ( ( )  =>  router . replace ( "/" ) ) ; 
13+   } ,  [ ] ) ; 
14+   return  null ; 
15+ } ; 
16+ 
17+ export  default  LogOut ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments