good spot withh auth

This commit is contained in:
Arjun Patel
2022-01-12 23:52:58 -08:00
parent a83e319c78
commit 3e37774238
8 changed files with 167 additions and 65 deletions
+25
View File
@@ -0,0 +1,25 @@
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { useAuth } from '../../contexts/authContext'
export default function Dashboard() {
const { currUser, signOut } = useAuth()
const router = useRouter()
useEffect(() => {
// if not authed, go to home
if (!currUser) {
console.log('routing from dashboard to teams home')
router.push('/teams')
}
}, [])
return (
<div>
<h1 className='text-white'>This is the dashboard</h1>
<button onClick={signOut} className='mt-10 text-sm text-orange-500 font-semibold py-1 px-4 bg-orange-200 rounded'>👋 Logout</button>
</div>
)
}