2017-06-30 20:18:11 +00:00
|
|
|
import React from 'react'
|
2018-03-31 06:11:36 +00:00
|
|
|
import { compose } from 'react-apollo'
|
2017-06-30 20:18:11 +00:00
|
|
|
import Link from 'next/link'
|
|
|
|
|
2017-11-02 16:56:14 +00:00
|
|
|
import withData from '../lib/withData'
|
2017-06-30 20:18:11 +00:00
|
|
|
import redirect from '../lib/redirect'
|
2017-11-02 16:56:14 +00:00
|
|
|
import checkLoggedIn from '../lib/checkLoggedIn'
|
2017-06-30 20:18:11 +00:00
|
|
|
|
2018-03-31 06:11:36 +00:00
|
|
|
import RegisterBox from '../components/RegisterBox'
|
|
|
|
|
2017-06-30 20:18:11 +00:00
|
|
|
class CreateAccount extends React.Component {
|
|
|
|
static async getInitialProps (context, apolloClient) {
|
|
|
|
const { loggedInUser } = await checkLoggedIn(context, apolloClient)
|
|
|
|
|
|
|
|
if (loggedInUser.user) {
|
|
|
|
// Already signed in? No need to continue.
|
|
|
|
// Throw them back to the main page
|
|
|
|
redirect(context, '/')
|
|
|
|
}
|
|
|
|
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<div>
|
2018-03-31 06:11:36 +00:00
|
|
|
{/* RegisterBox handles all register logic. */}
|
|
|
|
<RegisterBox client={this.props.client} />
|
2017-06-30 20:18:11 +00:00
|
|
|
<hr />
|
|
|
|
Already have an account? <Link prefetch href='/signin'><a>Sign in</a></Link>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-31 06:11:36 +00:00
|
|
|
export default compose( // TODO: Maybe remove the usage of compose?
|
2017-06-30 20:18:11 +00:00
|
|
|
// withData gives us server-side graphql queries before rendering
|
2018-03-31 06:11:36 +00:00
|
|
|
withData
|
2017-06-30 20:18:11 +00:00
|
|
|
)(CreateAccount)
|