|
@@ -2,10 +2,9 @@ import * as React from 'react';
|
2
|
2
|
import toast, { Toaster } from 'react-hot-toast';
|
3
|
3
|
import { useNavigate } from 'react-router-dom'
|
4
|
4
|
import jwt_decode from "jwt-decode";
|
5
|
|
-import {
|
6
|
|
- // useSelector,
|
7
|
|
- useDispatch } from "react-redux";
|
8
|
|
-// import { connect } from 'react-redux';
|
|
5
|
+import { useSelector, useDispatch } from "react-redux";
|
|
6
|
+
|
|
7
|
+import { setToken } from '../Slices/tokenSlice'
|
9
|
8
|
|
10
|
9
|
import {
|
11
|
10
|
Paper, Box, Grid, Typography, TextField, Button, Avatar,
|
|
@@ -22,7 +21,7 @@ import { useFormik } from 'formik';
|
22
|
21
|
import * as Yup from 'yup';
|
23
|
22
|
|
24
|
23
|
import { Service } from '../Utils/HTTP.js'
|
25
|
|
-import { setToken } from '../Actions/index.js';
|
|
24
|
+// import { setToken } from '../Actions/index.js';
|
26
|
25
|
|
27
|
26
|
const LoginSchema = Yup.object().shape({
|
28
|
27
|
email: Yup
|
|
@@ -43,7 +42,7 @@ export function LoginCs() {
|
43
|
42
|
let navigate = useNavigate()
|
44
|
43
|
|
45
|
44
|
const [open, setOpen] = React.useState(false);
|
46
|
|
- // const token = useSelector(state => state.token)
|
|
45
|
+ const token = useSelector(state => state.token)
|
47
|
46
|
const dispatch = useDispatch();
|
48
|
47
|
const handleClose = () => false
|
49
|
48
|
|
|
@@ -71,7 +70,7 @@ export function LoginCs() {
|
71
|
70
|
let { token, nombre, apelidos, id: pass_id } = response;
|
72
|
71
|
toast.success(`Bienvenido ${nombre} ${apelidos}!!`)
|
73
|
72
|
token = token.replace("Bearer ", "")
|
74
|
|
- console.log(token);
|
|
73
|
+ // console.log(token);
|
75
|
74
|
|
76
|
75
|
// let { exp } = jwt_decode(token);
|
77
|
76
|
let body_token = jwt_decode(token);
|
|
@@ -108,6 +107,7 @@ export function LoginCs() {
|
108
|
107
|
});
|
109
|
108
|
|
110
|
109
|
React.useEffect(() => {
|
|
110
|
+ console.log('TOKEN: ', token)
|
111
|
111
|
if (auth.isLogged()) {
|
112
|
112
|
return navigate('/user/home')
|
113
|
113
|
}
|