|
1 | | -import Button from 'react-bootstrap/Button'; |
2 | | -import Card from 'react-bootstrap/Card'; |
3 | | -import Form from 'react-bootstrap/Form'; |
4 | | -import Container from 'react-bootstrap/Container'; |
5 | 1 | import React, { useEffect, useState, useContext } from 'react'; |
6 | 2 | import { toast } from 'react-toastify'; |
7 | 3 | import axios from 'axios'; |
8 | 4 | import { useNavigate } from 'react-router-dom'; |
9 | 5 | import { FaUserAlt, FaKey, FaSignInAlt } from 'react-icons/fa'; |
10 | 6 | import UserContext from '../context/UserContext'; |
| 7 | +import { |
| 8 | + Container, |
| 9 | + Box, |
| 10 | + Card, |
| 11 | + CardContent, |
| 12 | + CardHeader, |
| 13 | + CardActions, |
| 14 | + Button, |
| 15 | + TextField, |
| 16 | + Typography, |
| 17 | + Link, |
| 18 | + Divider, |
| 19 | +} from '@mui/material'; |
11 | 20 | import '../App.css'; |
12 | 21 | import './Footer.css'; |
13 | 22 |
|
@@ -62,7 +71,6 @@ function Login() { |
62 | 71 | user: { name }, |
63 | 72 | } = response.data; |
64 | 73 |
|
65 | | - // set token and logged-in user's name in local storage |
66 | 74 | localStorage.setItem('token', token); |
67 | 75 | localStorage.setItem('name', name); |
68 | 76 | context.setUser({ token: token }); |
@@ -97,92 +105,119 @@ function Login() { |
97 | 105 |
|
98 | 106 | return ( |
99 | 107 | <Container |
100 | | - className="d-flex align-items-center justify-content-center" |
101 | | - style={{ minHeight: '90vh' }} |
| 108 | + sx={{ |
| 109 | + display: 'flex', |
| 110 | + alignItems: 'center', |
| 111 | + justifyContent: 'center', |
| 112 | + minHeight: '90vh', |
| 113 | + }} |
102 | 114 | > |
103 | | - <div className="w-100" style={{ maxWidth: '400px' }}> |
| 115 | + <Box sx={{ maxWidth: '400px', width: '100%' }}> |
104 | 116 | <Card> |
105 | | - <Card.Header style={{ backgroundColor: '#4B3F6B' }}> |
106 | | - {' '} |
107 | | - <h4 style={{ backgroundColor: '#4B3F6B' }}>Login</h4>{' '} |
108 | | - </Card.Header> |
109 | | - <Card.Body> |
110 | | - <Form onSubmit={handleSubmit}> |
111 | | - <Form.Group className="mb-3" controlId="formBasicEmail"> |
112 | | - <Form.Label |
113 | | - style={{ display: 'flex', gap: '5px', alignItems: 'center' }} |
| 117 | + <CardHeader |
| 118 | + sx={{ backgroundColor: '#4B3F6B', color: 'white' }} |
| 119 | + title={<Typography variant="h5">Login</Typography>} |
| 120 | + /> |
| 121 | + <CardContent> |
| 122 | + <Box component="form" onSubmit={handleSubmit}> |
| 123 | + <Box sx={{ mb: 3 }}> |
| 124 | + <Typography |
| 125 | + component="label" |
| 126 | + sx={{ |
| 127 | + display: 'flex', |
| 128 | + gap: '5px', |
| 129 | + alignItems: 'center', |
| 130 | + marginBottom: '7px', |
| 131 | + fontWeight: '600', |
| 132 | + }} |
114 | 133 | > |
115 | 134 | <FaUserAlt /> Email address |
116 | | - </Form.Label> |
117 | | - <Form.Control |
| 135 | + </Typography> |
| 136 | + <TextField |
| 137 | + fullWidth |
| 138 | + size="small" |
118 | 139 | type="email" |
119 | 140 | placeholder="Enter email" |
120 | 141 | onChange={(e) => setEmail(e.target.value)} |
121 | | - aria-required={true} |
| 142 | + required |
122 | 143 | /> |
123 | | - <Form.Text className="text-muted"> |
| 144 | + <Typography variant="caption" color="textSecondary"> |
124 | 145 | We'll never share your email with anyone else. |
125 | | - </Form.Text> |
126 | | - </Form.Group> |
127 | | - <Form.Group className="mb-3" controlId="formBasicPassword"> |
128 | | - <Form.Label |
129 | | - style={{ display: 'flex', gap: '5px', alignItems: 'center' }} |
| 146 | + </Typography> |
| 147 | + </Box> |
| 148 | + |
| 149 | + <Box sx={{ mb: 3 }}> |
| 150 | + <Typography |
| 151 | + component="label" |
| 152 | + sx={{ |
| 153 | + display: 'flex', |
| 154 | + gap: '5px', |
| 155 | + alignItems: 'center', |
| 156 | + marginBottom: '7px', |
| 157 | + fontWeight: '600', |
| 158 | + }} |
130 | 159 | > |
131 | 160 | <FaKey /> Password |
132 | | - </Form.Label> |
133 | | - <Form.Control |
| 161 | + </Typography> |
| 162 | + <TextField |
| 163 | + fullWidth |
| 164 | + size="small" |
134 | 165 | type="password" |
135 | 166 | placeholder="Password" |
136 | 167 | onChange={(e) => setPassword(e.target.value)} |
137 | | - aria-required={true} |
| 168 | + required |
138 | 169 | /> |
139 | | - <a |
140 | | - onClick={() => { |
141 | | - navigate('/forgot-password'); |
142 | | - }} |
143 | | - style={{ |
| 170 | + <Link |
| 171 | + onClick={() => navigate('/forgot-password')} |
| 172 | + sx={{ |
144 | 173 | textDecoration: 'none', |
145 | 174 | color: '#4B3F6B', |
146 | 175 | cursor: 'pointer', |
| 176 | + fontSize: '14px', |
147 | 177 | }} |
148 | 178 | > |
149 | | - {' '} |
150 | | - <span style={{ fontSize: '14px', color: '#4B3F6B' }}> |
151 | | - Forgot password |
152 | | - </span>{' '} |
153 | | - </a>{' '} |
154 | | - </Form.Group> |
| 179 | + Forgot password |
| 180 | + </Link> |
| 181 | + </Box> |
155 | 182 | <Button |
156 | | - className={'w-100'} |
157 | | - variant="info" |
| 183 | + fullWidth |
| 184 | + variant="contained" |
158 | 185 | type="submit" |
159 | | - style={{ backgroundColor: '#4B3F6B', color: 'white' }} |
| 186 | + sx={{ |
| 187 | + backgroundColor: '#4B3F6B', |
| 188 | + color: 'white', |
| 189 | + borderRadius: '20px', |
| 190 | + }} |
| 191 | + startIcon={<FaSignInAlt />} |
160 | 192 | > |
161 | | - <FaSignInAlt style={{ marginRight: '0.3rem' }} /> |
162 | 193 | LOGIN |
163 | 194 | </Button> |
164 | | - </Form> |
165 | | - </Card.Body> |
166 | | - <Card.Footer |
167 | | - className="text-muted" |
168 | | - style={{ display: 'flex', justifyContent: 'space-between' }} |
| 195 | + </Box> |
| 196 | + </CardContent> |
| 197 | + <Divider sx={{ backgroundColor: 'black' }} /> |
| 198 | + <CardActions |
| 199 | + sx={{ |
| 200 | + display: 'flex', |
| 201 | + justifyContent: 'space-between', |
| 202 | + padding: '14px', |
| 203 | + }} |
169 | 204 | > |
170 | | - Don't Have an Account?{' '} |
171 | | - <a |
172 | | - style={{ |
| 205 | + <Typography variant="body1" sx={{ color: 'grey' }}> |
| 206 | + Don't Have an Account? |
| 207 | + </Typography> |
| 208 | + <Link |
| 209 | + onClick={() => navigate('/signup')} |
| 210 | + sx={{ |
173 | 211 | textDecoration: 'none', |
174 | 212 | color: '#4B3F6B', |
175 | 213 | cursor: 'pointer', |
176 | 214 | }} |
177 | | - onClick={() => { |
178 | | - navigate('/signup'); |
179 | | - }} |
180 | 215 | > |
181 | | - <span>Click Here to Signup</span> |
182 | | - </a> |
183 | | - </Card.Footer> |
| 216 | + Click Here to Signup |
| 217 | + </Link> |
| 218 | + </CardActions> |
184 | 219 | </Card> |
185 | | - </div> |
| 220 | + </Box> |
186 | 221 | </Container> |
187 | 222 | ); |
188 | 223 | } |
|
0 commit comments