diff --git a/package-lock.json b/package-lock.json index f38fe5e8b..f2b211539 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1161,11 +1161,94 @@ "resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz", "integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==" }, + "@emotion/cache": { + "version": "10.0.29", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-10.0.29.tgz", + "integrity": "sha512-fU2VtSVlHiF27empSbxi1O2JFdNWZO+2NFHfwO0pxgTep6Xa3uGb+3pVKfLww2l/IBGLNEZl5Xf/++A4wAYDYQ==", + "requires": { + "@emotion/sheet": "0.9.4", + "@emotion/stylis": "0.8.5", + "@emotion/utils": "0.11.3", + "@emotion/weak-memoize": "0.2.5" + } + }, + "@emotion/core": { + "version": "10.0.35", + "resolved": "https://registry.npmjs.org/@emotion/core/-/core-10.0.35.tgz", + "integrity": "sha512-sH++vJCdk025fBlRZSAhkRlSUoqSqgCzYf5fMOmqqi3bM6how+sQpg3hkgJonj8GxXM4WbD7dRO+4tegDB9fUw==", + "requires": { + "@babel/runtime": "^7.5.5", + "@emotion/cache": "^10.0.27", + "@emotion/css": "^10.0.27", + "@emotion/serialize": "^0.11.15", + "@emotion/sheet": "0.9.4", + "@emotion/utils": "0.11.3" + } + }, + "@emotion/css": { + "version": "10.0.27", + "resolved": "https://registry.npmjs.org/@emotion/css/-/css-10.0.27.tgz", + "integrity": "sha512-6wZjsvYeBhyZQYNrGoR5yPMYbMBNEnanDrqmsqS1mzDm1cOTu12shvl2j4QHNS36UaTE0USIJawCH9C8oW34Zw==", + "requires": { + "@emotion/serialize": "^0.11.15", + "@emotion/utils": "0.11.3", + "babel-plugin-emotion": "^10.0.27" + } + }, "@emotion/hash": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz", "integrity": "sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==" }, + "@emotion/memoize": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz", + "integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==" + }, + "@emotion/serialize": { + "version": "0.11.16", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-0.11.16.tgz", + "integrity": "sha512-G3J4o8by0VRrO+PFeSc3js2myYNOXVJ3Ya+RGVxnshRYgsvErfAOglKAiy1Eo1vhzxqtUvjCyS5gtewzkmvSSg==", + "requires": { + "@emotion/hash": "0.8.0", + "@emotion/memoize": "0.7.4", + "@emotion/unitless": "0.7.5", + "@emotion/utils": "0.11.3", + "csstype": "^2.5.7" + }, + "dependencies": { + "csstype": { + "version": "2.6.13", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.13.tgz", + "integrity": "sha512-ul26pfSQTZW8dcOnD2iiJssfXw0gdNVX9IJDH/X3K5DGPfj+fUYe3kB+swUY6BF3oZDxaID3AJt+9/ojSAE05A==" + } + } + }, + "@emotion/sheet": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-0.9.4.tgz", + "integrity": "sha512-zM9PFmgVSqBw4zL101Q0HrBVTGmpAxFZH/pYx/cjJT5advXguvcgjHFTCaIO3enL/xr89vK2bh0Mfyj9aa0ANA==" + }, + "@emotion/stylis": { + "version": "0.8.5", + "resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz", + "integrity": "sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==" + }, + "@emotion/unitless": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz", + "integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==" + }, + "@emotion/utils": { + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-0.11.3.tgz", + "integrity": "sha512-0o4l6pZC+hI88+bzuaX/6BgOvQVhbt2PfmxauVaYOGgbsAw14wdKyvMCZXnsnsHys94iadcF+RG/wZyx6+ZZBw==" + }, + "@emotion/weak-memoize": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz", + "integrity": "sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==" + }, "@firebase/analytics": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.4.2.tgz", @@ -3202,6 +3285,23 @@ "object.assign": "^4.1.0" } }, + "babel-plugin-emotion": { + "version": "10.0.33", + "resolved": "https://registry.npmjs.org/babel-plugin-emotion/-/babel-plugin-emotion-10.0.33.tgz", + "integrity": "sha512-bxZbTTGz0AJQDHm8k6Rf3RQJ8tX2scsfsRyKVgAbiUPUNIRtlK+7JxP+TAd1kRLABFxe0CFm2VdK4ePkoA9FxQ==", + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@emotion/hash": "0.8.0", + "@emotion/memoize": "0.7.4", + "@emotion/serialize": "^0.11.16", + "babel-plugin-macros": "^2.0.0", + "babel-plugin-syntax-jsx": "^6.18.0", + "convert-source-map": "^1.5.0", + "escape-string-regexp": "^1.0.5", + "find-root": "^1.1.0", + "source-map": "^0.5.7" + } + }, "babel-plugin-istanbul": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.2.0.tgz", @@ -3280,6 +3380,11 @@ "resolved": "https://registry.npmjs.org/babel-plugin-named-asset-import/-/babel-plugin-named-asset-import-0.3.6.tgz", "integrity": "sha512-1aGDUfL1qOOIoqk9QKGIo2lANk+C7ko/fqH0uIyC71x3PEGz0uVP8ISgfEsFuG+FKmjHTvFK/nNM8dowpmUxLA==" }, + "babel-plugin-syntax-jsx": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz", + "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=" + }, "babel-plugin-syntax-object-rest-spread": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", @@ -6489,6 +6594,11 @@ "pkg-dir": "^3.0.0" } }, + "find-root": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==" + }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -11606,6 +11716,11 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.7.tgz", "integrity": "sha512-TAv1KJFh3RhqxNvhzxj6LeT5NWklP6rDr2a0jaTfsZ5wSZWHOGeqQyejUp3xxLfPt2UpyJEcVQB/zyPcmonNFA==" }, + "react-flip-move": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-flip-move/-/react-flip-move-3.0.4.tgz", + "integrity": "sha512-HyUVv9g3t/BS7Yz9HgrtYSWyRNdR2F81nkj+C5iRY675AwlqCLB5JU9mnZWg0cdVz7IM4iquoyZx70vzZv3Z8Q==" + }, "react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -11717,6 +11832,14 @@ "workbox-webpack-plugin": "4.3.1" } }, + "react-spinners": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.9.0.tgz", + "integrity": "sha512-+x6eD8tn/aYLdxZjNW7fSR1uoAXLb9qq6TFYZR1dFweJvckcf/HfP8Pa/cy5HOvB/cvI4JgrYXTjh2Me3S6Now==", + "requires": { + "@emotion/core": "^10.0.15" + } + }, "react-transition-group": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.1.tgz", diff --git a/package.json b/package.json index d9fa4acab..15a8849d4 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "react": "^16.13.1", "react-currency-format": "^1.0.0", "react-dom": "^16.13.1", + "react-flip-move": "^3.0.4", "react-router-dom": "^5.2.0", + "react-spinners": "^0.9.0", "react-scripts": "3.4.3" }, "scripts": { diff --git a/src/App.js b/src/App.js index 981c5aa51..d38c6fba4 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,8 @@ import Checkout from "./Checkout"; import Login from "./Login"; import Payment from "./Payment"; import Orders from "./Orders"; +import Register from "./Register"; + import { auth } from "./firebase"; import { useStateValue } from "./StateProvider"; import { loadStripe } from "@stripe/stripe-js"; @@ -50,6 +52,9 @@ function App() {
+ + + diff --git a/src/Login.css b/src/Login.css index 2b9a302fe..e5b2916a6 100644 --- a/src/Login.css +++ b/src/Login.css @@ -1,68 +1,72 @@ .login { - background-color: white; - height: 100vh; - display: flex; - flex-direction: column; - align-items: center; + background-color: white; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; } .login__logo { - margin-top: 20px; - margin-bottom: 20px; - object-fit: contain; - width: 100px; - margin-right: auto; - margin-left: auto; - } + margin-top: 20px; + margin-bottom: 20px; + object-fit: contain; + width: 100px; + margin-right: auto; + margin-left: auto; +} .login__container { - width: 300px; - height: fit-content; - display: flex; - flex-direction: column; - border-radius: 5px; - border: 1px solid lightgray; - padding: 20px; + width: 300px; + height: fit-content; + display: flex; + flex-direction: column; + border-radius: 5px; + border: 1px solid lightgray; + padding: 20px; } .login__container > h1 { - font-weight: 500; - margin-bottom: 20px; - } + font-weight: 500; + margin-bottom: 20px; +} .login__container > form > h5 { - margin-bottom: 5px; + margin-bottom: 5px; } .login__container > form > input { - height: 30px; - margin-bottom: 10px; - background-color: white; - width: 98%; - } + height: 30px; + margin-bottom: 10px; + background-color: white; + width: 98%; +} .login__container > p { - margin-top: 15px; - font-size: 12px; + margin-top: 15px; + font-size: 12px; } .login__signInButton { - background: #f0c14b; - border-radius: 2px; - width: 100%; - height: 30px; - border: 1px solid; - margin-top: 10px; - border-color: #a88734 #9c7e31 #846a29; - } + background: #f0c14b; + border-radius: 2px; + width: 100%; + height: 30px; + border: 1px solid; + margin-top: 10px; + border-color: #a88734 #9c7e31 #846a29; +} - .login__registerButton { - border-radius: 2px; - width: 100%; - height: 30px; - border: 1px solid; - margin-top: 10px; - border-color: darkgray; - } - - \ No newline at end of file +.login__newUser > p { + font-size: 12px; + text-align: center; +} +.login__registerButton { + border-radius: 2px; + width: 100%; + height: 30px; + border: 1px solid; + margin-top: 10px; + background-image: linear-gradient(white, #e6e6e6, #e6e6e6); + border-color: lightgray; + font-weight: 600; +} diff --git a/src/Login.js b/src/Login.js index 92181057b..a0d8486cc 100644 --- a/src/Login.js +++ b/src/Login.js @@ -1,69 +1,88 @@ -import React, { useState } from 'react'; -import './Login.css' +import React, { useState } from "react"; +import "./Login.css"; +import PulseLoader from "react-spinners/PulseLoader"; 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 history = useHistory(); + const [loading, setLoading] = useState(false); + const [user, setUser] = useState({ email: "", password: "" }); - const signIn = e => { - e.preventDefault(); + const handleOnChange = (e) => { + setUser({ + ...user, + [e.target.name]: e.target.value, + }); + }; - auth - .signInWithEmailAndPassword(email, password) - .then(auth => { - history.push('/') - }) - .catch(error => alert(error.message)) - } + const signIn = (e) => { + e.preventDefault(); + setLoading(true); + auth + .signInWithEmailAndPassword(user.email, user.password) + .then((auth) => { + history.push("/"); + }) + .catch((error) => alert(error.message)) + .then(() => setLoading(false)); + }; - const register = e => { - e.preventDefault(); + return ( +
+ + amazon-logo + - auth - .createUserWithEmailAndPassword(email, password) - .then((auth) => { - // it successfully created a new user with email and password - if (auth) { - history.push('/') - } - }) - .catch(error => alert(error.message)) - } +
+

Sign-in

- return ( -
- - - +
+
E-mail
+ -
-

Sign-in

+
Password
+ - -
E-mail
- setEmail(e.target.value)} /> + + -
Password
- setPassword(e.target.value)} /> +

+ By continuing, you agree to AMAZON FAKE CLONE Terms of Use and Privacy + Notice. +

- - - -

- By signing-in you agree to the AMAZON FAKE CLONE Conditions of Use & Sale. Please - see our Privacy Notice, our Cookies Notice and our Interest-Based Ads Notice. -

- - -
+
+

¿Don't you have an account?

+ + +
- ) +
+
+ ); } -export default Login +export default Login; diff --git a/src/Register.css b/src/Register.css new file mode 100644 index 000000000..f26b2901c --- /dev/null +++ b/src/Register.css @@ -0,0 +1,82 @@ +.register { + background: white; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; +} + +.register__logo { + width: 100px; + margin: 20px auto; + object-fit: contain; +} + +.register__container { + width: 300px; + height: fit-content; + display: flex; + flex-direction: column; + border-radius: 5px; + border: 1px solid lightgray; + padding: 20px; +} + +.register__container > h1 { + font-weight: 500; + margin-bottom: 20px; +} + +.register__container > form > h5 { + margin-bottom: 5px; +} + +.register__container > form > input { + height: 30px; + margin-bottom: 10px; + padding-left: 10px; + border-radius: 3px; + border: 1px solid grey; + background-color: white; + width: 95%; +} + +.register__container > form > input:focus { + border: 2px solid #f0c14b; + outline: none; +} + +.register__container > form > button { + border-radius: 2px; + width: 100%; + height: 30px; + border: 1px solid; + margin-top: 10px; + background-image: linear-gradient(white, #f0c14b, #f0c14b); + border-color: #a88734 #9c7e31 #846a29; +} + +.register__container > p { + margin-top: 20px; + font-size: 12px; + text-align: center; +} + +.register__alreadyAccount { + border-top: 1px solid lightgray; + padding-top: 30px; + padding-bottom: 20px; + margin-top: 20px; + font-size: 12px; + text-align: center; +} + +.register__alreadyAccount > strong { + color: #0066c0; + cursor: pointer; +} + +a { + color: #0066c0; + text-decoration: none; +} diff --git a/src/Register.js b/src/Register.js new file mode 100644 index 000000000..55f946dc4 --- /dev/null +++ b/src/Register.js @@ -0,0 +1,102 @@ +import React, { useState } from "react"; +import "./Register.css"; +import PulseLoader from "react-spinners/PulseLoader"; +import { Link, useHistory } from "react-router-dom"; + +import { auth } from "./firebase"; + +function Register() { + const history = useHistory(); + const [loading, setLoading] = useState(false); + const [user, setUser] = useState({ name: "", email: "", password: "" }); + + const handleOnChange = (e) => { + setUser({ + ...user, + [e.target.name]: e.target.value, + }); + }; + + const register = (e) => { + e.preventDefault(); + setLoading(true); + + auth + .createUserWithEmailAndPassword(user.email, user.password) + .then((auth) => { + auth.user.updateProfile({ + displayName: user.name, + }); + }) + .then(() => { + // I did this because if I perform the action continuously, the username takes it as its initial value (null) + setTimeout(() => { + history.push("/"); + }, 1500); + }) + .catch((error) => alert(error.message)) + .then(() => setLoading(true)); + }; + + return ( +
+ + amazon-logo + + +
+

Create Account

+ +
+
Your name
+ +
E-mail
+ +
Password
+ + + +
+ +

+ By creating an account, you agree to the Terms of Use and Privacy + Notice of AMAZON FAKE CLONE. +

+ +
+ ¿Already have an account?  + + Sign in + +
+
+
+ ); +} + +export default Register;