From 39164053ffe1485172f19c6ebf68caf15d299bab Mon Sep 17 00:00:00 2001 From: Jonny Date: Sun, 16 Jun 2019 19:10:04 +0200 Subject: [PATCH] Add warning popup for invalid values --- js/components/WarningPopup.js | 23 +++++++++++++++++++++++ pages/create.js | 20 +++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 js/components/WarningPopup.js diff --git a/js/components/WarningPopup.js b/js/components/WarningPopup.js new file mode 100644 index 0000000..a1196cc --- /dev/null +++ b/js/components/WarningPopup.js @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import {Alert} from 'reactstrap'; + +export class WarningPopup extends React.Component { + render() { + if (this.props.shown) { + return (
+ {this.props.children} + + {this.props.text} + +
); + } else { + return this.props.children; + } + } +} + +WarningPopup.propTypes = { + text: PropTypes.string.isRequired, + shown: PropTypes.bool.isRequired +} \ No newline at end of file diff --git a/pages/create.js b/pages/create.js index 1a81f1f..acbedb8 100644 --- a/pages/create.js +++ b/pages/create.js @@ -8,6 +8,7 @@ import {TurniereNavigation} from '../js/components/Navigation'; import {Footer} from '../js/components/Footer'; import EditableStringList from '../js/components/EditableStringList'; import {createTournament} from '../js/api'; +import {WarningPopup} from '../js/components/WarningPopup' import '../static/css/everypage.css'; import RequireLogin from '../js/components/RequireLogin'; @@ -50,7 +51,7 @@ function CreateTournamentCard() { const GroupphaseFader = posed.div({ visible: { - opacity: 1, height: 150 + opacity: 1, height: 200 }, hidden: { opacity: 0, height: 0 } @@ -118,11 +119,14 @@ class CreateTournamentForm extends React.Component { - - - + + + + + @@ -204,11 +208,13 @@ class CreateTournamentForm extends React.Component { }, () => { notify.show('Das Turnier konnte nicht erstellt werden.', 'warning', 5000); }); + } else { + notify.show('Bitte korrigiere deine Eingaben zuerst.', 'warning', 5000); } } valuesAreCredible() { - return this.state.groups.length >= this.state.groupAdvance; + return this.state.teams.length >= this.state.groupAdvance; } generateTournamentCreationObject() {