2020-10-30 18:28:50 +03:00
|
|
|
import React from 'react'
|
2020-10-30 22:18:17 +03:00
|
|
|
import { Link } from 'react-router-dom'
|
2020-10-30 18:28:50 +03:00
|
|
|
|
2020-11-17 13:49:10 +03:00
|
|
|
import useAuth from '@wasp/auth/useAuth.js'
|
|
|
|
import logout from '@wasp/auth/logout.js'
|
|
|
|
|
2020-10-30 18:28:50 +03:00
|
|
|
const MainPage = () => {
|
2020-11-17 13:49:10 +03:00
|
|
|
const { data: user } = useAuth()
|
|
|
|
|
2020-10-30 22:18:17 +03:00
|
|
|
return (
|
|
|
|
<div>
|
2020-11-17 13:49:10 +03:00
|
|
|
<UserWidget user={user} />
|
2020-10-30 22:18:17 +03:00
|
|
|
</div>
|
|
|
|
)
|
2020-10-30 18:28:50 +03:00
|
|
|
}
|
|
|
|
|
2020-11-17 13:49:10 +03:00
|
|
|
const UserWidget = (props) => {
|
|
|
|
if (props.user) {
|
|
|
|
// TODO: Make links lead somewhere.
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<a href="#"> Settings </a>
|
|
|
|
<a href="#"> { props.user.username } </a>
|
|
|
|
<button onClick={logout}> Log out </button>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Link to='/login'> Sign in </Link>
|
|
|
|
<Link to='/register'> Sign up </Link>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-30 18:28:50 +03:00
|
|
|
export default MainPage
|