From 70047a2e551e8774b26d5e6ddcd4041a35ba87d0 Mon Sep 17 00:00:00 2001 From: Jonny Date: Tue, 18 Jun 2019 13:49:12 +0200 Subject: [PATCH 1/2] Add notifications and redirect after trying to register --- js/api.js | 8 ++++++-- pages/register.js | 14 +++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/js/api.js b/js/api.js index 6eb486c..b440bde 100644 --- a/js/api.js +++ b/js/api.js @@ -50,6 +50,7 @@ const reducerUserinfo = (state = defaultStateUserinfo, action) => { __store.dispatch({ type: actionTypesUserinfo.REGISTER_RESULT_SUCCESS }); + action.parameters.successCallback(); storeOptionalToken(resp); }).catch(error => { if (error.response) { @@ -70,6 +71,7 @@ const reducerUserinfo = (state = defaultStateUserinfo, action) => { } }); } + action.parameters.errorCallback(); }); return Object.assign({}, state, {}); case actionTypesUserinfo.REGISTER_RESULT_SUCCESS: @@ -357,13 +359,15 @@ export function verifyCredentials() { } } -export function register(username, email, password) { +export function register(username, email, password, successCallback, errorCallback) { __store.dispatch({ type: actionTypesUserinfo.REGISTER, parameters: { username: username, email: email, - password: password + password: password, + successCallback: successCallback, + errorCallback: errorCallback }, state: __store.getState() }); diff --git a/pages/register.js b/pages/register.js index b7fc0ca..83506e6 100644 --- a/pages/register.js +++ b/pages/register.js @@ -1,6 +1,8 @@ import Head from 'next/head'; import React from 'react'; import {connect} from 'react-redux'; +import {notify} from 'react-notify-toast'; +import Router from 'next/router'; import { Button, Card, CardBody, Container, Form, FormGroup, FormText, Input, Label } from 'reactstrap'; @@ -95,12 +97,22 @@ class RegisterForm extends React.Component { Du akzeptierst die Datenschutzbestimmungen, wenn du auf Registrieren klickst. - ); } + registerUser() { + register( + this.state.username, this.state.email, this.state.password, () => { + notify.show('Sie wurden erfolgreich registriert, ' + this.state.username + '!', 'success', 5000); + Router.push('/'); + }, () => { + notify.show('Sie konnten nicht registriert werden.', 'warning', 5000); + }); + } + handlePasswordInput(input) { this.setState({password: input.target.value}); } From 8baa6fe9f07d417cd90f5bccb2c849a0c1dabffb Mon Sep 17 00:00:00 2001 From: Jonny Date: Tue, 18 Jun 2019 16:06:53 +0200 Subject: [PATCH 2/2] Add modal to describe registration process instead of a toast --- pages/register.js | 51 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/pages/register.js b/pages/register.js index 83506e6..2d84200 100644 --- a/pages/register.js +++ b/pages/register.js @@ -1,10 +1,12 @@ import Head from 'next/head'; import React from 'react'; +import PropTypes from 'prop-types'; import {connect} from 'react-redux'; import {notify} from 'react-notify-toast'; import Router from 'next/router'; import { - Button, Card, CardBody, Container, Form, FormGroup, FormText, Input, Label + Button, Card, CardBody, Container, Form, FormGroup, FormText, Input, Label, + Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import {TurniereNavigation} from '../js/components/Navigation'; @@ -71,12 +73,15 @@ class RegisterForm extends React.Component { super(props); this.state = { - username: '', email: '', password: '' + username: '', email: '', password: '', + showRegisterSuccessModal: false, code: -1 }; } render() { return (
+ this.closeRegisterSuccessModal()}/> @@ -103,14 +108,22 @@ class RegisterForm extends React.Component { ); } + showRegisterSuccessModal() { + this.setState({ + showRegisterSuccessModal: true + }); + } + + closeRegisterSuccessModal() { + Router.push('/'); + } + registerUser() { - register( - this.state.username, this.state.email, this.state.password, () => { - notify.show('Sie wurden erfolgreich registriert, ' + this.state.username + '!', 'success', 5000); - Router.push('/'); - }, () => { - notify.show('Sie konnten nicht registriert werden.', 'warning', 5000); - }); + register(this.state.username, this.state.email, this.state.password, () => { + this.showRegisterSuccessModal(); + }, () => { + notify.show('Sie konnten nicht registriert werden.', 'warning', 5000); + }); } handlePasswordInput(input) { @@ -126,6 +139,26 @@ class RegisterForm extends React.Component { } } +class RegisterSuccessModal extends React.Component { + render() { + return ( + Erfolgreich registriert + + Sie wurden erfolgreich registriert. Um Ihren Account nutzen zu können + müssen Sie den Verifizierungslink, den wir Ihnen per E-Mail zugesandt haben, aufrufen. + + + + + ); + } +} + +RegisterSuccessModal.proptypes = { + isOpen: PropTypes.bool.isRequired, + close: PropTypes.func.isRequired +}; + function AccountRequirementMarketing() { return (