import React from 'react'; import PropTypes from 'prop-types'; import i18next from 'i18next'; import { translate } from 'react-i18next'; class InstallerForm extends React.Component { constructor(props) { super(props); this.state = { isValidUserName: true, }; this.checkUserName = this.checkUserName.bind(this); } checkUserName(e) { $.getJSON('/_api/check_username', {username: e.target.value}, function(json) { this.setState({ isValidUserName: json.valid }); }.bind(this)); } changeLanguage(locale) { i18next.changeLanguage(locale); } render() { const hasErrorClass = this.state.isValidUserName ? '' : ' has-error'; const unavailableUserId = this.state.isValidUserName ? '' : { this.props.t('installer.unavaliable_user_id') }; return (

{ this.props.t('installer.create_initial_account') }
{ this.props.t('installer.initial_account_will_be_administrator_automatically') }

{ unavailableUserId }

this.changeLanguage('en-US')} />
this.changeLanguage('ja')} />
); } } InstallerForm.propTypes = { // i18next t: PropTypes.func.isRequired, // for input value userName: PropTypes.string, name: PropTypes.string, email: PropTypes.string, csrf: PropTypes.string, }; export default translate()(InstallerForm);