From 778d0173024293ea3fa2e39b1f216c0c9c2efd4c Mon Sep 17 00:00:00 2001 From: Felix Hamme Date: Wed, 19 Jun 2019 18:55:04 +0200 Subject: [PATCH] Continuing merge: link tournament view, edit and statistics pages between each other, use new design from merged branch --- js/components/TournamentBigImage.js | 22 +++++ js/components/TournamentInformationView.js | 105 --------------------- js/components/TournamentStatusBar.js | 29 ++++++ js/redux/tournamentStatistics.js | 2 +- pages/tournament-statistics.js | 28 ++++-- pages/tournament.js | 56 +++-------- 6 files changed, 81 insertions(+), 161 deletions(-) create mode 100644 js/components/TournamentBigImage.js delete mode 100644 js/components/TournamentInformationView.js create mode 100644 js/components/TournamentStatusBar.js diff --git a/js/components/TournamentBigImage.js b/js/components/TournamentBigImage.js new file mode 100644 index 0000000..ed304f0 --- /dev/null +++ b/js/components/TournamentBigImage.js @@ -0,0 +1,22 @@ +import {Container, ListGroup, ListGroupItem} from 'reactstrap'; +import React from 'react'; + +export function TournamentBigImage(props) { + return (
+

{props.name}

+ + + +
); +} + +function TournamentProperties(props) { + return ( + {props.description && {props.description}} + + {props.isPublic ? 'Das Turnier ist öffentlich.' : 'Das Turnier ist privat.'} + + Turnier-Code: {props.code} + von {props.ownerUsername} + ); +} diff --git a/js/components/TournamentInformationView.js b/js/components/TournamentInformationView.js deleted file mode 100644 index b31c695..0000000 --- a/js/components/TournamentInformationView.js +++ /dev/null @@ -1,105 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import { - Button, - ButtonGroup, - Col, - Container, - ListGroup, - ListGroupItem, - Row -} from 'reactstrap'; - - -class PrivateTournamentInformationView extends React.Component { - render() { - const {tournament, isSignedIn, username, currentpage} = this.props; - - return ( - - - - -

{tournament.description}

- - - - - {tournament.isPublic ? 'Das Turnier ist öffentlich.' : 'Das Turnier ist privat.'} - - Turnier-Code: {tournament.code} - von {tournament.owner_username} - - -
-
- ); - } -} - -function mapStateToPrivateTournamentInformationViewProps(state) { - const {isSignedIn, username} = state.userinfo; - return {isSignedIn, username}; -} - -export const TournamentInformationView = connect( - mapStateToPrivateTournamentInformationViewProps -)(PrivateTournamentInformationView); - -function ButtonsBadge(props) { - const {id, ownerName, isSignedIn, username, currentpage} = props; - - switch (currentpage) { - case 'statistics': - return ( - - - - - ); - case 'tournament': - return ( - - - - - ); - case 'edit': - return ( - - - - - ); - default: return null; - } -} - -function TournamentButton(props) { - const {id} = props; - return ; -} - -function EditButton(props) { - const {id, ownerName, isSignedIn, username} = props; - - if (isSignedIn && ownerName === username) { - return ( - - ); - } else { - return null; - } -} - -function StatisticsButton(props) { - const {id} = props; - return ; -} - diff --git a/js/components/TournamentStatusBar.js b/js/components/TournamentStatusBar.js new file mode 100644 index 0000000..0fd018a --- /dev/null +++ b/js/components/TournamentStatusBar.js @@ -0,0 +1,29 @@ +import Navbar from 'react-bootstrap/Navbar'; +import {Container} from 'reactstrap'; +import React from 'react'; + +export function TournamentStatusBar(props) { + return ( + + {props.children} + + ); +} + +export function TournamentStatusBarButton(props) { + return ( + {props.children} + ); +} + +export function EditButton(props) { + const {tournamentId, isOwner, isSignedIn} = props; + + if (isSignedIn && isOwner) { + return ( + Turnier bearbeiten + ); + } else { + return null; + } +} diff --git a/js/redux/tournamentStatistics.js b/js/redux/tournamentStatistics.js index 4d426ec..4004982 100644 --- a/js/redux/tournamentStatistics.js +++ b/js/redux/tournamentStatistics.js @@ -30,7 +30,7 @@ export function transformTournamentInfoToStatistics(data) { description: data.description, id: data.id, name: data.name, - owner_username: data.owner_username, + ownerUsername: data.owner_username, isPublic: data.public }; } diff --git a/pages/tournament-statistics.js b/pages/tournament-statistics.js index 1fb27bb..0beb23b 100644 --- a/pages/tournament-statistics.js +++ b/pages/tournament-statistics.js @@ -1,19 +1,16 @@ import Head from 'next/head'; import React from 'react'; import {connect} from 'react-redux'; -import { - Col, - Container, - Row -} from 'reactstrap'; +import {Col, Container, Row} from 'reactstrap'; import {TurniereNavigation} from '../js/components/Navigation'; -import {TournamentInformationView} from '../js/components/TournamentInformationView'; -import {BigImage} from '../js/components/BigImage'; import {StandingsTable} from '../js/components/StandingsTable'; import {DominanceShower} from '../js/components/DominanceShower'; import {Footer} from '../js/components/Footer'; import {requestTournamentStatistics} from '../js/api'; +import {EditButton, TournamentStatusBar, TournamentStatusBarButton} from '../js/components/TournamentStatusBar'; +import Navbar from 'react-bootstrap/Navbar'; +import {TournamentBigImage} from '../js/components/TournamentBigImage'; class StatisticsTournamentPage extends React.Component { static async getInitialProps({query}) { @@ -33,9 +30,19 @@ class StatisticsTournamentPage extends React.Component { {tournamentStatistics.name}: turnie.re - + + + + {tournamentStatistics.name} + + + zurück zum Turnier + + +
-