diff --git a/client/src/components/UserUpdate.js b/client/src/components/UserUpdate.js index 6e9b5b7cf..b77ed07c0 100644 --- a/client/src/components/UserUpdate.js +++ b/client/src/components/UserUpdate.js @@ -18,6 +18,12 @@ import Input from '@material-ui/core/Input'; import classNames from 'classnames'; import Button from '@material-ui/core/Button'; import AddIcon from '@material-ui/icons/Add'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; +import Checkbox from '@material-ui/core/Checkbox'; +import FormGroup from '@material-ui/core/FormGroup'; +import Select from '@material-ui/core/Select'; +import FormHelperText from '@material-ui/core/FormHelperText'; +import NoSsr from '@material-ui/core/NoSsr'; const styles = theme => ({ container: { @@ -25,14 +31,38 @@ const styles = theme => ({ flexWrap: 'wrap', padding: 20 }, - textField: { + inputField: { width: '60%', marginLeft:'20%', marginTop: 20 }, + pField: { + width: '80%', + marginLeft:'10%', + marginTop: 20 + }, + checkbox: { + width: '25%', + marginLeft:'0%', + marginTop: 20 + }, menu: { width: 200, }, + divider: { + height: theme.spacing.unit * 2, + }, + root: { + display: 'flex', + flexWrap: 'wrap', + }, + formControl: { + margin: theme.spacing.unit, + minWidth: 120, + }, + selectEmpty: { + marginTop: theme.spacing.unit * 2, + }, }); class UserUpdate extends Component { @@ -62,10 +92,14 @@ class UserUpdate extends Component { 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( ); + return( + + ); } else { return data.roles.map(role => { - return( ); + return( + + ); }); } } @@ -119,22 +153,19 @@ class UserUpdate extends Component { let select = ReactDOM.findDOMNode(this.refs.select); switch (e.target.id) { case "isDeveloper": - if (select.value === "2") { - select.value = "1"; + if (this.state.roleId === "2") { this.setState({ roleId: "1"}); } break; case "isTrader": - if (select.value === "3") { - select.value = "1"; + if (this.state.roleId === "3") { this.setState({ roleId: "1"}); } break; case "isDataAnalyst": - if (select.value === "4") { - select.value = "1"; + if (this.state.roleId === "4") { this.setState({ roleId: "1"}); } break; @@ -145,21 +176,20 @@ class UserUpdate extends Component { } handleSelect(e){ - let checkbox; + + /* + Whenever the select component changes its value, we need to activate the type of role selected. + To do so, we change the state of the corresponding type of role here. + */ + switch (e.target.value) { case "2": - checkbox = ReactDOM.findDOMNode(this.refs.isDeveloper); - checkbox.checked = true; this.setState({ isDeveloper: 1}) break; case "3": - checkbox = ReactDOM.findDOMNode(this.refs.isTrader); - checkbox.checked = true; this.setState({ isTrader: 1}) break; case "4": - checkbox = ReactDOM.findDOMNode(this.refs.isDataAnalyst); - checkbox.checked = true; this.setState({ isDataAnalyst: 1}) break; default: @@ -168,6 +198,10 @@ class UserUpdate extends Component { this.setState({ roleId:e.target.value }) } + rightCheckboxValue(stateValue) { + if (stateValue === 1) {return true} else {return false}; + } + componentWillMount () { console.log("componentWillUnmount"); @@ -182,22 +216,6 @@ class UserUpdate extends Component { console.log("user", user); this.defaultValuesSet= true; - /* Now we can set the default values for the form fields. */ - /* - this.refs.alias.value = user.alias; - this.refs.firstName.value = user.firstName; - this.refs.middleName.value = user.middleName; - this.refs.lastName.value = user.lastName; - this.refs.email.value = user.email; - this.refs.emailVerified.checked = user.emailVerified; - this.refs.isDeveloper.checked = user.isDeveloper; - this.refs.isTrader.checked = user.isTrader; - this.refs.isDataAnalyst.checked = user.isDataAnalyst; - this.refs.select.value = user.role.id; - console.log("select value ", this.refs.select.value); - console.log("select ", this.refs.select); - */ - this.setState({ id: user.id, alias: user.alias, @@ -222,89 +240,133 @@ console.log("State", this.state); const { classes } = this.props; return( -