diff --git a/client/src/components/UserReferrals.js b/client/src/components/UserReferrals.js index 6f00b0b27..ad7d8fe8c 100644 --- a/client/src/components/UserReferrals.js +++ b/client/src/components/UserReferrals.js @@ -11,22 +11,12 @@ import UserSearch from './UserSearch' import { withStyles } from '@material-ui/core/styles' import MenuItem from '@material-ui/core/MenuItem' import TextField from '@material-ui/core/TextField' -import FormControl from '@material-ui/core/FormControl' -import InputLabel from '@material-ui/core/InputLabel' import Input from '@material-ui/core/Input' import Button from '@material-ui/core/Button' -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 Paper from '@material-ui/core/Paper' -import Grid from '@material-ui/core/Grid' import Typography from '@material-ui/core/Typography' -// Images -import AALogo from '../img/aa-logo.png' - const styles = theme => ({ root: { width: '50%', @@ -35,33 +25,14 @@ const styles = theme => ({ marginLeft: '25%', marginTop: '2%' }, - inputField: { - width: '80%', - marginLeft: '10%', - marginTop: 25 - }, typography: { width: '80%', marginLeft: '10%', marginTop: 40 }, - checkbox: { - width: 150, - marginLeft: '0%', - marginTop: 20 - }, - selectEmpty: { - marginTop: theme.spacing.unit * 2 - }, button: { margin: theme.spacing.unit, marginTop: theme.spacing.unit * 3 - }, - img: { - display: 'block', - marginTop: 20, - maxWidth: 120, - maxHeight: 24 } }) @@ -73,36 +44,10 @@ class UserReferrals extends Component { this.defaultValuesSet = false this.state = { - id: '', - firstName: '', - middleName: '', - lastName: '', - bio: '', - email: '', - emailVerified: 0, - isDeveloper: 0, - isTrader: 0, - isDataAnalyst: 0, - roleId: '1', firstNameError: false, middleNameError: false, lastNameError: false, - bioError: false - } - } - - 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 ( - Loading roles - ) - } else { - return data.roles.map(role => { - return ( - { role.name } - ) - }) + aliasError: false } } @@ -139,108 +84,6 @@ class UserReferrals extends Component { localStorage.setItem('loggedInUser', JSON.stringify(user)) } - 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 */ - - switch (e.target.id) { - case 'isDeveloper': - if (this.state.roleId === '2') { - this.setState({ roleId: '1'}) - } - break - - case 'isTrader': - if (this.state.roleId === '3') { - this.setState({ roleId: '1'}) - } - break - - case 'isDataAnalyst': - if (this.state.roleId === '4') { - this.setState({ roleId: '1'}) - } - break - default: - } - } - this.setState({ [e.target.id]: fieldValue}) - } - - handleSelect (e) { - /* - 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': - this.setState({ isDeveloper: 1}) - break - case '3': - this.setState({ isTrader: 1}) - break - case '4': - this.setState({ isDataAnalyst: 1}) - break - default: - } - - this.setState({ roleId: e.target.value }) - } - - handleTextField (e) { - /* - We will do some basic input validations here. If something is wrong we will turn on the error sign on the textfield. - */ - - let value = e.target.value - - switch (e.target.id) { - case 'firstName': - if (value.length > 30) { - this.setState({firstNameError: true}) - } else { - this.setState({firstNameError: false, firstName: value}) - } - break - case 'middleName': - if (value.length > 30) { - this.setState({middleNameError: true}) - } else { - this.setState({middleNameError: false, middleName: value}) - } - break - case 'lastName': - if (value.length > 50) { - this.setState({lastNameError: true}) - } else { - this.setState({lastNameError: false, lastName: value}) - } - break - case 'bio': - if (value.length > 250) { - this.setState({bioError: true}) - } else { - this.setState({bioError: false, bio: value}) - } - break - default: - } - } - - rightCheckboxValue (stateValue) { - if (stateValue === 1) { - return true - } else { return false } - } - componentWillMount () { if (this.defaultValuesSet === false) { let userData = localStorage.getItem('loggedInUser')