import React from 'react'; import cn from 'classnames'; import PropTypes from 'prop-types'; import styles from './ChangeUsername.css'; import { Button } from 'plugin-api/beta/client/components/ui'; import ChangeUsernameDialog from './ChangeUsernameDialog'; import { t } from 'plugin-api/beta/client/services'; import InputField from './InputField'; const initialState = { editing: false, showDialog: false, formData: {}, }; class ChangeUsername extends React.Component { state = initialState; clearForm = () => { this.setState(initialState); }; enableEditing = () => { this.setState({ editing: true, }); }; disableEditing = () => { this.setState({ editing: false, }); }; cancel = () => { this.clearForm(); this.disableEditing(); }; showDialog = () => { this.setState({ showDialog: true, }); }; onSave = async () => { this.showDialog(); }; saveChanges = async () => { // savechanges }; onChange = e => { const { name, value } = e.target; this.setState(state => ({ formData: { ...state.formData, [name]: value, }, })); }; closeDialog = () => { this.setState({ showDialog: false, }); }; render() { const { username, emailAddress } = this.props; const { editing } = this.state; return (
{editing ? (
{t('talk-plugin-auth.change_username.change_username_note')}
) : (

{username}

{emailAddress ? (

{emailAddress}

) : null}
)} {editing ? (
{t('talk-plugin-auth.change_username.cancel')}
) : (
)}
); } } ChangeUsername.propTypes = { changeUsername: PropTypes.func.isRequired, username: PropTypes.string, emailAddress: PropTypes.string, }; export default ChangeUsername;