signup.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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(
  9. api.register,
  10. true
  11. );
  12. return (
  13. <Layout>
  14. <form className="form" onSubmit={submitHandler}>
  15. <div className="form-group">
  16. <label htmlFor="email" className="form-label">
  17. Email
  18. </label>
  19. <input
  20. type="email"
  21. name="email"
  22. id="email"
  23. className="form-input"
  24. placeholder="monkey@gmail.com"
  25. required
  26. />
  27. </div>
  28. <div className="form-group">
  29. <label htmlFor="password" className="form-label">
  30. Password
  31. </label>
  32. <input
  33. type="password"
  34. name="password"
  35. id="password"
  36. className="form-input"
  37. minLength={6}
  38. placeholder="••••••"
  39. required
  40. />
  41. </div>
  42. <button
  43. type="submit"
  44. className="default-button col-start-2 w-max"
  45. disabled={loading}
  46. >
  47. {loading ? <Spinner /> : "Sign up"}
  48. </button>
  49. <FormResponse
  50. error={error}
  51. success={success}
  52. loading={loading}
  53. fallbackSuccessMessage="User created correctly! Please, log in to continue"
  54. />
  55. </form>
  56. </Layout>
  57. );
  58. };
  59. export default SignUp;