File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 11import Link from 'next/link' ;
22import { useUser } from '../lib/hooks' ;
33import AfterLogin from '../components/AfterLogin' ;
4+ import { useState } from 'react'
45
56export default function Home ( ) {
67 const [ user , { mutate } ] = useUser ( ) ;
8+ const [ loading , isLoading ] = useState ( false ) ;
79 const handleLogout = async ( ) => {
10+ isLoading ( true ) ;
811 await fetch ( '/api/auth' , {
912 method : 'DELETE' ,
1013 } ) ;
1114 // set the user state to null
1215 mutate ( null ) ;
1316 M . toast ( { html : 'Logged out' } )
17+ isLoading ( false ) ;
1418 } ;
1519 return (
1620 < >
@@ -31,6 +35,9 @@ export default function Home() {
3135
3236 </ div >
3337 < div className = "card-stacked center-align" >
38+ { loading ? < div class = "progress white" style = { { margin :0 } } >
39+ < div class = "indeterminate blue" > </ div >
40+ </ div > : null }
3441 < div className = "card-content" >
3542 < h2 style = { { marginTop : '0' } } > < span style = { { fontWeight : 'bolder' , color : `${ user ? '#2196f3' : '#7ed' } ` , textShadow : '2px 2px black' } } > Hello </ span > { ! user ? 'Stranger' : user . name } </ h2 >
3643 { ! user ? < div className = "card-title und" > Welcome to < strong > < a onClick = { ( ) => M . toast ( { html : 'Coming soon' , classes : 'toast' } ) } > Tushar.dev</ a > </ strong > </ div > : null }
You can’t perform that action at this time.
0 commit comments