login.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 Login: NextPage = () => {
  6. const { error, submitHandler } = useForm({
  7. path: ApiPaths.Login,
  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. placeholder="••••••"
  36. required
  37. />
  38. </div>
  39. <button type="submit" className="form-button">
  40. Log in
  41. </button>
  42. {error && (
  43. <div role="alert" className="form-alert-msg">
  44. {error.message}
  45. </div>
  46. )}
  47. </form>
  48. </Layout>
  49. );
  50. };
  51. export default Login;