signup.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { NextPage } from "next";
  2. import FormResponse from "../components/FormResponse";
  3. import Layout from "../components/Layout";
  4. import Spinner from "../components/Spinner";
  5. import useForm from "../hooks/useForm";
  6. import api from "../utils/api";
  7. const SignUp: NextPage = () => {
  8. const { submitHandler, error, success, loading } = useForm(api.register);
  9. return (
  10. <Layout>
  11. <form className="form" onSubmit={submitHandler}>
  12. <div className="form-group">
  13. <label htmlFor="email" className="form-label">
  14. Email
  15. </label>
  16. <input
  17. type="email"
  18. name="email"
  19. id="email"
  20. className="form-input"
  21. placeholder="monkey@gmail.com"
  22. required
  23. />
  24. </div>
  25. <div className="form-group">
  26. <label htmlFor="password" className="form-label">
  27. Password
  28. </label>
  29. <input
  30. type="password"
  31. name="password"
  32. id="password"
  33. className="form-input"
  34. minLength={6}
  35. placeholder="••••••"
  36. required
  37. />
  38. </div>
  39. <button type="submit" className="form-button" disabled={loading}>
  40. {loading ? <Spinner /> : "Sign up"}
  41. </button>
  42. <FormResponse
  43. error={error}
  44. success={success}
  45. loading={loading}
  46. fallbackSuccessMessage="User created correctly! Please, log in to continue"
  47. />
  48. </form>
  49. </Layout>
  50. );
  51. };
  52. export default SignUp;