diff --git a/frontend/src/components/Pages/About.jsx b/frontend/src/components/Pages/About.jsx index f4ab679b..f834b2aa 100644 --- a/frontend/src/components/Pages/About.jsx +++ b/frontend/src/components/Pages/About.jsx @@ -1,8 +1,7 @@ - -import bgpic from "../../assets/img/abt1.jpg"; +'use client'; +import bgpic from '../../assets/img/abt1.jpg'; import React, { useEffect } from 'react'; - export default function About() { useEffect(() => { window.scrollTo(0, 0); diff --git a/frontend/src/components/Pages/Login.jsx b/frontend/src/components/Pages/Login.jsx index 19f47c20..7c760afa 100644 --- a/frontend/src/components/Pages/Login.jsx +++ b/frontend/src/components/Pages/Login.jsx @@ -13,13 +13,14 @@ const Login = () => { password: '', }); const [hidden, setHidden] = useState(true); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(null); + + const navigate = useNavigate(); const handleChange = (e) => { setData({ ...data, [e.target.name]: e.target.value }); }; - const navigate = useNavigate(); // Correctly initialize useNavigate - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(null); const handleSubmit = async (e) => { e.preventDefault(); @@ -37,11 +38,7 @@ const Login = () => { if (!response.ok) { throw new Error(result.message || 'Login failed'); } - // Handle successful login (e.g., store token, redirect) - Cookies.set('authToken', result.token, { - expire: '1h', - secure: true, - }); + Cookies.set('authToken', result.token, { expire: '1h', secure: true }); message.success('Login successful'); navigate('/'); } catch (err) { @@ -56,37 +53,44 @@ const Login = () => { }, []); return ( -
- login +
+ {/* Background Image */} + login + {/* Login Form */}
handleSubmit(e)} - className="form z-10 p-16 bg-lightblue flex flex-col items-start justify-center gap-4 rounded-lg border-2 border-black shadow-[4px_4px_0px_0px_black] bg-[#f1e9dc]" + onSubmit={handleSubmit} + className="z-10 p-8 lg:p-16 bg-[#f1e9dc] flex flex-col gap-6 rounded-lg border-2 border-black shadow-[4px_4px_0px_0px_black] w-full max-w-md lg:max-w-xl" > -
+
Welcome, -
- + Log in to continue
handleChange(e)} + onChange={handleChange} /> +
handleChange(e)} + onChange={handleChange} />
-
- Forgot Password? -
+ + Forgot Password? + -

- Dont have an account? - - Register Here - +

+ Don’t have an account? + + Register Here +

+ + {error &&

{error}

} + diff --git a/frontend/src/components/Pages/Signup.jsx b/frontend/src/components/Pages/Signup.jsx index a0ae4183..b10ce1c5 100644 --- a/frontend/src/components/Pages/Signup.jsx +++ b/frontend/src/components/Pages/Signup.jsx @@ -1,30 +1,24 @@ import { useState, useEffect } from 'react'; import photo from '../../assets/login.png'; -import { useNavigate } from 'react-router-dom'; -import { Link } from 'react-router-dom'; +import { useNavigate, Link } from 'react-router-dom'; import { FaEye } from 'react-icons/fa'; import { FaEyeSlash } from 'react-icons/fa6'; -import zxcvbn from 'zxcvbn'; // Import zxcvbn for password strength check +import zxcvbn from 'zxcvbn'; // Password strength checker const Signup = () => { const API_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:3000'; const navigate = useNavigate(); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); - const [passwordStrength, setPasswordStrength] = useState(0); // State to track password strength - const [data, setData] = useState({ - name: '', - email: '', - password: '', - }); + const [passwordStrength, setPasswordStrength] = useState(0); + const [data, setData] = useState({ name: '', email: '', password: '' }); const [hidden, setHidden] = useState(true); const handleChange = (e) => { setData({ ...data, [e.target.name]: e.target.value }); - if (e.target.name === 'password') { const result = zxcvbn(e.target.value); - setPasswordStrength(result.score); // Update password strength score + setPasswordStrength(result.score); } }; @@ -36,42 +30,33 @@ const Signup = () => { setIsLoading(false); return; } - if (data.password.length < 8) { setError('Password must be at least 8 characters long'); setIsLoading(false); return; } - if (data.name.length < 3) { setError('Name must be at least 3 characters long'); setIsLoading(false); return; } - if (!data.email.includes('@')) { setError('Please enter a valid email address'); setIsLoading(false); return; } - try { const response = await fetch(`${API_URL}/api/user/register`, { method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, + headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data), }); const result = await response.json(); - if (!response.ok) { setIsLoading(false); setError(result.error); return; } - - // Handle successful registration alert('Registered successfully! Please log in.'); navigate('/'); } catch (error) { @@ -95,43 +80,42 @@ const Signup = () => { }; return ( -
- login - -
+
+ login + +
Play Cafe,
- + Register to continue
- handleChange(e)} + type="text" + onChange={handleChange} /> - handleChange(e)} + onChange={handleChange} /> -
handleChange(e)} + onChange={handleChange} />
- - {/* Password Strength Meter */}
{ Strength: {getPasswordStrengthText(passwordStrength)}

- {error && (
{error}
)} -

+

Already have an account? - - Login - -

- - diff --git a/frontend/src/components/Shared/Navbar.jsx b/frontend/src/components/Shared/Navbar.jsx index 482056a9..560478d2 100644 --- a/frontend/src/components/Shared/Navbar.jsx +++ b/frontend/src/components/Shared/Navbar.jsx @@ -20,7 +20,7 @@ const Navbar = () => { { name: 'BOARDGAMES', path: '/boardgame' }, { name: 'MEMBERSHIP', path: '/membership' }, // Add Membership here ]; - + useEffect(() => { setToken(Cookies.get('authToken')); }); @@ -107,7 +107,7 @@ const Navbar = () => {
-
+
{token ? (