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

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

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

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

)}
); } } UserBasicInfoForm.propTypes = { updateUserInfo: PropTypes.func.isRequired, userInfo: PropTypes.object.isRequired, }; export default UserBasicInfoForm;