/*** @jsx React.DOM */
var account_management = createReactClass({
getInitialState: function(props) {
return {
email: window.email,
new_email: window.email,
email_password: '',
editing_email: false,
username: window.username,
editing_pin: false,
new_pin: '',
editing_password: false,
old_password: '',
new_password1: '',
new_password2: '',
};
},
componentDidUpdate: function() {
if (this.focus_element && this.focus_element != this.already_focused) {
this.focus_element.focus();
this.already_focused = this.focus_element;
}
},
saveEmail: function(event) {
AJAX.post(
Link.get('updateemail'),
{
email: this.state.new_email,
password: this.state.email_password,
},
function(response) {
this.setState({
email: response.email,
new_email: response.email,
email_password: '',
editing_email: false,
});
}.bind(this)
);
event.preventDefault();
},
savePin: function(event) {
AJAX.post(
Link.get('updatepin'),
{pin: this.state.new_pin},
function(response) {
this.setState({
new_pin: '',
editing_pin: false,
});
}.bind(this)
);
event.preventDefault();
},
savePassword: function(event) {
AJAX.post(
Link.get('updatepassword'),
{
old: this.state.old_password,
new1: this.state.new_password1,
new2: this.state.new_password2,
},
function(response) {
this.setState({
old_password: '',
new_password1: '',
new_password2: '',
editing_password: false,
});
}.bind(this)
);
event.preventDefault();
},
renderUsername: function() {
return (