From 51f9c73b297f118b544fc5f929faaa46af54673a Mon Sep 17 00:00:00 2001 From: Tony-ArtZ Date: Thu, 10 Oct 2024 01:17:10 +0530 Subject: [PATCH] [FIX] #73 : updated login-ui --- src/Pages/Login.js | 237 +++++++++++++++++++++++++++++---------------- 1 file changed, 156 insertions(+), 81 deletions(-) diff --git a/src/Pages/Login.js b/src/Pages/Login.js index 0aa0c1c..464d293 100644 --- a/src/Pages/Login.js +++ b/src/Pages/Login.js @@ -1,12 +1,9 @@ -import React, { useState, useEffect } from "react"; -import "./style.css"; -import "./utils.css"; -import loader_icon from "../assets/icons/loader_icon.gif"; +import { useState, useEffect } from "react"; import { useFirebase } from "../context/firebase"; import { getAuth, onAuthStateChanged } from "firebase/auth"; import { useNavigate, Link } from "react-router-dom"; -import { FaEye, FaEyeSlash } from "react-icons/fa"; -import "../components/Navbar.css"; +import { FaEye, FaEyeSlash, FaFilm, FaTicketAlt } from "react-icons/fa"; +import { PiPopcorn } from "react-icons/pi"; const Login = () => { const firebase = useFirebase(); @@ -17,7 +14,6 @@ const Login = () => { const [password, setPassword] = useState(""); const [isLoading, setIsLoading] = useState(false); const [isPasswordVisible, setIsPasswordVisible] = useState(false); - const [error, setError] = useState(""); const [emailError, setEmailError] = useState(""); const [passwordError, setPasswordError] = useState(""); @@ -28,8 +24,8 @@ const Login = () => { navigate("/Home"); } }); - document.title = "Login"; - }, [auth]); + document.title = "Login - Movie Tickets"; + }, [auth, navigate]); const resetErrors = () => { setError(""); @@ -45,14 +41,14 @@ const Login = () => { const validateForm = () => { let isValid = true; if (email === "") { - setEmailError("(Required Field)"); + setEmailError("Required"); isValid = false; } else if (!validateEmailFormat(email)) { - setEmailError("(Invalid Email Format)"); + setEmailError("Invalid format"); isValid = false; } if (password === "") { - setPasswordError("(Required Field)"); + setPasswordError("Required"); isValid = false; } return isValid; @@ -60,14 +56,11 @@ const Login = () => { const handleSignIn = () => { resetErrors(); - let isValid = validateForm(); - if (isValid) { + if (validateForm()) { setIsLoading(true); - setError(""); firebase .loginUserWithEmailAndPassword(email, password) .then(() => { - console.log("User logged in successfully!"); setEmail(""); setPassword(""); setError(""); @@ -76,7 +69,7 @@ const Login = () => { if (error.message === "Firebase: Error (auth/invalid-credential).") setError("Incorrect email or password"); else if (error.message === "Firebase: Error (auth/invalid-email).") - setEmailError("(Invalid Email)"); + setEmailError("Invalid Email"); else setError("Can't Sign In, Unexpected error occurred!"); }) .finally(() => { @@ -90,77 +83,159 @@ const Login = () => { }; return ( - <> -
-
-
Login
-
- Please provide your email address and password. +
+ {/* Left side - Image and overlay */} +
+ Movie Theater +
+

+ Welcome to Ticketify +

+

+ Your gateway to cinematic adventures +

+
+ + +
+
+
- - setEmail(e.target.value)} - className={`input-field ${ - emailError !== "" ? "error-input-field" : "" - }`} - placeholder="e.g. example@gmail.com" - /> - - -
- setPassword(e.target.value)} - placeholder="Password" - className={`input-field ${ - passwordError !== "" ? "error-input-field" : "" - }`} - /> - + {/* Right side - Login form */} +
+
+
+

+ Sign in to your account +

-
- Loader Icon -
- {error} +
e.preventDefault()}> +
+
+ + setEmail(e.target.value)} + /> + {emailError && ( +

{emailError}

+ )} +
+
+ + setPassword(e.target.value)} + /> + + {passwordError && ( +

{passwordError}

+ )} +
+
+ + {error &&

{error}

} - - - Don't have an account{" "} - - Sign Up +
+ +
+ +
+ + Don't have an account? Sign up - +
- +
); }; -export default Login; \ No newline at end of file +export default Login;