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});
}