|
@@ -1,4 +1,4 @@
|
1
|
|
-import * as React from 'react';
|
|
1
|
+import React, { useEffect, useState, useMemo } from 'react';
|
2
|
2
|
import { styled, createTheme, ThemeProvider } from '@mui/material/styles';
|
3
|
3
|
import CssBaseline from '@mui/material/CssBaseline';
|
4
|
4
|
import MuiDrawer from '@mui/material/Drawer';
|
|
@@ -52,6 +52,26 @@ const AppBar = styled(MuiAppBar, {
|
52
|
52
|
}),
|
53
|
53
|
}));
|
54
|
54
|
|
|
55
|
+const useCheckMobileScreen = () => {
|
|
56
|
+ const [width, setWidth] = useState(window.innerWidth);
|
|
57
|
+ const handleWindowSizeChange = () => {
|
|
58
|
+ let size = window.innerWidth;
|
|
59
|
+ console.log('SIZE >', size)
|
|
60
|
+ setWidth(size);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ useEffect(() => {
|
|
64
|
+ window.addEventListener('resize', handleWindowSizeChange);
|
|
65
|
+ return () => {
|
|
66
|
+ window.removeEventListener('resize', handleWindowSizeChange);
|
|
67
|
+ }
|
|
68
|
+ }, []);
|
|
69
|
+
|
|
70
|
+ let isMobile = width <= 1000
|
|
71
|
+
|
|
72
|
+ return (isMobile);
|
|
73
|
+}
|
|
74
|
+
|
55
|
75
|
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open' })(
|
56
|
76
|
({ theme, open }) => ({
|
57
|
77
|
'& .MuiDrawer-paper': {
|
|
@@ -82,7 +102,8 @@ const mdTheme = createTheme();
|
82
|
102
|
|
83
|
103
|
function DashboardContent() {
|
84
|
104
|
|
85
|
|
- const [open, setOpen] = React.useState(true);
|
|
105
|
+ const [open, setOpen] = React.useState(false);
|
|
106
|
+
|
86
|
107
|
const toggleDrawer = () => setOpen(!open);
|
87
|
108
|
const auth = useAuth();
|
88
|
109
|
const navigate = useNavigate()
|
|
@@ -91,24 +112,34 @@ function DashboardContent() {
|
91
|
112
|
const open_profile = Boolean(anchorEl);
|
92
|
113
|
const handleClick = (event) => setAnchorEl(event.currentTarget);
|
93
|
114
|
const handleClose = () => setAnchorEl(null);
|
|
115
|
+
|
|
116
|
+ const MenuResponsive = () => {
|
|
117
|
+ console.log('show menu responsive')
|
|
118
|
+ }
|
|
119
|
+
|
94
|
120
|
const CerrarSession = () => {
|
95
|
121
|
console.log('cerrando session')
|
96
|
122
|
auth.logout();
|
97
|
123
|
navigate('/')
|
98
|
124
|
}
|
99
|
125
|
|
|
126
|
+
|
100
|
127
|
return (
|
101
|
128
|
<ThemeProvider theme={mdTheme}>
|
102
|
129
|
<Box sx={{ display: 'flex' }}>
|
103
|
130
|
<CssBaseline />
|
104
|
|
- <AppBar style={{ backgroundColor : '#fff', boxShadow : 'None' }} position="absolute" open={open}>
|
|
131
|
+ <AppBar style={{ backgroundColor : '#fff', boxShadow : 'None' }} position="absolute" open={useCheckMobileScreen() ? false : open}>
|
|
132
|
+
|
105
|
133
|
<Toolbar sx={{ pr: '24px' , borderBottom : "1px solid #ec5e69"}} >
|
106
|
134
|
|
107
|
|
- <IconButton style={{
|
108
|
|
- // color : '#212529',
|
109
|
|
- }} edge="start" color="inherit" aria-label="open drawer" onClick={toggleDrawer} sx={{
|
110
|
|
- marginRight: '36px', ...(open && { display: 'none' }),
|
111
|
|
- }} >
|
|
135
|
+ <IconButton
|
|
136
|
+ edge="start"
|
|
137
|
+ color="inherit"
|
|
138
|
+ aria-label="open drawer"
|
|
139
|
+ onClick={ useCheckMobileScreen() ? MenuResponsive : toggleDrawer }
|
|
140
|
+ // onClick={ () => console.log('que estoy haciendo con mi vida') }
|
|
141
|
+ sx={{ marginRight: '36px', ...( !useCheckMobileScreen() && open && { display: 'none' }), }} >
|
|
142
|
+
|
112
|
143
|
<MenuIcon style={{
|
113
|
144
|
background: '#ec5e69',
|
114
|
145
|
fontSize: "40",
|
|
@@ -119,7 +150,7 @@ function DashboardContent() {
|
119
|
150
|
<Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
|
120
|
151
|
|
121
|
152
|
{
|
122
|
|
- open ? (
|
|
153
|
+ !useCheckMobileScreen() && open ? (
|
123
|
154
|
<React.Fragment>
|
124
|
155
|
|
125
|
156
|
<IconButton onClick={toggleDrawer}>
|
|
@@ -201,7 +232,7 @@ function DashboardContent() {
|
201
|
232
|
|
202
|
233
|
<div style={{ flat : 'righ' }} className="sidebar-header">
|
203
|
234
|
<div className="width_img">
|
204
|
|
- <img src={Logo} alt=""/>
|
|
235
|
+ <img src={Logo} alt="pruebas psicometricas"/>
|
205
|
236
|
</div>
|
206
|
237
|
</div>
|
207
|
238
|
|