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 = ({ ...@@ -20,7 +20,7 @@ const SignUpInvitation = ({
Your details have been pre-filled, please review and confirm before set Your details have been pre-filled, please review and confirm before set
your password. your password.
</Subtitle> </Subtitle>
<Email>{email}</Email> <Email>{initialValues.email}</Email>
{error && <Err>Token expired or Something went wrong.</Err>} {error && <Err>Token expired or Something went wrong.</Err>}
{step === 0 && ( {step === 0 && (
<Step0 <Step0
......
import { get } from 'lodash' 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 { withJournal } from 'xpub-journal'
import { loginUser } from 'pubsweet-component-login/actions' import { loginUser } from 'pubsweet-component-login/actions'
import { SubmissionError } from 'redux-form' import { SubmissionError } from 'redux-form'
import { import { compose, withState, withProps, withHandlers } from 'recompose'
compose,
withState,
withProps,
withHandlers,
lifecycle,
} from 'recompose'
import SignUpInvitation from './SignUpInvitationForm' import SignUpInvitation from './SignUpInvitationForm'
...@@ -52,30 +46,33 @@ const confirmUser = (email, token, history) => (values, dispatch) => { ...@@ -52,30 +46,33 @@ const confirmUser = (email, token, history) => (values, dispatch) => {
export default compose( export default compose(
withJournal, withJournal,
withState('step', 'changeStep', 0), withState('step', 'changeStep', 0),
withState('initialValues', 'setInitialValues', {}),
withProps(({ location }) => { withProps(({ location }) => {
const params = new URLSearchParams(location.search) const params = new URLSearchParams(location.search)
const email = params.get('email') const email = params.get('email')
const token = params.get('token') 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({ withHandlers({
nextStep: ({ changeStep }) => () => changeStep(step => step + 1), nextStep: ({ changeStep }) => () => changeStep(step => step + 1),
prevStep: ({ changeStep }) => () => changeStep(step => step - 1), prevStep: ({ changeStep }) => () => changeStep(step => step - 1),
submitConfirmation: ({ email, token, history }) => submitConfirmation: ({
confirmUser(email, token, history), initialValues: { email, token },
}), history,
lifecycle({ ...rest
componentDidMount() { }) => confirmUser(email, token, history),
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 })
})
},
}), }),
)(SignUpInvitation) )(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