Skip to content
Snippets Groups Projects
Commit 6c849d25 authored by Giannis Kopanas's avatar Giannis Kopanas
Browse files

refactor(signup): migrate sign up to graphql

parent de9c37c2
No related branches found
No related tags found
No related merge requests found
module.exports = {
client: {
components: [() => require('./src/SignupContainer')],
},
}
{ {
"name": "pubsweet-component-signup", "name": "editoria-component-signup",
"version": "1.0.41", "version": "1.0.41",
"description": "Basic signup form component for PubSweet", "description": "Basic signup form component for PubSweet",
"main": "index.js", "main": "index.js",
...@@ -9,19 +9,16 @@ ...@@ -9,19 +9,16 @@
"@pubsweet/ui": "^9.1.3", "@pubsweet/ui": "^9.1.3",
"@pubsweet/ui-toolkit": "2.0.7", "@pubsweet/ui-toolkit": "2.0.7",
"formik": "^1.3.0", "formik": "^1.3.0",
"styled-components": "^4.1.1", "prop-types": "^15.5.10",
"prop-types": "^15.5.10", "recompose": "^0.30.0"
"react-bootstrap": "^0.32.0",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"recompose": "^0.30.0",
"redux": "^3.7.2",
"redux-form": "^7.4.2"
}, },
"peerDependencies": { "peerDependencies": {
"graphql-tag": "^2.10.0",
"pubsweet-client": ">=1.0.0", "pubsweet-client": ">=1.0.0",
"react": ">=16", "react": ">=16",
"react-router-redux": "^4.0.8" "react-apollo": "^2.3.3",
"react-router": "^4.3.1",
"styled-components": "^4.1.3"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
...@@ -30,7 +30,7 @@ const EmailInput = props => ( ...@@ -30,7 +30,7 @@ const EmailInput = props => (
const PasswordInput = props => ( const PasswordInput = props => (
<TextField <TextField
label="Password" label="Password"
{...props.input} {...props.field}
placeholder="Password" placeholder="Password"
type="password" type="password"
/> />
......
import { compose } from 'recompose' import { compose } from 'recompose'
import { withFormik } from 'formik' import { withFormik } from 'formik'
import { graphql } from 'react-apollo'
import { SIGNUP_USER } from './graphql/mutations'
import { signupUser } from './actions'
import Signup from './Signup' import Signup from './Signup'
const handleSubmit = (values, dispatch) => { const handleSubmit = (values, { props, setSubmitting, setErrors }) =>
dispatch(signupUser(values)) props.signupUser({
} variables: { input: values },
})
const enhancedFormik = withFormik({ const enhancedFormik = withFormik({
initialValues: { initialValues: {
...@@ -14,8 +16,17 @@ const enhancedFormik = withFormik({ ...@@ -14,8 +16,17 @@ const enhancedFormik = withFormik({
email: '', email: '',
password: '', password: '',
}, },
mapPropsToValues: props => ({
username: props.username,
password: props.password,
email: props.email,
}),
displayName: 'signup', displayName: 'signup',
handleSubmit, handleSubmit,
})(Signup) })(Signup)
export default compose()(enhancedFormik) export default compose(
graphql(SIGNUP_USER, {
name: 'signupUser',
}),
)(enhancedFormik)
import gql from 'graphql-tag'
export const SIGNUP_USER = gql`
mutation($input: UserInput) {
createUser(input: $input) {
id
type
username
email
}
}
`
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