import React, {Component, PropTypes} from 'react'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from 'coral-framework/translations.json'; const lang = new I18n(translations); import styles from './RestrictedContent.css'; import {Button} from 'coral-ui'; import validate from '../helpers/validate'; class SuspendedAccount extends Component { static propTypes = { canEditName: PropTypes.bool, editName: PropTypes.func.isRequired } state = { username: '', alert: '' } onSubmitClick = (e) => { const {editName} = this.props; const {username} = this.state; e.preventDefault(); if (validate.username(username)) { editName(username) .then(() => location.reload()) .catch((error) => { this.setState({alert: lang.t(`error.${error.translation_key}`)}); }); } else { this.setState({alert: lang.t('editName.error')}); } } render () { const {canEditName} = this.props; const {username, alert} = this.state; return
{ canEditName ? lang.t('editName.msg') : lang.t('bannedAccountMsg') } { canEditName ?
{alert}
this.setState({username: e.target.value})} rows={3}/>
: null }
; } } export default SuspendedAccount;