import React, { Component } from "react"; import ReactDOM from "react-dom"; import { Container, Checkbox, Header, Form, Grid, Modal, Rail, Segment, List, Input, Button, Message, Icon, Table } from "semantic-ui-react"; // ---------------------------------------------------- const requestMessageStyle = { color: "red" }; // ---------------------------------------------------- class AddPermissionModal extends Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); this.handleClose = this.handleClose.bind(this); this.handleChange = this.handleChange.bind(this); // Set initial state this.state = { role: 5, email: "", error: "" }; } componentDidMount() { } handleInputChange = (e, { name, value }) => this.setState({ [name]: value }); handleChange = (e, { newRole }) => this.setState({ newRole }) handleClose = () => { this.setState({ error: "" }); this.props.onClose(false); } handleSubmit() { //if (this.props.updatePermissionId) { const data = {email: this.state.email, shortName: this.props.shortName, role: this.state.role } this.props.permissionActions.addPermission(data).then(requestMessage => { if (requestMessage) { // report to the user is there was a problem during registration this.setState({ error: requestMessage }); //this.props.onClose(false); } else { this.setState({ error: "" }); this.props.onClose(true); } }); //} } render() { const railStyle = { top: "15px", minHeight: "200px" }; var errorMessage = ""; if (this.state.error) { errorMessage = ( That didn't work...

{this.state.error}

) } return ( Select Role
Add User Access to System: {this.props.shortName} = 0) && (this.state.role < 10)} onChange={this.handleInputChange} /> = 10) && (this.state.role < 20)} onChange={this.handleInputChange} />
{errorMessage}
); } } export default AddPermissionModal;