Skip to content

Commit 4f170cd

Browse files
author
Uttam Singh
committed
Redesigned professional Forgot Password page
1 parent 5606659 commit 4f170cd

File tree

1 file changed

+59
-43
lines changed

1 file changed

+59
-43
lines changed

frontend/src/pages/ForgotPassword.jsx

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,35 @@ import logo from "../assets/logo.png";
44
export default function ForgotPassword() {
55
const [email, setEmail] = useState("");
66
const [message, setMessage] = useState("");
7+
const [error, setError] = useState("");
78
const [loading, setLoading] = useState(false);
89

910
const handleSendOTP = async (e) => {
1011
e.preventDefault();
11-
setMessage("");
1212
setLoading(true);
13+
setMessage("");
14+
setError("");
1315

1416
try {
1517
const response = await fetch(
1618
"https://fat-eibl-backend-x1sp.onrender.com/users/forgot-password",
1719
{
1820
method: "POST",
21+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
1922
body: new URLSearchParams({ email }),
2023
}
2124
);
2225

2326
const data = await response.json();
24-
if (response.ok && data.ok) {
27+
if (response.ok) {
2528
setMessage(`✅ OTP sent to ${email}. Please check your inbox.`);
29+
// Optionally redirect to reset page:
30+
// setTimeout(() => (window.location.href = "/reset-password"), 2000);
2631
} else {
27-
setMessage(`❌ ${data.detail || data.error || "Email not registered."}`);
32+
setError(data.detail || "Email not found");
2833
}
2934
} catch {
30-
setMessage("⚠️ Unable to reach the server. Please try again later.");
35+
setError("⚠️ Unable to connect to server. Try again later.");
3136
} finally {
3237
setLoading(false);
3338
}
@@ -36,8 +41,8 @@ export default function ForgotPassword() {
3641
return (
3742
<div
3843
style={{
44+
background: "linear-gradient(to bottom, #f4f8ff, #dce8ff)",
3945
height: "100vh",
40-
background: "linear-gradient(180deg, #f6f9ff 0%, #e7efff 100%)",
4146
display: "flex",
4247
justifyContent: "center",
4348
alignItems: "center",
@@ -46,31 +51,40 @@ export default function ForgotPassword() {
4651
>
4752
<div
4853
style={{
49-
background: "#fff",
50-
padding: "40px",
54+
background: "white",
55+
padding: "40px 35px",
5156
borderRadius: "16px",
52-
boxShadow: "0 6px 16px rgba(0, 0, 0, 0.1)",
53-
width: "380px",
57+
boxShadow: "0 4px 25px rgba(0, 0, 0, 0.08)",
58+
width: "360px",
5459
textAlign: "center",
5560
}}
5661
>
5762
<img
5863
src={logo}
5964
alt="Edme Logo"
60-
style={{ width: "120px", marginBottom: "20px" }}
65+
style={{ width: "120px", marginBottom: "15px" }}
6166
/>
62-
<h2 style={{ color: "#004aad", marginBottom: "10px" }}>
67+
68+
<h2
69+
style={{
70+
color: "#004aad",
71+
fontSize: "1.6rem",
72+
marginBottom: "10px",
73+
fontWeight: 600,
74+
}}
75+
>
6376
Forgot Password
6477
</h2>
78+
6579
<p
6680
style={{
67-
fontSize: "14px",
6881
color: "#555",
82+
fontSize: "0.9rem",
6983
marginBottom: "25px",
7084
}}
7185
>
72-
Enter your registered email and we’ll send an OTP to reset your
73-
password.
86+
Enter your registered email address to receive an OTP for password
87+
reset.
7488
</p>
7589

7690
<form onSubmit={handleSendOTP}>
@@ -83,60 +97,62 @@ export default function ForgotPassword() {
8397
style={{
8498
width: "100%",
8599
padding: "12px",
86-
borderRadius: "8px",
87100
border: "1px solid #ccc",
88-
outlineColor: "#004aad",
101+
borderRadius: "8px",
89102
marginBottom: "15px",
90-
fontSize: "14px",
103+
fontSize: "0.95rem",
104+
textAlign: "center",
91105
}}
92106
/>
107+
108+
{error && (
109+
<p style={{ color: "red", fontSize: "0.85rem", marginBottom: "10px" }}>
110+
{error}
111+
</p>
112+
)}
113+
{message && (
114+
<p
115+
style={{
116+
color: "green",
117+
fontSize: "0.9rem",
118+
marginBottom: "10px",
119+
}}
120+
>
121+
{message}
122+
</p>
123+
)}
124+
93125
<button
94126
type="submit"
95127
disabled={loading}
96128
style={{
97129
width: "100%",
98130
padding: "12px",
99-
borderRadius: "8px",
100-
backgroundColor: loading ? "#7a9be6" : "#004aad",
131+
backgroundColor: loading ? "#7aa2f7" : "#004aad",
101132
color: "white",
102-
fontWeight: 500,
133+
fontWeight: "bold",
103134
border: "none",
135+
borderRadius: "8px",
104136
cursor: "pointer",
105-
fontSize: "15px",
137+
fontSize: "1rem",
138+
transition: "0.3s",
106139
}}
107140
>
108141
{loading ? "Sending..." : "Send OTP"}
109142
</button>
110143
</form>
111144

112-
{message && (
113-
<p
114-
style={{
115-
color: message.includes("✅")
116-
? "green"
117-
: message.includes("⚠️")
118-
? "#e67e22"
119-
: "red",
120-
fontSize: "14px",
121-
marginTop: "15px",
122-
lineHeight: "1.5",
123-
}}
124-
>
125-
{message}
126-
</p>
127-
)}
128-
129145
<p
130-
onClick={() => (window.location.href = "/")}
131146
style={{
132147
color: "#004aad",
133-
marginTop: "25px",
134-
fontSize: "14px",
135-
textDecoration: "underline",
148+
fontSize: "0.9rem",
149+
marginTop: "20px",
136150
cursor: "pointer",
151+
textDecoration: "underline",
137152
}}
153+
onClick={() => (window.location.href = "/")}
138154
>
139-
Back to Login
155+
Back to Login
140156
</p>
141157
</div>
142158
</div>

0 commit comments

Comments
 (0)