|
1 | | -// import React, { useState, useContext } from "react"; |
2 | | -// import { AdminContext } from "../../context/AdminContext"; |
3 | | -// import { Button, Form, FormGroup, Label, Input, Container } from "reactstrap"; |
4 | | -// import GoogleIcon from "@mui/icons-material/Google"; |
5 | | -// import { loginUser } from "../../services/auth"; |
6 | | -// import { useNavigate } from "react-router-dom"; |
7 | | -// function Login() { |
8 | | -// const { handleLogin } = useContext(AdminContext); |
9 | | -// const [email, setEmail] = useState(""); |
10 | | -// const [password, setPassword] = useState(""); |
11 | | -// const navigate = useNavigate(); |
12 | | -// const handleSubmit = async (event) => { |
13 | | -// event.preventDefault(); |
14 | | -// try { |
15 | | -// const userObject = await loginUser(email, password); |
16 | | -// if (userObject) { |
17 | | -// handleLogin(userObject); |
18 | | -// navigate("/", { replace: true }); |
19 | | -// } |
20 | | -// } catch (error) { |
21 | | -// console.error("Login failed:", error); |
22 | | -// alert("Login failed. Please check your credentials."); |
23 | | -// } |
24 | | -// }; |
25 | | - |
26 | | -// return ( |
27 | | -// <Container |
28 | | -// className="d-flex flex-column justify-content-center align-items-center" |
29 | | -// style={{ height: "100vh" }} |
30 | | -// > |
31 | | -// <img |
32 | | -// src="/Logo_of_IIT_Bhilai.png" |
33 | | -// width={100} |
34 | | -// alt="IIT-Bhilai-Logo" |
35 | | -// style={{ position: "relative", bottom: 20 }} |
36 | | -// /> |
37 | | -// <Container className="d-flex justify-content-center align-items-center"> |
38 | | -// <Form onSubmit={handleSubmit} style={{ width: "30%" }}> |
39 | | -// <FormGroup className="text-center"> |
40 | | -// <h2>Login</h2> |
41 | | -// </FormGroup> |
42 | | -// <FormGroup> |
43 | | -// <Label for="email">Email</Label> |
44 | | -// <Input |
45 | | -// type="email" |
46 | | -// name="email" |
47 | | -// id="email" |
48 | | -// placeholder="Email" |
49 | | -// value={email} |
50 | | -// onChange={(e) => setEmail(e.target.value)} |
51 | | -// /> |
52 | | -// </FormGroup> |
53 | | -// <FormGroup> |
54 | | -// <Label for="password">Password</Label> |
55 | | -// <Input |
56 | | -// type="password" |
57 | | -// name="password" |
58 | | -// id="password" |
59 | | -// placeholder="Password" |
60 | | -// value={password} |
61 | | -// onChange={(e) => setPassword(e.target.value)} |
62 | | -// /> |
63 | | -// </FormGroup> |
64 | | -// <div className="d-flex justify-content-end mt-2"> |
65 | | -// <a |
66 | | -// href="/forgot-password" |
67 | | -// style={{ |
68 | | -// fontSize: "0.9rem", |
69 | | -// textDecoration: "none", |
70 | | -// color: "#007bff", |
71 | | -// }} |
72 | | -// > |
73 | | -// {" "} |
74 | | -// Forgot Password?{" "} |
75 | | -// </a> |
76 | | -// </div> |
77 | | -// <FormGroup className="text-center"> |
78 | | -// <Button type="submit" style={{ width: "100%" }} color="success"> |
79 | | -// Login |
80 | | -// </Button> |
81 | | -// </FormGroup> |
82 | | -// <div |
83 | | -// style={{ |
84 | | -// display: "flex", |
85 | | -// alignItems: "center", |
86 | | -// justifyContent: "center", |
87 | | -// marginBottom: "10px", |
88 | | -// }} |
89 | | -// > |
90 | | -// <hr style={{ width: "40%" }} /> |
91 | | -// <p style={{ margin: "0 10px" }}>OR</p> |
92 | | -// <hr style={{ width: "40%" }} /> |
93 | | -// </div> |
94 | | -// <FormGroup className="text-center"> |
95 | | -// <a href={`${process.env.REACT_APP_BACKEND_URL}/auth/google`}> |
96 | | -// <Button type="button" style={{ width: "100%" }} color="primary"> |
97 | | -// Sign in with Google <GoogleIcon /> |
98 | | -// </Button> |
99 | | -// </a> |
100 | | -// </FormGroup> |
101 | | -// <FormGroup className="text-center"> |
102 | | -// <Label> |
103 | | -// Don't have an Account? <a href="/register">Register</a> |
104 | | -// </Label> |
105 | | -// </FormGroup> |
106 | | -// </Form> |
107 | | -// </Container> |
108 | | -// </Container> |
109 | | -// ); |
110 | | -// } |
111 | | - |
112 | | -// export default Login; |
113 | 1 | import React, { useState, useContext } from "react"; |
114 | 2 | import { AdminContext } from "../../context/AdminContext"; |
115 | 3 | import { loginUser } from "../../services/auth"; |
|
0 commit comments