Now using changeUsername

This commit is contained in:
Belen Curcio
2017-11-20 16:07:50 -03:00
parent 43e9da9cbc
commit 2706e47f85
3 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import {createDefaultResponseFragments} from '../utils';
// fragments defined here are automatically registered.
export default {
...createDefaultResponseFragments(
'SetUsernameResponse',
'ChangeUsernameResponse',
'SetUserBanStatusResponse',
'SetUserSuspensionStatusResponse',
'SetCommentStatusResponse',
+5 -5
View File
@@ -196,16 +196,16 @@ export const withRejectUsername = withMutation(
})
});
export const withSetUsername = withMutation(
export const withChangeUsername = withMutation(
gql`
mutation RejectUsername($id: ID!, $username: String!) {
setUsername(id: $id, username: $username) {
...SetUsernameResponse
mutation ChangeUsername($id: ID!, $username: String!) {
changeUsername(id: $id, username: $username) {
...ChangeUsernameResponse
}
}
`, {
props: ({mutate}) => ({
setUsername: (id, username) => {
changeUsername: (id, username) => {
return mutate({
variables: {
id,
@@ -5,7 +5,7 @@ import {bindActionCreators} from 'redux';
import errorMsj from 'coral-framework/helpers/error';
import validate from 'coral-framework/helpers/validate';
import CreateUsernameDialog from './CreateUsernameDialog';
import {withSetUsername} from 'coral-framework/graphql/mutations';
import {withChangeUsername} from 'coral-framework/graphql/mutations';
import {compose} from 'react-apollo';
import t from 'coral-framework/services/i18n';
@@ -94,8 +94,9 @@ class ChangeUsernameContainer extends React.Component {
const {errors, formData: {username}} = this.state;
const {validForm, invalidForm} = this.props;
this.displayErrors();
if (this.isCompleted() && !Object.keys(errors).length) {
this.props.setUsername(this.props.auth.user.id, username);
this.props.changeUsername(this.props.auth.user.id, username);
validForm();
} else {
invalidForm(t('createdisplay.check_the_form'));
@@ -131,7 +132,7 @@ ChangeUsernameContainer.propTypes = {
validForm: PropTypes.func,
invalidForm: PropTypes.func,
loggedIn: PropTypes.bool,
setUsername: PropTypes.func,
changeUsername: PropTypes.func,
};
const mapStateToProps = ({auth}) => ({
@@ -151,6 +152,6 @@ const mapDispatchToProps = (dispatch) =>
);
export default compose(
withSetUsername,
withChangeUsername,
connect(mapStateToProps, mapDispatchToProps),
)(ChangeUsernameContainer);