import React from 'react'; import { gettext } from '../../utils/constants'; const { nameLabel, enableUpdateUserInfo, enableUserSetContactEmail } = window.app.pageOptions; class UserBasicInfoForm extends React.Component { constructor(props) { super(props); const { contact_email, login_id, name, telephone } = this.props.userInfo; this.state = { contactEmail: contact_email, loginID: login_id, name: name, telephone: telephone }; } handleNameInputChange = (e) => { this.setState({ name: e.target.value }); } handleContactEmailInputChange = (e) => { this.setState({ contactEmail: e.target.value }); } handleTelephoneInputChange = (e) => { this.setState({ telephone: e.target.value }); } handleSubmit = (e) => { e.preventDefault(); let data = { name: this.state.name, telephone: this.state.telephone }; if (enableUserSetContactEmail) { data.contact_email = this.state.contactEmail; } this.props.updateUserInfo(data); } render() { const { contactEmail, loginID, name, telephone } = this.state; return (
{loginID && (

{gettext('You can use this field at login.')}

)} {(contactEmail || enableUserSetContactEmail) && (

{gettext('Your notifications will be sent to this email.')}

)} {(telephone != undefined) && (
)}
); } } export default UserBasicInfoForm;