login.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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
  13. className="form"
  14. onSubmit={submitHandler}
  15. >
  16. <div className="xs:contents">
  17. <label htmlFor="email" className="form-label">
  18. Email
  19. </label>
  20. <input
  21. type="email"
  22. name="email"
  23. id="email"
  24. className="form-input"
  25. placeholder="monkey@gmail.com"
  26. required
  27. />
  28. </div>
  29. <div className="xs:contents">
  30. <label htmlFor="password" className="form-label">
  31. Password
  32. </label>
  33. <input
  34. type="password"
  35. name="password"
  36. id="password"
  37. className="form-input"
  38. placeholder="••••••"
  39. required
  40. />
  41. </div>
  42. <button
  43. type="submit"
  44. className="form-button"
  45. >
  46. Log in
  47. </button>
  48. {error && (
  49. <div
  50. role="alert"
  51. className="col-span-2 bg-red-200 p-4 text-center rounded font-bold text-red-900"
  52. >
  53. {error.message}
  54. </div>
  55. )}
  56. </form>
  57. </Layout>
  58. );
  59. };
  60. export default Login;