Skip to content
Snippets Groups Projects
Commit df4c76e6 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

fix(signup-invitation): remove get request

parent 7c52281e
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ const SignUpInvitation = ({
Your details have been pre-filled, please review and confirm before set
your password.
</Subtitle>
<Email>{email}</Email>
<Email>{initialValues.email}</Email>
{error && <Err>Token expired or Something went wrong.</Err>}
{step === 0 && (
<Step0
......
import { get } from 'lodash'
import request, { create } from 'pubsweet-client/src/helpers/api'
import { create } from 'pubsweet-client/src/helpers/api'
import { withJournal } from 'xpub-journal'
import { loginUser } from 'pubsweet-component-login/actions'
import { SubmissionError } from 'redux-form'
import {
compose,
withState,
withProps,
withHandlers,
lifecycle,
} from 'recompose'
import { compose, withState, withProps, withHandlers } from 'recompose'
import SignUpInvitation from './SignUpInvitationForm'
......@@ -52,30 +46,33 @@ const confirmUser = (email, token, history) => (values, dispatch) => {
export default compose(
withJournal,
withState('step', 'changeStep', 0),
withState('initialValues', 'setInitialValues', {}),
withProps(({ location }) => {
const params = new URLSearchParams(location.search)
const email = params.get('email')
const token = params.get('token')
return { email, token }
const firstName = params.get('firstName')
const lastName = params.get('lastName')
const affiliation = params.get('affiliation')
const title = params.get('title')
return {
initialValues: {
email,
firstName,
lastName,
affiliation,
title,
token,
},
}
}),
withHandlers({
nextStep: ({ changeStep }) => () => changeStep(step => step + 1),
prevStep: ({ changeStep }) => () => changeStep(step => step - 1),
submitConfirmation: ({ email, token, history }) =>
confirmUser(email, token, history),
}),
lifecycle({
componentDidMount() {
const { setInitialValues, token } = this.props
const encodedUri = `?passwordResetToken=${token}`
request(`/users/${encodedUri}`)
.then(res => {
setInitialValues(v => res.users[0])
})
.catch(err => {
this.setState({ error: err.response })
})
},
submitConfirmation: ({
initialValues: { email, token },
history,
...rest
}) => confirmUser(email, token, history),
}),
)(SignUpInvitation)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment