-
-
Save arist0tl3/4eae0c3f59ac856343bd0ed028dc49e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const container = compose( | |
withStateHandlers({ errors: [] }, { | |
setErrors: () => errors => ({ errors }), | |
}), | |
graphql(LOGIN_MUTATION, { | |
props: ({ mutate, ownProps }) => ({ | |
login: input => | |
mutate({ | |
variables: { | |
input, | |
}, | |
}) | |
.then(data => { | |
console.log('data', data); | |
if (data.loginResponse) { | |
ownProps.history.push('/repositories'); | |
} | |
}) | |
.catch((err) => { | |
const errors = getErrors(err); // Transform your server-thrown errors | |
ownProps.setErrors(errors); | |
}), | |
}), | |
}), | |
withForm({ | |
handleSubmit: (values, { props, setSubmitting, setStatus }) => { | |
props.login(values); | |
}, | |
mapPropsToValues: props => ({ | |
username: props.username, | |
password: props.password, | |
}), | |
}) | |
); | |
type Props = { | |
handleSubmit: Function, | |
}; | |
const LoginScene = (props: Props) => ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment