1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 17:12:30 +01:00

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

View File

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