import React from 'react'; import { Alert, Button, Card, CardBody, CardTitle, CardText, Input, InputGroup, InputGroupAddon } from 'reactstrap'; import '../../static/css/editablestringlist.css'; export default class EditableStringList extends React.Component { constructor(props) { super(props); this.state = { teams: props.teams, groups: props.groups }; this.add = this.add.bind(this); this.remove = this.remove.bind(this); } add(text) { if (text === '' || this.state.teams.includes(text)) { return false; } this.state.teams.push(text); var lastGroup = this.state.groups[this.state.groups.length - 1]; if(lastGroup === undefined || lastGroup.length === this.props.groupSize) { this.state.groups[this.state.groups.length] = []; } lastGroup = this.state.groups[this.state.groups.length - 1]; lastGroup[lastGroup.length] = text; this.setState({ teams: this.state.teams, groups: this.state.groups }); this.props.onTeamsChange(this.state.teams); this.props.onGroupsChange(this.state.groups); return true; } remove(text) { let tmp = this.state.teams.filter(item => item !== text); this.setState({teams: tmp}); this.props.onTeamsChange(tmp); } render() { if(this.props.groupPhaseEnabled) { if ((typeof this.state.teams !== 'undefined') && this.state.teams.length > 0) { return (