@@ -8,6 +8,7 @@ export default function Login() {
88 const [ loading , setLoading ] = useState ( false ) ;
99 const [ error , setError ] = useState ( "" ) ;
1010
11+ // ✅ Login function
1112 const handleSubmit = async ( e ) => {
1213 e . preventDefault ( ) ;
1314 setLoading ( true ) ;
@@ -18,9 +19,7 @@ export default function Login() {
1819 "https://fat-eibl-backend-x1sp.onrender.com/users/login" ,
1920 {
2021 method : "POST" ,
21- headers : {
22- Accept : "application/json" ,
23- } ,
22+ headers : { Accept : "application/json" } ,
2423 body : new URLSearchParams ( {
2524 email : email ,
2625 password : password ,
@@ -34,10 +33,10 @@ export default function Login() {
3433 setError ( data . detail || "Invalid credentials" ) ;
3534 } else {
3635 alert ( `Welcome ${ data . user . name } !` ) ;
37- // Save user info to localStorage ( for future dashboard use)
36+ // ✅ Save user info for session
3837 localStorage . setItem ( "user" , JSON . stringify ( data . user ) ) ;
3938
40- // Redirect based on role
39+ // ✅ Redirect based on role
4140 if ( data . user . role === "admin" ) {
4241 window . location . href = "/admin-dashboard" ;
4342 } else {
@@ -51,9 +50,9 @@ export default function Login() {
5150 }
5251 } ;
5352
53+ // ✅ Forgot password redirect (no Outlook)
5454 const handleForgotPassword = ( ) => {
55- const mailtoLink = `mailto:[email protected] ?subject=Forgot Password - FAT-EIBL&body=Dear Support,%0D%0A%0D%0AI forgot my password. Please help me reset it.%0D%0A%0D%0ARegistered Email: ${ email } %0D%0A%0D%0AThank you.` ; 56- window . location . href = mailtoLink ;
55+ window . location . href = "/forgot-password" ;
5756 } ;
5857
5958 return (
@@ -67,16 +66,22 @@ export default function Login() {
6766 backgroundColor : "#f5f9ff" ,
6867 } }
6968 >
69+ { /* ✅ Logo */ }
7070 < img
7171 src = { logo }
7272 alt = "Company Logo"
7373 style = { { width : "120px" , marginBottom : "20px" } }
7474 />
75- < h1 style = { { color : "#004aad" } } > Welcome to FAT-EIBL</ h1 >
76- < p style = { { color : "#003b80" , marginBottom : "30px" } } >
75+
76+ { /* ✅ Title */ }
77+ < h1 style = { { color : "#004aad" , marginBottom : "10px" } } >
78+ Welcome to FAT-EIBL
79+ </ h1 >
80+ < p style = { { color : "#003b80" , marginBottom : "30px" , textAlign : "center" } } >
7781 Finance Audit Tracker – Edme Insurance Brokers Limited
7882 </ p >
7983
84+ { /* ✅ Login form */ }
8085 < form
8186 onSubmit = { handleSubmit }
8287 style = { {
@@ -88,6 +93,7 @@ export default function Login() {
8893 textAlign : "center" ,
8994 } }
9095 >
96+ { /* Email field */ }
9197 < input
9298 type = "email"
9399 placeholder = "Email"
@@ -102,6 +108,8 @@ export default function Login() {
102108 } }
103109 required
104110 />
111+
112+ { /* Password field */ }
105113 < input
106114 type = "password"
107115 placeholder = "Password"
@@ -117,12 +125,20 @@ export default function Login() {
117125 required
118126 />
119127
128+ { /* Error message */ }
120129 { error && (
121- < p style = { { color : "red" , fontSize : "0.9rem" , marginBottom : "10px" } } >
130+ < p
131+ style = { {
132+ color : "red" ,
133+ fontSize : "0.9rem" ,
134+ marginBottom : "10px" ,
135+ } }
136+ >
122137 { error }
123138 </ p >
124139 ) }
125140
141+ { /* Submit button */ }
126142 < button
127143 type = "submit"
128144 disabled = { loading }
@@ -139,6 +155,7 @@ export default function Login() {
139155 { loading ? "Logging in..." : "Login" }
140156 </ button >
141157
158+ { /* ✅ Forgot password redirect */ }
142159 < p
143160 onClick = { handleForgotPassword }
144161 style = { {
0 commit comments