|
@@ -1,25 +1,169 @@
|
|
1
|
+// import { useNavigate } from 'react-router-dom'
|
|
2
|
+// import useAuth from '../Auth/useAuth';
|
|
3
|
+// import {Button} from 'react-bootstrap'
|
|
4
|
+//
|
|
5
|
+// export function Login () {
|
|
6
|
+//
|
|
7
|
+// let auth = useAuth();
|
|
8
|
+// let navigate = useNavigate()
|
|
9
|
+//
|
|
10
|
+//
|
|
11
|
+// function In () {
|
|
12
|
+// auth.login({ name : 'edgar', id : 1 })
|
|
13
|
+// console.log('is logged ? ',auth.isLogged())
|
|
14
|
+// return navigate('/dashboard/home')
|
|
15
|
+// }
|
|
16
|
+//
|
|
17
|
+// return(
|
|
18
|
+// <>
|
|
19
|
+// <h1>Bienvenido</h1>
|
|
20
|
+// <Button onClick={In}>
|
|
21
|
+// Iniciar Session
|
|
22
|
+// </Button>
|
|
23
|
+// </>
|
|
24
|
+// )
|
|
25
|
+// }
|
|
26
|
+
|
|
27
|
+import * as React from 'react';
|
|
28
|
+import Avatar from '@mui/material/Avatar';
|
|
29
|
+import Button from '@mui/material/Button';
|
|
30
|
+import CssBaseline from '@mui/material/CssBaseline';
|
|
31
|
+import TextField from '@mui/material/TextField';
|
|
32
|
+
|
|
33
|
+import PersonIcon from '@mui/icons-material/Person';
|
|
34
|
+import Typography from '@mui/material/Typography';
|
|
35
|
+import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
36
|
+import {Paper, Box, Grid,Link, Checkbox, FormControlLabel } from '@mui/material'
|
|
37
|
+
|
1
|
38
|
import { useNavigate } from 'react-router-dom'
|
2
|
39
|
import useAuth from '../Auth/useAuth';
|
3
|
|
-import {Button} from 'react-bootstrap'
|
4
|
40
|
|
5
|
|
-export function Login () {
|
6
|
|
-
|
|
41
|
+function Copyright(props){
|
|
42
|
+ return (
|
|
43
|
+ <Typography variant="body2" color="text.secondary" align="center" {...props}>
|
|
44
|
+ {'Copyright © '}
|
|
45
|
+ <Link color="inherit" href="https://mui.com/">
|
|
46
|
+ GrupoDIT
|
|
47
|
+ </Link>{' '}
|
|
48
|
+ {new Date().getFullYear()}
|
|
49
|
+ {'.'}
|
|
50
|
+ </Typography>
|
|
51
|
+ );
|
|
52
|
+}
|
|
53
|
+
|
|
54
|
+const theme = createTheme();
|
|
55
|
+
|
|
56
|
+export function Login() {
|
|
57
|
+
|
7
|
58
|
let auth = useAuth();
|
8
|
59
|
let navigate = useNavigate()
|
9
|
60
|
|
|
61
|
+ const handleSubmit = (event) => {
|
|
62
|
+ event.preventDefault();
|
|
63
|
+ const data = new FormData(event.currentTarget);
|
|
64
|
+
|
|
65
|
+ let user = {
|
|
66
|
+ email: data.get('email'),
|
|
67
|
+ password: data.get('password'),
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ console.log(user);
|
|
71
|
+ auth.login(user)
|
|
72
|
+ console.log(auth.isLogged());
|
10
|
73
|
|
11
|
|
- function In () {
|
12
|
|
- auth.login({ name : 'edgar', id : 1 })
|
13
|
|
- console.log('is logged ? ',auth.isLogged())
|
14
|
74
|
return navigate('/dashboard/home')
|
15
|
|
- }
|
16
|
|
-
|
17
|
|
- return(
|
18
|
|
- <>
|
19
|
|
- <h1>Bienvenido</h1>
|
20
|
|
- <Button onClick={In}>
|
21
|
|
- Iniciar Session
|
22
|
|
- </Button>
|
23
|
|
- </>
|
24
|
|
- )
|
|
75
|
+
|
|
76
|
+ };
|
|
77
|
+
|
|
78
|
+ return (
|
|
79
|
+ <ThemeProvider theme={theme}>
|
|
80
|
+ <Grid container component="main" sx={{ height: '100vh' }}>
|
|
81
|
+ <CssBaseline />
|
|
82
|
+ <Grid
|
|
83
|
+ item
|
|
84
|
+ xs={false}
|
|
85
|
+ sm={4}
|
|
86
|
+ md={7}
|
|
87
|
+ sx={{
|
|
88
|
+ backgroundImage: 'url(https://source.unsplash.com/random)',
|
|
89
|
+ backgroundRepeat: 'no-repeat',
|
|
90
|
+ backgroundColor: (t) =>
|
|
91
|
+ t.palette.mode === 'light' ? t.palette.grey[50] : t.palette.grey[900],
|
|
92
|
+ backgroundSize: 'cover',
|
|
93
|
+ backgroundPosition: 'center',
|
|
94
|
+ }}
|
|
95
|
+ />
|
|
96
|
+ <Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square>
|
|
97
|
+ <Box
|
|
98
|
+ sx={{
|
|
99
|
+ my: 8,
|
|
100
|
+ mx: 4,
|
|
101
|
+ display: 'flex',
|
|
102
|
+ flexDirection: 'column',
|
|
103
|
+ alignItems: 'center',
|
|
104
|
+ }}
|
|
105
|
+ >
|
|
106
|
+ <Avatar sx={{ m: 1, bgcolor: '#fd4b4b' }}>
|
|
107
|
+ <PersonIcon />
|
|
108
|
+ </Avatar>
|
|
109
|
+ <Typography component="h1" variant="h5">
|
|
110
|
+ Ingresar
|
|
111
|
+ </Typography>
|
|
112
|
+ <Box component="form" noValidate onSubmit={handleSubmit} sx={{ mt: 1 }}>
|
|
113
|
+ <TextField
|
|
114
|
+ margin="normal"
|
|
115
|
+ required
|
|
116
|
+ fullWidth
|
|
117
|
+ id="email"
|
|
118
|
+ label="Email Address"
|
|
119
|
+ name="email"
|
|
120
|
+ autoComplete="email"
|
|
121
|
+ autoFocus
|
|
122
|
+ />
|
|
123
|
+ <TextField
|
|
124
|
+ margin="normal"
|
|
125
|
+ required
|
|
126
|
+ fullWidth
|
|
127
|
+ name="password"
|
|
128
|
+ label="Password"
|
|
129
|
+ type="password"
|
|
130
|
+ id="password"
|
|
131
|
+ autoComplete="current-password"
|
|
132
|
+ />
|
|
133
|
+ <FormControlLabel
|
|
134
|
+ control={<Checkbox value="remember" sx={{
|
|
135
|
+ color: '#fd4b4b',
|
|
136
|
+ '&.Mui-checked': {
|
|
137
|
+ color: '#fd4b4b'
|
|
138
|
+ },
|
|
139
|
+ }}/>}
|
|
140
|
+ label="Recordarme"
|
|
141
|
+ />
|
|
142
|
+ <Button
|
|
143
|
+ type="submit"
|
|
144
|
+ fullWidth
|
|
145
|
+ variant="contained"
|
|
146
|
+ sx={{ mt: 3, mb: 2, bgcolor :'#fd4b4b' }}
|
|
147
|
+ >
|
|
148
|
+ Ingresar
|
|
149
|
+ </Button>
|
|
150
|
+ <Grid container>
|
|
151
|
+ <Grid item xs>
|
|
152
|
+ <Link href="#" variant="body2">
|
|
153
|
+ ¿Olvidaste tu contraseña?
|
|
154
|
+ </Link>
|
|
155
|
+ </Grid>
|
|
156
|
+ <Grid item>
|
|
157
|
+ <Link href="#" variant="body2">
|
|
158
|
+ {"¿No tienes cuenta? Regístrate"}
|
|
159
|
+ </Link>
|
|
160
|
+ </Grid>
|
|
161
|
+ </Grid>
|
|
162
|
+ <Copyright sx={{ mt: 5 }} />
|
|
163
|
+ </Box>
|
|
164
|
+ </Box>
|
|
165
|
+ </Grid>
|
|
166
|
+ </Grid>
|
|
167
|
+ </ThemeProvider>
|
|
168
|
+ );
|
25
|
169
|
}
|