diff --git a/app/gabsocial/actions/auth.js b/app/gabsocial/actions/auth.js
index 3d1695aaa..4e2e5a61c 100644
--- a/app/gabsocial/actions/auth.js
+++ b/app/gabsocial/actions/auth.js
@@ -6,6 +6,10 @@ export const AUTH_APP_AUTHORIZED = 'AUTH_APP_AUTHORIZED';
export const AUTH_LOGGED_IN = 'AUTH_LOGGED_IN';
export const AUTH_LOGGED_OUT = 'AUTH_LOGGED_OUT';
+export const AUTH_REGISTER_REQUEST = 'AUTH_REGISTER_REQUEST';
+export const AUTH_REGISTER_SUCCESS = 'AUTH_REGISTER_SUCCESS';
+export const AUTH_REGISTER_FAIL = 'AUTH_REGISTER_FAIL';
+
export function createAuthApp() {
return (dispatch, getState) => {
const appToken = getState().getIn(['auth', 'app', 'access_token']);
@@ -57,6 +61,17 @@ export function logOut() {
};
}
+export function register(params) {
+ return (dispatch, getState) => {
+ dispatch({ type: AUTH_REGISTER_REQUEST });
+ return api(getState).post('/api/v1/accounts', params).then(response => {
+ dispatch({ type: AUTH_REGISTER_SUCCESS, response });
+ }).catch(error => {
+ dispatch({ type: AUTH_REGISTER_FAIL, error });
+ });
+ };
+}
+
export function authAppCreated(app) {
return {
type: AUTH_APP_CREATED,
diff --git a/app/gabsocial/features/forms/index.js b/app/gabsocial/features/forms/index.js
index fed8deb8e..00382806f 100644
--- a/app/gabsocial/features/forms/index.js
+++ b/app/gabsocial/features/forms/index.js
@@ -115,7 +115,7 @@ FieldsGroup.propTypes = {
};
export const Checkbox = props => (
-
+
);
export class RadioGroup extends ImmutablePureComponent {
diff --git a/app/gabsocial/features/landing_page/components/registration_form.js b/app/gabsocial/features/landing_page/components/registration_form.js
index c50abecfc..1fa7f596a 100644
--- a/app/gabsocial/features/landing_page/components/registration_form.js
+++ b/app/gabsocial/features/landing_page/components/registration_form.js
@@ -9,6 +9,7 @@ import {
TextInput,
Checkbox,
} from 'gabsocial/features/forms';
+import { register } from 'gabsocial/actions/auth';
const mapStateToProps = (state, props) => ({
instance: state.get('instance'),
@@ -21,8 +22,16 @@ class RegistrationForm extends ImmutablePureComponent {
instance: ImmutablePropTypes.map,
}
+ onInputChange = e => {
+ this.setState({ [e.target.name]: e.target.value });
+ }
+
+ onCheckboxChange = e => {
+ this.setState({ [e.target.name]: e.target.checked });
+ }
+
onSubmit = e => {
- // TODO: Dispatch action
+ this.props.dispatch(register(this.state));
}
render() {
@@ -38,6 +47,7 @@ class RegistrationForm extends ImmutablePureComponent {
placeholder='Username'
name='username'
autoComplete='off'
+ onChange={this.onInputChange}
required
/>
@@ -66,9 +79,11 @@ class RegistrationForm extends ImmutablePureComponent {
I agree to the Terms of Service.>}
name='agreement'
+ onChange={this.onCheckboxChange}
required
/>
+