| 20 | } |
| 21 | |
| 22 | export default class LoginForm extends Component<LoginFormProps, LoginFormState> { |
| 23 | state = { email: '' }; |
| 24 | |
| 25 | onChange = (event: React.ChangeEvent<HTMLInputElement>) => { |
| 26 | const email = (event.target as HTMLInputElement).value; |
| 27 | this.setState((s) => ({ email })); |
| 28 | }; |
| 29 | |
| 30 | onSubmit = (event: React.FormEvent<HTMLFormElement>) => { |
| 31 | event.preventDefault(); |
| 32 | this.props.login({ variables: { email: this.state.email } }); |
| 33 | }; |
| 34 | |
| 35 | render() { |
| 36 | return ( |
| 37 | <Container> |
| 38 | <Header> |
| 39 | <StyledCurve /> |
| 40 | <StyledLogo /> |
| 41 | </Header> |
| 42 | <StyledRocket /> |
| 43 | <Heading>Space Explorer</Heading> |
| 44 | <StyledForm onSubmit={(e) => this.onSubmit(e)}> |
| 45 | <StyledInput required type="email" name="email" placeholder="Email" data-testid="login-input" onChange={(e) => this.onChange(e)} /> |
| 46 | <Button type="submit">Log in</Button> |
| 47 | </StyledForm> |
| 48 | </Container> |
| 49 | ); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * STYLED COMPONENTS USED IN THIS FILE ARE BELOW HERE |
nothing calls this directly
no outgoing calls
no test coverage detected