Guest User

Untitled

a guest
May 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import React from 'react';
  2. import { sendSignInLink } from '../api/session';
  3.  
  4. class Landing extends React.Component {
  5. state = {
  6. email: '',
  7. result: '',
  8. };
  9.  
  10. handleChange = (e) => {
  11. const email = e.target.value;
  12.  
  13. this.setState({
  14. email,
  15. });
  16. };
  17.  
  18. handleSubmit = (e) => {
  19. e.preventDefault();
  20.  
  21. sendSignInLink(this.state.email)
  22. .then((res) => {
  23. this.setState({
  24. result: res,
  25. });
  26. })
  27. .catch((err) => {
  28. this.setState({
  29. result: err.message,
  30. });
  31. });
  32. };
  33.  
  34. render() {
  35. return (
  36. <React.Fragment>
  37. <h1>I am the landing page!</h1>
  38. <form onSubmit={this.handleSubmit}>
  39. <label htmlFor="email">
  40. Sign In:
  41. <input
  42. value={this.state.email}
  43. onChange={this.handleChange}
  44. id="email"
  45. type="text"
  46. name="email"
  47. />
  48. </label>
  49. <input type="submit" value="Submit" />
  50. {this.state.result}
  51. </form>
  52. </React.Fragment>
  53. );
  54. }
  55. }
  56.  
  57. export default Landing;
Add Comment
Please, Sign In to add comment