Last active
February 19, 2023 14:07
-
-
Save dcortesnet/2a1ecbaba276a354d846cb8719082568 to your computer and use it in GitHub Desktop.
Nextjs manejo de formulario basico
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use client' | |
| import React from "react"; | |
| import signUp from "@/firebase/auth/signup"; | |
| import { useRouter } from 'next/navigation' | |
| function Page() { | |
| const [email, setEmail] = React.useState('') | |
| const [password, setPassword] = React.useState('') | |
| const router = useRouter() | |
| const handleForm = async (event) => { | |
| event.preventDefault() | |
| const { result, error } = await signUp(email, password); | |
| if (error) { | |
| return console.log(error) | |
| } | |
| console.log(result) | |
| return router.push("/admin") | |
| } | |
| return (<div className="wrapper"> | |
| <div className="form-wrapper"> | |
| <h1 className="mt-60 mb-30">Sign up</h1> | |
| <form onSubmit={handleForm} className="form"> | |
| <label htmlFor="email"> | |
| <p>Email</p> | |
| <input onChange={(e) => setEmail(e.target.value)} required type="email" name="email" id="email" placeholder="example@mail.com" /> | |
| </label> | |
| <label htmlFor="password"> | |
| <p>Password</p> | |
| <input onChange={(e) => setPassword(e.target.value)} required type="password" name="password" id="password" placeholder="password" /> | |
| </label> | |
| <button type="submit">Sign up</button> | |
| </form> | |
| </div> | |
| </div>); | |
| } | |
| export default Page;` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment