Clear email field on send

This commit is contained in:
Dane Everitt 2019-06-16 15:24:20 -07:00
parent 19ef901768
commit 54cfe7e981
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 15 additions and 5 deletions

View File

@ -18,6 +18,8 @@ type State = Readonly<{
}>; }>;
class ForgotPasswordContainer extends React.PureComponent<Props, State> { class ForgotPasswordContainer extends React.PureComponent<Props, State> {
emailField = React.createRef<HTMLInputElement>();
state: State = { state: State = {
email: '', email: '',
isSubmitting: false, isSubmitting: false,
@ -33,9 +35,15 @@ class ForgotPasswordContainer extends React.PureComponent<Props, State> {
this.setState({ isSubmitting: true }, () => { this.setState({ isSubmitting: true }, () => {
this.props.clearAllFlashMessages(); this.props.clearAllFlashMessages();
requestPasswordResetEmail(this.state.email) requestPasswordResetEmail(this.state.email)
.then(response => this.props.pushFlashMessage({ .then(response => {
type: 'success', title: 'Success', message: response, if (this.emailField.current) {
})) this.emailField.current.value = '';
}
this.props.pushFlashMessage({
type: 'success', title: 'Success', message: response,
});
})
.catch(error => { .catch(error => {
console.error(error); console.error(error);
this.props.pushFlashMessage({ this.props.pushFlashMessage({
@ -54,6 +62,7 @@ class ForgotPasswordContainer extends React.PureComponent<Props, State> {
<form className={'login-box'} onSubmit={this.handleSubmission}> <form className={'login-box'} onSubmit={this.handleSubmission}>
<div className={'-mx-3'}> <div className={'-mx-3'}>
<OpenInputField <OpenInputField
ref={this.emailField}
id={'email'} id={'email'}
type={'email'} type={'email'}
label={'Email'} label={'Email'}

View File

@ -6,7 +6,7 @@ type Props = React.InputHTMLAttributes<HTMLInputElement> & {
description?: string; description?: string;
}; };
export default ({ className, description, onChange, label, ...props }: Props) => { export default React.forwardRef<HTMLInputElement, Props>(({ className, description, onChange, label, ...props }, ref) => {
const [ value, setValue ] = React.useState(''); const [ value, setValue ] = React.useState('');
const classes = classNames('input open-label', { const classes = classNames('input open-label', {
@ -16,6 +16,7 @@ export default ({ className, description, onChange, label, ...props }: Props) =>
return ( return (
<div className={'input-open'}> <div className={'input-open'}>
<input <input
ref={ref}
className={classes} className={classes}
onChange={e => { onChange={e => {
setValue(e.target.value); setValue(e.target.value);
@ -33,4 +34,4 @@ export default ({ className, description, onChange, label, ...props }: Props) =>
} }
</div> </div>
); );
}; });