diff --git a/client/coral-framework/graphql/fragments.js b/client/coral-framework/graphql/fragments.js index 861c1f9ae..4fb84f18e 100644 --- a/client/coral-framework/graphql/fragments.js +++ b/client/coral-framework/graphql/fragments.js @@ -3,7 +3,7 @@ import {createDefaultResponseFragments} from '../utils'; // fragments defined here are automatically registered. export default { ...createDefaultResponseFragments( - 'SetUsernameResponse', + 'ChangeUsernameResponse', 'SetUserBanStatusResponse', 'SetUserSuspensionStatusResponse', 'SetCommentStatusResponse', diff --git a/client/coral-framework/graphql/mutations.js b/client/coral-framework/graphql/mutations.js index 97c476efe..a0e29220e 100644 --- a/client/coral-framework/graphql/mutations.js +++ b/client/coral-framework/graphql/mutations.js @@ -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, diff --git a/plugins/talk-plugin-auth/client/components/ChangeUsername.js b/plugins/talk-plugin-auth/client/components/ChangeUsername.js index fb3720dfd..cdba62cad 100644 --- a/plugins/talk-plugin-auth/client/components/ChangeUsername.js +++ b/plugins/talk-plugin-auth/client/components/ChangeUsername.js @@ -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);