signup.tsx 1.4 KB

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