'use strict'; import React from 'react'; import Router from 'react-router'; import { mergeOptions } from '../utils/general_utils'; import { getLangText } from '../utils/lang_utils'; import UserStore from '../stores/user_store'; import GlobalNotificationModel from '../models/global_notification_model'; import GlobalNotificationActions from '../actions/global_notification_actions'; import Form from './ascribe_forms/form'; import Property from './ascribe_forms/property'; import FormPropertyHeader from './ascribe_forms/form_property_header'; import InputCheckbox from './ascribe_forms/input_checkbox'; import apiUrls from '../constants/api_urls'; let SignupContainer = React.createClass({ mixins: [Router.Navigation], getInitialState() { return mergeOptions({ submitted: false, message: null }, UserStore.getState()); }, componentDidMount() { UserStore.listen(this.onChange); }, componentWillUnmount() { UserStore.unlisten(this.onChange); }, onChange(state) { this.setState(state); // if user is already logged in, redirect him to piece list if(this.state.currentUser && this.state.currentUser.email) { this.transitionTo('pieces'); } }, handleSuccess(message){ this.setState({ submitted: true, message: message }); }, render() { if (this.state.submitted){ return (

{this.state.message}
); } return (

); } }); let SignupForm = React.createClass({ propTypes: { handleSuccess: React.PropTypes.func }, mixins: [Router.Navigation], handleSuccess(response){ let notificationText = getLangText('Sign up successful'); let notification = new GlobalNotificationModel(notificationText, 'success', 50000); GlobalNotificationActions.appendGlobalNotification(notification); this.props.handleSuccess(getLangText('We sent an email to your address') + ' ' + response.user.email + ', ' + getLangText('please confirm') + '.'); }, getFormData(){ return {terms: this.refs.form.refs.terms.refs.input.state.value}; }, render() { let tooltipPassword = getLangText('Your password must be at least 10 characters') + '.\n ' + getLangText('This password is securing your digital property like a bank account') + '.\n ' + getLangText('Store it in a safe place') + '!'; return (
{getLangText('Sign up to ascribe')} } spinner={ }>

{getLangText('Welcome to ascribe')}

); } }); export default SignupContainer;