import {Button, Card, CardBody, Col, Collapse, Row, Table} from 'reactstrap'; import {Match} from './Match'; import React, {Component} from 'react'; import {getGroup} from '../redux/tournamentApi'; import {notify} from 'react-notify-toast'; import {sortMatchesByPositionAscending} from '../utils/sorting'; import {FaChevronDown} from 'react-icons/fa6'; export default class GroupStage extends Component { constructor(props) { super(props); this.groupRefs = this.props.groups.reduce((acc, group) => { acc[group.id] = React.createRef(); return acc; }, {}); } render() { return (

Gruppenphase

{this.props.groups.map(group => ( ))}
); } } function ShowMatchesToggleChevron(props) { const toggleClass = props.show ? 'rotate' : ''; return ( ); } export class Group extends Component { constructor(props) { super(props); this.state = { ...props.group, showMatches: false }; this.reload = this.reload.bind(this); this.handleToggle = this.handleToggle.bind(this); this.onReloadSuccess = this.onReloadSuccess.bind(this); this.onReloadError = this.onReloadError.bind(this); } handleToggle() { this.setState(prevState => ({ showMatches: !prevState.showMatches })); if (this.props.groupRef.current) { this.props.groupRef.current.scrollIntoView({behavior: 'smooth', block: 'center'}); } } reload() { getGroup(this.state.id, this.onReloadSuccess, this.onReloadError); } onReloadSuccess(status, updatedGroup) { this.setState(updatedGroup); } onReloadError() { notify.show('Die Gruppe konnte nicht aktualisiert werden.', 'warning', 2000); } render() { return (

Gruppe {this.state.number}

{this.state.matches.sort(sortMatchesByPositionAscending()).map(match => ( ))}
); } } function GroupScoresTable(props) { return ( {props.scores.map(groupScore => )}
# Team Pkt. Dif. Gew.
); } function GroupScoresTableRow(props) { const teamId = `favorite-team-groupstage-${props.score.team.id}`; return ( {props.score.position} {props.score.team.name} {props.score.group_points} {props.score.difference_in_points} {props.score.scored_points} ); }