Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frontend/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ body {
}
}



.input-style {
@apply w-full p-3 rounded-lg bg-gray-700 text-white focus:ring focus:ring-blue-500;
@apply w-full px-4 py-2 rounded-md bg-gray-700 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-400;
}
177 changes: 74 additions & 103 deletions frontend/app/login/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ const Login = () => {
});

const data = await response.json();
<<<<<<< HEAD

console.log("API Response:", data);

if (!response.ok) {
throw new Error(data.message || "Something went wrong");
}
=======

if (!response.ok) throw new Error(data.message || "Something went wrong");
>>>>>>> bd4cc6b545b67df56b95f554d722b0185fab6322


if (data.token) {
sessionStorage.setItem("token", data.token);
Expand All @@ -83,9 +83,9 @@ const Login = () => {
}
};

<<<<<<< HEAD

const capitalizedRole = role?.charAt(0).toUpperCase() + role?.slice(1);
=======

const getImageSrc = () => {
const imageMap = {
police: "/policeBg.jpg",
Expand All @@ -94,13 +94,16 @@ const Login = () => {
};
return imageMap[role] || "/defaultBg.jpg";
};
>>>>>>> bd4cc6b545b67df56b95f554d722b0185fab6322


return (
<>
<Navbar />
{role !== "anonymous" && (
<<<<<<< HEAD

<div className="min-h-screen bg-gradient-to-b from-gray-900 to-blue-900 text-white flex flex-col lg:flex-row items-center justify-center px-4 lg:pb-8 gap-16">


<div className="min-h-screen flex items-center bg-gradient-to-b from-gray-900 to-blue-900">
<div className="flex flex-col items-center justify-center">
<h1 className="text-5xl pb-8 pl-16 font-bold mb-4 bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-cyan-300">
Expand Down Expand Up @@ -212,114 +215,82 @@ const Login = () => {
src={`/${role ?? "default"}Bg.jpg`}
alt="Login Background"
className="w-full h-full object-cover rounded-3xl"
=======

<div className="min-h-screen bg-gradient-to-b from-gray-900 to-blue-900 text-white flex flex-col lg:flex-row items-center justify-center px-4 pt-6 pb-16 lg:pt-8 lg:pb-8 gap-8">

{/* Left: Form Section */}
<div className="w-full max-w-md bg-gray-800 rounded-xl shadow-xl p-8">
<h1 className="text-3xl lg:text-4xl font-bold text-center mb-6 bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-cyan-300">
{isSignup ? "Sign Up" : "Login"} as{" "}
{role?.charAt(0).toUpperCase() + role?.slice(1)}
</h1>
<div className="w-full h-[450px] max-w-xl bg-gray-800 rounded-2xl shadow-2xl p-8">
<h1 className="text-3xl lg:text-4xl font-bold text-center mb-4 bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-cyan-300 ">
{isSignup ? "Sign Up" : "Login"} as {role?.charAt(0).toUpperCase() + role?.slice(1)}
</h1>

{error && <p className="text-red-400 text-sm text-center">{error}</p>}

<form onSubmit={handleAuth} className="space-y-4 mt-4">
{role === "police" && (
<>
<input
type="text"
name="badgeNumber"
placeholder="Badge Number"
className="input-style"
value={credentials.badgeNumber}
onChange={handleChange}
/>
<input
type="text"
name="name"
placeholder="Name"
className="input-style"
value={credentials.name}
onChange={handleChange}
/>
</>
)}
{role === "citizen" && (
<>
<input
type="text"
name="name"
placeholder="Name"
className="input-style"
value={credentials.name}
onChange={handleChange}
/>
<input
type="text"
name="phone"
placeholder="Mobile Number"
className="input-style"
value={credentials.phone}
onChange={handleChange}
/>
</>
)}
{role === "community" && (
<>
<input
type="text"
name="adminId"
placeholder="Admin ID"
className="input-style"
value={credentials.adminId}
onChange={handleChange}
/>
<input
type="password"
name="password"
placeholder="Password"
className="input-style"
value={credentials.password}
onChange={handleChange}
/>
</>
)}
<input
type="password"
name="password"
placeholder="Password"
className="input-style"
value={credentials.password}
onChange={handleChange}
/>
<button
type="submit"
className="w-full bg-blue-600 p-3 rounded-lg hover:bg-blue-700 transition"
>
{loading ? "Please wait..." : isSignup ? "Sign Up" : "Login"}
</button>
</form>

<p className="text-center text-sm text-gray-400 mt-4">
{isSignup ? "Already have an account?" : "Don't have an account?"}{" "}
<button
className="text-blue-400 hover:underline"
onClick={() => setIsSignup(!isSignup)}
>
{isSignup ? "Login" : "Sign Up"}
</button>
</p>
</div>
{error && <p className="text-red-400 text-sm text-center">{error}</p>}

<form onSubmit={handleAuth} className="space-y-8 mt-4 ">
{/* Inputs */}
<input
type="text"
name="badgeNumber"
placeholder="Badge Number"
className="input-style "
value={credentials.badgeNumber}
onChange={handleChange}
/>
<input
type="text"
name="name"
placeholder="Name"
className="input-style"
value={credentials.name}
onChange={handleChange}
/>
<input
type="password"
name="password"
placeholder="Password"
className="input-style"
value={credentials.password}
onChange={handleChange}
/>
<button
type="submit"
className="w-full bg-blue-600 p-3 rounded-lg hover:bg-blue-700 transition font-semibold"
>
{loading ? "Please wait..." : isSignup ? "Sign Up" : "Login"}
</button>
</form>

<p className="text-center text-sm text-gray-400 mt-4">
{isSignup ? "Already have an account?" : "Don't have an account?"}{" "}
<button
className="text-blue-400 hover:underline"
onClick={() => setIsSignup(!isSignup)}
>
{isSignup ? "Login" : "Sign Up"}
</button>
</p>
</div>

{/* Right: Image Section */}

<div className="w-full max-w-md hidden lg:block">
<img
src={getImageSrc()}
alt="Login Visual"
className="rounded-2xl w-full h-auto object-cover shadow-xl"
/>
</div>


<div className="w-full max-w-xl hidden lg:block">
<img
src={getImageSrc()}
alt="Login Background"
className="rounded-2xl w-full h-auto object-cover shadow-lg"
>>>>>>> bd4cc6b545b67df56b95f554d722b0185fab6322

/>
</div>

</div>
)}
</>
Expand Down
Loading