import React from 'react'; import { defineMessages, FormattedMessage as Message } from 'react-intl'; import { Helmet } from 'react-helmet-async'; import { Input, Button, Form, FormModel } from 'app/components/ui/form'; import { BackButton } from 'app/components/profile/ProfileForm'; import styles from '../profileForm.scss'; const labels = defineMessages({ changeUsernameButton: 'Change nickname', }); interface Props { username: string; form: FormModel; onChange: (name: string) => void; onSubmit: (form: FormModel) => Promise; } export default class ChangeUsername extends React.Component { static get defaultProps(): Partial { return { form: new FormModel(), }; } render() { const { form, username } = this.props; return (
{(pageTitle) => (

{pageTitle}

)}

); } onUsernameChange = (event: React.ChangeEvent) => { this.props.onChange(event.target.value); }; onFormSubmit = () => { const { form } = this.props; this.props.onSubmit(form).catch((resp) => { if (resp.errors) { form.setErrors(resp.errors); } else { return Promise.reject(resp); } }); }; }