import Head from 'next/head'; import React from 'react'; import 'bootstrap/dist/css/bootstrap.min.css'; import { connect } from 'react-redux'; import { notify } from 'react-notify-toast'; import { requestTournament } from '../js/api'; import { BigImage, Footer, TurniereNavigation, Login, UserRestrictor, Option } from '../js/CommonComponents.js'; import { ErrorPageComponent } from '../js/components/ErrorComponents.js'; import { Container, Button, Card, CardBody, Table } from 'reactstrap'; import { verifyCredentials, updateTeamName } from '../js/api'; import '../static/everypage.css'; import '../static/css/index.css'; class EditTournamentPage extends React.Component { static async getInitialProps({query}) { return {query}; } constructor(props) { super(props); this.state = { validCode: false }; } componentDidMount() { verifyCredentials(); requestTournament(this.props.query.code, () => { this.setState({ validCode: true }); if(this._edittournamentcontent != null) { this._edittournamentcontent.notifyOfContentUpdate(); } }, () => { this.setState({ validCode: false }); }); } render() { const { validCode } = this.state; const { tournamentname, ownerUsername, isSignedIn, username } = this.props; return ( ); } } function mapStateToTournamentInfo(state) { const { tournamentname, ownerUsername } = state.tournamentinfo; const { isSignedIn, username } = state.userinfo; return { tournamentname, ownerUsername, isSignedIn, username }; } export default connect( mapStateToTournamentInfo )(EditTournamentPage); class EditTournamentContent extends React.Component { render() { return (
{ this._edittournamentpropertiesfield = field; }}/> { this._editteamfield = field; }}/>
); } notifyOfContentUpdate() { this._edittournamentpropertiesfield.notifyOfContentUpdate(); this._editteamfield.notifyOfContentUpdate(); } } function ReturnToTournamentButton() { return ( ); } class EditTournamentPropertiesField extends React.Component { render() { return (

Turnier-Eigenschaften ändern

{ this._visibleedittournamentform = form; }}/>
); } notifyOfContentUpdate() { this._visibleedittournamentform.getWrappedInstance().notifyOfContentUpdate(); } } class EditTournamentForm extends React.Component { constructor(props) { super(props); this.state = { name : '', description : '', isPublic : false }; } render() { const { name, description, isPublic } = this.state; return (
); } notifyOfContentUpdate() { const { name, description, isPublic } = this.props; this.setState({ name : name? name : '', description : description? description : '', isPublic : isPublic }); } handleClick() { // TODO: Apply changes to the tournament properties } handleNameInput(input) { this.setState({ name : input.target.value }); } handleDescriptionInput(input) { this.setState({ description : input.target.value }); } handlePublicInput(input) { this.setState({ public : input.target.value }); } } function mapStateToTournamentFormProps(state) { const { name, description, isPublic } = state.tournamentinfo; return { name, description, isPublic }; } const VisibleEditTournamentForm = connect( mapStateToTournamentFormProps, null, null, { withRef : true} )(EditTournamentForm); class EditTeamField extends React.Component { render() { return (

Team-Namen ändern

{ this._visibleeditteamnamesform = form; }}/>
); } notifyOfContentUpdate() { this._visibleeditteamnamesform.getWrappedInstance().notifyOfContentUpdate(); } } class EditTeamNamesForm extends React.Component { constructor(props) { super(props); this.state = { teams : [] }; } render() { const { teams } = this.state; return (
{ teams.map((team, index) => ) }
); } notifyOfContentUpdate() { const { teams } = this.props; this.setState({ teams : teams }); } handleNameInput(index, input) { var team = this.state.teams.slice(); team[index].name = input.target.value; this.setState({ teams : team }); } handleClick(index) { updateTeamName(this.state.teams[index], () => { notify.show('Team Name wurde erfolgreich geändert.', 'success', 5000); }, () => { notify.show('Team Name konnte nicht geändert werden.', 'warning', 5000); }); } } function mapStateToTeamFormProps(state) { const { teams } = state.tournamentinfo; return { teams }; } const VisibleEditTeamNamesForm = connect( mapStateToTeamFormProps, null, null, { withRef : true } )(EditTeamNamesForm);