mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-12-11 00:11:14 -05:00
c547a32282
This is one of the differences between React and Preact: https://preactjs.com/guide/v10/differences-to-react/#use-oninput-instead-of-onchange Closes: https://todo.sr.ht/~emersion/gamja/128
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import { html, Component } from "../lib/index.js";
|
|
import linkify from "../lib/linkify.js";
|
|
|
|
export default class RegisterForm extends Component {
|
|
state = {
|
|
code: "",
|
|
};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.handleInput = this.handleInput.bind(this);
|
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
}
|
|
|
|
handleInput(event) {
|
|
let target = event.target;
|
|
let value = target.type == "checkbox" ? target.checked : target.value;
|
|
this.setState({ [target.name]: value });
|
|
}
|
|
|
|
handleSubmit(event) {
|
|
event.preventDefault();
|
|
|
|
this.props.onSubmit(this.state.code);
|
|
}
|
|
|
|
render() {
|
|
return html`
|
|
<form onInput=${this.handleInput} onSubmit=${this.handleSubmit}>
|
|
<p>Your account <strong>${this.props.account}</strong> has been created, but a verification code is required to complete the registration.</p>
|
|
|
|
<p>${linkify(this.props.message)}</p>
|
|
|
|
<label>
|
|
Verification code:<br/>
|
|
<input type="text" name="code" value=${this.state.code} required autofocus autocomplete="off"/>
|
|
</label>
|
|
<br/><br/>
|
|
|
|
<button>Verify account</button>
|
|
</form>
|
|
`;
|
|
}
|
|
}
|