diff --git a/client/src/components/AddUser.js b/client/src/components/AddUser.js index 1cb43e56f..0939fe3a8 100644 --- a/client/src/components/AddUser.js +++ b/client/src/components/AddUser.js @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; import {graphql, compose} from 'react-apollo'; import {getRolesQuery, addUserMutation, getUsersQuery} from '../queries/queries'; @@ -8,24 +7,9 @@ class AddUser extends Component { super(props); this.state = { alias: '', - firstName: '', - lastName: '', - isDeveloper: 0, - isTrader: 0, - isDataAnalyst: 0, - roleId: '1' + authId: '1' }; } - displayRoles(){ - var data = this.props.getRolesQuery; // When there is more than one query binded to a single componente 'data' is replaced by thename of the query given below at the binding operation. - if(data.loading){ - return( ); - } else { - return data.roles.map(role => { - return( ); - }); - } - } submitForm(e){ console.log(this.state); @@ -33,84 +17,17 @@ class AddUser extends Component { this.props.addUserMutation({ variables: { alias: this.state.alias, - firstName: this.state.firstName, - lastName: this.state.lastName, - isDeveloper: this.state.isDeveloper, - isTrader: this.state.isTrader, - isDataAnalyst: this.state.isDataAnalyst, - roleId: this.state.roleId + authId: this.state.authId }, refetchQueries: [{ query: getUsersQuery}] // This allow us to re run whatever queries are necesary after the mutation. }); } - handleCheckBoxes(e){ - let fieldValue; - if (e.target.checked === true) { - fieldValue = 1; - } else { - fieldValue = 0; - - /* When the user unchecks one of the checkboxes, we need to make sure that that Role is not the one selected at the SELECT, - and if it is, then we need to automatically select another one */ - - let select = ReactDOM.findDOMNode(this.refs.select); - switch (e.target.id) { - case "isDeveloper": - if (select.value === "2") { - select.value = "1"; - this.setState({ roleId: "1"}); - } - break; - - case "isTrader": - if (select.value === "3") { - select.value = "1"; - this.setState({ roleId: "1"}); - } - break; - - case "isDataAnalyst": - if (select.value === "4") { - select.value = "1"; - this.setState({ roleId: "1"}); - } - break; - default: - } - } - this.setState({ [e.target.id]: fieldValue}) - } - - handleSelect(e){ - let checkbox; - switch (e.target.value) { - case "2": - checkbox = ReactDOM.findDOMNode(this.refs.id2); - checkbox.checked = true; - this.setState({ isDeveloper: 1}) - break; - case "3": - checkbox = ReactDOM.findDOMNode(this.refs.id3); - checkbox.checked = true; - this.setState({ isTrader: 1}) - break; - case "4": - checkbox = ReactDOM.findDOMNode(this.refs.id4); - checkbox.checked = true; - this.setState({ isDataAnalyst: 1}) - break; - default: - } - - this.setState({ roleId:e.target.value }) - } - render(){ return(
{ user.firstName }
{ user.lastName }
@@ -22,6 +23,7 @@ class UserProfile extends Component { } render() { + return (