'use strict';
import React from 'react';
import Router from 'react-router';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
import apiUrls from '../constants/api_urls';
import GlobalNotificationModel from '../models/global_notification_model';
import GlobalNotificationActions from '../actions/global_notification_actions';
let PasswordResetContainer = React.createClass({
mixins: [Router.Navigation],
getInitialState() {
return {isRequested: false};
},
handleRequestSuccess(email){
this.setState({isRequested: email});
},
render() {
if (this.props.query.email && this.props.query.token) {
return (
Reset the password for {this.props.query.email}
);
}
else {
if (this.state.isRequested === false) {
return (
Reset your ascribe password
);
}
else if (this.state.isRequested) {
return (
An email has been sent to "{this.state.isRequested}"
);
}
else {
return ;
}
}
}
});
let PasswordRequestResetForm = React.createClass({
handleSuccess() {
let notificationText = 'Request succesfully sent, check your email';
let notification = new GlobalNotificationModel(notificationText, 'success', 50000);
GlobalNotificationActions.appendGlobalNotification(notification);
this.props.handleRequestSuccess(this.refs.form.refs.email.state.value);
},
render() {
return (
);
}
});
let PasswordResetForm = React.createClass({
mixins: [Router.Navigation],
getFormData(){
let data = {};
for (let ref in this.refs.form.refs){
data[this.refs.form.refs[ref].props.name] = this.refs.form.refs[ref].state.value;
}
data.email = this.props.email;
data.token = this.props.token;
return data;
},
handleSuccess() {
this.transitionTo('pieces');
let notification = new GlobalNotificationModel('password succesfully updated', 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
render() {
return (
);
}
});
export default PasswordResetContainer;