Download amazon-clone/src/Login.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.04 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/amazon-clone/src/Login.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/amazon-clone/src/Login.js
-
curl -L -o Login.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/amazon-clone/src/Login.js
2.04 kB
| import React, { useState } from "react"; | |
| import "./Login.css"; | |
| import { Link, useHistory } from "react-router-dom"; | |
| import { auth } from "./firebase"; | |
| function Login() { | |
| const history = useHistory(); | |
| const [email, setEmail] = useState(""); | |
| const [password, setPassword] = useState(""); | |
| const signIn = (e) => { | |
| e.preventDefault(); | |
| // firebase | |
| auth | |
| .signInWithEmailAndPassword(email, password) | |
| .then((auth) => { | |
| if (auth) { | |
| history.push("/"); | |
| } | |
| }) | |
| .catch((err) => alert(err.message)); | |
| }; | |
| const register = (e) => { | |
| e.preventDefault(); | |
| auth | |
| .createUserWithEmailAndPassword(email, password) | |
| .then((auth) => { | |
| if (auth) { | |
| history.push("/"); | |
| } | |
| }) | |
| .catch((err) => alert(err.message)); | |
| // fancy firebase register | |
| }; | |
| return ( | |
| <div className="login"> | |
| <Link to="/"> | |
| <img | |
| className="login__logo" | |
| src="https://i.insider.com/539f3ffbecad044276726c01?width=1100&format=jpeg&auto=webp" | |
| /> | |
| </Link> | |
| <div className="login__container"> | |
| <h1>Sign-In</h1> | |
| <form> | |
| <h5>Email</h5> | |
| <input | |
| type="text" | |
| value={email} | |
| onChange={(e) => setEmail(e.target.value)} | |
| /> | |
| <h5>Password</h5> | |
| <input | |
| type="password" | |
| value={password} | |
| onChange={(e) => setPassword(e.target.value)} | |
| /> | |
| <button | |
| className="login__signInButton" | |
| onClick={signIn} | |
| type="submit" | |
| > | |
| Sign In | |
| </button> | |
| <p> | |
| By signing in you agree the Terms and Conditions of the Amazon fake | |
| clone. Please see our privacy notice and out cookies policy | |
| </p> | |
| <button className="login__registerButton" onClick={register}> | |
| Create your Amazon account | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| export default Login; | |