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