|
@@ -0,0 +1,58 @@
|
|
|
|
|
+import { NextPage } from "next";
|
|
|
|
|
+import Layout from "../components/Layout";
|
|
|
|
|
+import useForm from "../hooks/useForm";
|
|
|
|
|
+import { ApiMethods, ApiPaths } from "../utils/api";
|
|
|
|
|
+
|
|
|
|
|
+const SignUp: NextPage = () => {
|
|
|
|
|
+ const { submitHandler, error } = useForm({
|
|
|
|
|
+ path: ApiPaths.SignUp,
|
|
|
|
|
+ method: ApiMethods.POST,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Layout>
|
|
|
|
|
+ <form className="form" onSubmit={submitHandler}>
|
|
|
|
|
+ <div className="xs:contents">
|
|
|
|
|
+ <label htmlFor="email" className="form-label">
|
|
|
|
|
+ Email
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="email"
|
|
|
|
|
+ name="email"
|
|
|
|
|
+ id="email"
|
|
|
|
|
+ className="form-input"
|
|
|
|
|
+ placeholder="monkey@gmail.com"
|
|
|
|
|
+ required
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="xs:contents">
|
|
|
|
|
+ <label htmlFor="password" className="form-label">
|
|
|
|
|
+ Password
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="password"
|
|
|
|
|
+ name="password"
|
|
|
|
|
+ id="password"
|
|
|
|
|
+ className="form-input"
|
|
|
|
|
+ minLength={6}
|
|
|
|
|
+ placeholder="••••••"
|
|
|
|
|
+ required
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <button type="submit" className="form-button">
|
|
|
|
|
+ Sign up
|
|
|
|
|
+ </button>
|
|
|
|
|
+ {error && (
|
|
|
|
|
+ <div
|
|
|
|
|
+ role="alert"
|
|
|
|
|
+ className="col-span-2 bg-red-200 p-4 text-center rounded font-bold text-red-900"
|
|
|
|
|
+ >
|
|
|
|
|
+ {error.message}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </Layout>
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+export default SignUp;
|