MCPcopy Create free account
hub / github.com/apollographql/fullstack-tutorial / LoginForm

Class LoginForm

final/client/src/components/login-form.tsx:22–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22export 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected