everything works

This commit is contained in:
Arjun Patel
2022-01-13 00:50:07 -08:00
parent 3e37774238
commit 2ac31fa825
2 changed files with 31 additions and 27 deletions
+19 -5
View File
@@ -5,21 +5,35 @@ import { useEffect } from 'react'
import { useAuth } from '../../contexts/authContext'
export default function Dashboard() {
const { currUser, signOut } = useAuth()
const { currUser, logOut } = useAuth()
const router = useRouter()
console.log("in dashboard " + currUser)
useEffect(() => {
// if not authed, go to home
if (!currUser) {
console.log('routing from dashboard to teams home')
console.log('not authenticated...routing from dashboard to teams home')
router.push('/teams')
}
}, [])
}, [currUser])
async function handleSignOut() {
console.log("clicked log out button")
try {
await logOut()
router.push('/teams')
} catch(error) {
console.log(error)
}
}
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>
<button onClick={handleSignOut} className='mt-10 text-sm text-orange-500 font-semibold py-1 px-4 bg-orange-200 rounded'>👋 Logout</button>
</div>
)
}