import React, { Component, FormEvent } from 'react'; import { wrappable, getChangeHandler } from 'wdk-client/Utils/ComponentUtils'; import Link from 'wdk-client/Components/Link/Link'; import Dialog from 'wdk-client/Components/Overlays/Dialog'; import TextBox from 'wdk-client/Components/InputControls/TextBox'; type Props = { onCancel: () => void; onSubmit: (email: string, password: string) => void; open: boolean; message?: string; passwordResetPath: string; registerPath: string; }; type State = { email: string, password: string } /** * Form used for authorizing against webapp instead of oauth server. */ class LoginForm extends Component { constructor(props: Props) { super(props); this.state = { email: '', password: '' }; this.submitForm = this.submitForm.bind(this); this.updateState = this.updateState.bind(this); } submitForm(e: FormEvent): void { e.preventDefault(); this.props.onSubmit(this.state.email, this.state.password); } updateState(newState: State): State { this.setState(newState); return newState; } render() { let { open, message, onCancel, passwordResetPath, registerPath } = this.props; let onChange = (name: string) => getChangeHandler(name, this.updateState, this.state); return open === false ? null : (
{message ? {message} : ""}
Username or Email:
Password:
Forgot Password? Register/Subscribe
); } } export default wrappable(LoginForm);