import Alert from "../elements/alert"; import {Link} from "react-router-dom"; import * as React from "react"; import Icon from "../elements/icon"; import ReactTooltip from "react-tooltip"; import 'rc-color-picker/assets/index.css'; import ColorPicker from 'rc-color-picker'; export default class CreateGroup extends React.Component { constructor(props) { super(props); this.state = { alerts: [], isSubmitting: false, name: "", color: "#0F0" }; this.parent = { api: props.api, }; } removeAlert(i) { if (i >= 0 && i < this.state.alerts.length) { let alerts = this.state.alerts.slice(); alerts.splice(i, 1); this.setState({...this.state, alerts: alerts}); } } render() { let alerts = []; for (let i = 0; i < this.state.alerts.length; i++) { alerts.push( this.removeAlert(i)} {...this.state.alerts[i]}/>) } return <>

Create a new group

  1. Home
  2. Users
  3. Add User
{alerts}
this.submitForm(e)}>
 Back {this.state.isSubmitting ? : }
; } onChangeColor(e) { this.setState({...this.state, color: e.color}); } onChangeInput(event) { const target = event.target; const value = target.value; const name = target.name; this.setState({...this.state, [name]: value}); } submitForm(e) { e.preventDefault(); const name = this.state.name; const color = this.state.color; this.setState({...this.state, isSubmitting: true}); this.parent.api.createGroup(name, color).then((res) => { let alerts = this.state.alerts.slice(); if (res.success) { alerts.push({message: "Group was successfully created", title: "Success!", type: "success"}); this.setState({...this.state, name: "", color: "", alerts: alerts, isSubmitting: false}); } else { alerts.push({message: res.msg, title: "Error creating Group", type: "danger"}); this.setState({...this.state, alerts: alerts, isSubmitting: false}); } }); } }