import { Component, linkEvent } from 'inferno'; import { LoginForm, RegisterForm } from '../interfaces'; import { WebSocketService } from '../services'; interface State { loginForm: LoginForm; registerForm: RegisterForm; } let emptyState: State = { loginForm: { username: null, password: null }, registerForm: { username: null, password: null, password_verify: null } } export class Login extends Component { constructor(props, context) { super(props, context); this.state = emptyState; } render() { return (
{this.loginForm()}
{this.registerForm()}
) } loginForm() { return (

Login

Forgot your password or deleted your account? Reset your password. TODO
); } registerForm() { return (

Sign Up

); } handleLoginSubmit(i: Login, event) { console.log(i.state); event.preventDefault(); WebSocketService.Instance.login(i.state.loginForm); } handleLoginUsernameChange(i: Login, event) { i.state.loginForm.username = event.target.value; } handleLoginPasswordChange(i: Login, event) { i.state.loginForm.password = event.target.value; } handleRegisterSubmit(i: Login, event) { console.log(i.state); event.preventDefault(); WebSocketService.Instance.register(i.state.registerForm); } handleRegisterUsernameChange(i: Login, event) { i.state.registerForm.username = event.target.value; } handleRegisterEmailChange(i: Login, event) { i.state.registerForm.email = event.target.value; } handleRegisterPasswordChange(i: Login, event) { i.state.registerForm.password = event.target.value; } handleRegisterPasswordVerifyChange(i: Login, event) { i.state.registerForm.password_verify = event.target.value; } }