|
@@ -1,13 +1,11 @@
|
1
|
|
-import React, { useEffect, useState, useRef } from 'react';
|
2
|
|
-import { styled, createTheme, ThemeProvider } from '@mui/material/styles';
|
|
1
|
+import React from 'react';
|
|
2
|
+import {createTheme, ThemeProvider } from '@mui/material/styles';
|
3
|
3
|
|
4
|
4
|
import { MainListItems, secondaryListItems } from './listItems';
|
5
|
5
|
import {
|
6
|
6
|
Menu,MenuItem,Container,Avatar, Badge,IconButton,Divider,
|
7
|
|
- Typography, List, Toolbar, AppBar as MuiAppBar, Box, Drawer as MuiDrawer,
|
8
|
|
- CssBaseline,
|
|
7
|
+ Typography, List, Toolbar, Box, CssBaseline,useMediaQuery as Size
|
9
|
8
|
} from '@mui/material'
|
10
|
|
-
|
11
|
9
|
import {
|
12
|
10
|
Mail as MailIcon, Notifications as NotificationsIcon, Fullscreen as FullscreenIcon,
|
13
|
11
|
Menu as MenuIcon,
|
|
@@ -18,105 +16,29 @@ import ProfilePicture from '../Images/man.png';
|
18
|
16
|
|
19
|
17
|
import useAuth from '../Auth/useAuth';
|
20
|
18
|
import { Outlet, useNavigate} from "react-router-dom";
|
21
|
|
-// import { MenuMovil } from '../Components/MenuMovil';
|
22
|
19
|
import { MenuMovil } from '../Components/Navigation/MenuMovil';
|
23
|
20
|
import Footer from "../Components/Footer";
|
24
|
|
-
|
25
|
|
-
|
26
|
|
-const drawerWidth = 240;
|
27
|
|
-
|
28
|
|
-const AppBar = styled(MuiAppBar, {
|
29
|
|
- shouldForwardProp: (prop) => prop !== 'open',
|
30
|
|
-})(({ theme, open }) => ({
|
31
|
|
- zIndex: theme.zIndex.drawer + 1,
|
32
|
|
- transition: theme.transitions.create(['width', 'margin'], {
|
33
|
|
- easing: theme.transitions.easing.sharp,
|
34
|
|
- duration: theme.transitions.duration.leavingScreen,
|
35
|
|
- }),
|
36
|
|
- ...(open && {
|
37
|
|
- marginLeft: drawerWidth,
|
38
|
|
- width: `calc(100% - ${drawerWidth}px)`,
|
39
|
|
- transition: theme.transitions.create(['width', 'margin'], {
|
40
|
|
- easing: theme.transitions.easing.sharp,
|
41
|
|
- duration: theme.transitions.duration.enteringScreen,
|
42
|
|
- }),
|
43
|
|
- }),
|
44
|
|
-}));
|
45
|
|
-
|
46
|
|
-const useCheckMobileScreen = () => {
|
47
|
|
- const [width, setWidth] = useState(window.innerWidth);
|
48
|
|
- const handleWindowSizeChange = () => {
|
49
|
|
- let size = window.innerWidth;
|
50
|
|
- setWidth(size);
|
51
|
|
- }
|
52
|
|
-
|
53
|
|
- useEffect(() => {
|
54
|
|
- window.addEventListener('resize', handleWindowSizeChange);
|
55
|
|
- return () => {
|
56
|
|
- window.removeEventListener('resize', handleWindowSizeChange);
|
57
|
|
- document.getElementById("mySidebar").style.display = "block";
|
58
|
|
- }
|
59
|
|
- }, []);
|
60
|
|
-
|
61
|
|
- let isMobile = width <= 1000
|
62
|
|
-
|
63
|
|
- return (isMobile);
|
64
|
|
-}
|
65
|
|
-
|
66
|
|
-const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open' })(
|
67
|
|
- ({ theme, open }) => ({
|
68
|
|
- '& .MuiDrawer-paper': {
|
69
|
|
- position: 'relative',
|
70
|
|
- whiteSpace: 'nowrap',
|
71
|
|
- width: drawerWidth,
|
72
|
|
- transition: theme.transitions.create('width', {
|
73
|
|
- easing: theme.transitions.easing.sharp,
|
74
|
|
- duration: theme.transitions.duration.enteringScreen,
|
75
|
|
- }),
|
76
|
|
- boxSizing: 'border-box',
|
77
|
|
- ...(!open && {
|
78
|
|
- overflowX: 'hidden',
|
79
|
|
- transition: theme.transitions.create('width', {
|
80
|
|
- easing: theme.transitions.easing.sharp,
|
81
|
|
- duration: theme.transitions.duration.leavingScreen,
|
82
|
|
- }),
|
83
|
|
- width: theme.spacing(7),
|
84
|
|
- [theme.breakpoints.up('sm')]: {
|
85
|
|
- width: theme.spacing(9),
|
86
|
|
- },
|
87
|
|
- }),
|
88
|
|
- },
|
89
|
|
- }),
|
90
|
|
-);
|
|
21
|
+import { Drawer, AppBar } from "../Components/Navigation/AppBar"
|
91
|
22
|
|
92
|
23
|
const mdTheme = createTheme();
|
93
|
24
|
|
94
|
25
|
function DashboardContent() {
|
95
|
26
|
|
96
|
27
|
const [open, setOpen] = React.useState(false);
|
97
|
|
- const elRef = useRef();
|
98
|
|
-
|
|
28
|
+ const isMovil = Size('(min-width:770px)');
|
99
|
29
|
|
100
|
30
|
const toggleDrawer = () => setOpen(!open);
|
101
|
31
|
const auth = useAuth();
|
102
|
32
|
const navigate = useNavigate()
|
103
|
33
|
|
104
|
34
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
105
|
|
-
|
106
|
35
|
const open_profile = Boolean(anchorEl);
|
107
|
36
|
const handleClick = (event) => setAnchorEl(event.currentTarget);
|
108
|
37
|
const handleClose = () => setAnchorEl(null)
|
109
|
38
|
|
110
|
39
|
const [anchorElMovil, setAnchorElMov] = React.useState(false);
|
111
|
40
|
|
112
|
|
- const handleCloseMov = () => {
|
113
|
|
- setAnchorElMov(null);
|
114
|
|
- };
|
115
|
|
-
|
116
|
41
|
const MenuResponsive = () => {
|
117
|
|
- if(!anchorElMovil){
|
118
|
|
- // document.getElementsByTagName("MuiToolbar-root ").style.display = "none";
|
119
|
|
- }
|
120
|
42
|
setAnchorElMov(!anchorElMovil);
|
121
|
43
|
}
|
122
|
44
|
|
|
@@ -128,39 +50,27 @@ function DashboardContent() {
|
128
|
50
|
|
129
|
51
|
return (
|
130
|
52
|
<ThemeProvider theme={mdTheme}>
|
131
|
|
-
|
132
|
53
|
<MenuMovil anchor={anchorElMovil}/>
|
133
|
|
-
|
134
|
|
-
|
135
|
54
|
<Box sx={{ display: 'flex' }}>
|
136
|
55
|
<CssBaseline/>
|
137
|
|
- <AppBar style={{ backgroundColor : '#fff', boxShadow : 'None' }} position="absolute" open={useCheckMobileScreen() ? false : open}>
|
138
|
|
-
|
|
56
|
+ <AppBar style={{ backgroundColor : '#fff', boxShadow : 'None' }} position="absolute" open={ !isMovil ? open : false}>
|
139
|
57
|
<Toolbar sx={{ pr: '24px' , borderBottom : "1px solid #ec5e69"}} >
|
140
|
|
-
|
141
|
|
- <div ref={elRef}>
|
142
|
|
-
|
143
|
|
- <IconButton
|
144
|
|
- edge="start"
|
145
|
|
- color="inherit"
|
146
|
|
- aria-label="open drawer"
|
147
|
|
- onClick={ useCheckMobileScreen() ? MenuResponsive : toggleDrawer }
|
148
|
|
- sx={{ marginRight: '36px', ...( !useCheckMobileScreen() && open && { display: 'none' }), }} >
|
149
|
|
- <MenuIcon style={{
|
150
|
|
- background: '#ec5e69',
|
151
|
|
- fontSize: "40",
|
152
|
|
- color: "#fff"
|
153
|
|
- }}/>
|
154
|
|
- </IconButton>
|
155
|
|
-
|
156
|
|
-
|
157
|
|
-
|
158
|
|
-
|
159
|
|
- </div>
|
160
|
|
-
|
|
58
|
+ {/* boton para activar navegacion */}
|
|
59
|
+ <IconButton
|
|
60
|
+ edge="start"
|
|
61
|
+ color="inherit"
|
|
62
|
+ aria-label="open drawer"
|
|
63
|
+ onClick={ !isMovil ? MenuResponsive : toggleDrawer }
|
|
64
|
+ sx={{ marginRight: '36px', ...( !isMovil && open && { display: 'none' }), }} >
|
|
65
|
+ <MenuIcon style={{
|
|
66
|
+ background: '#ec5e69',
|
|
67
|
+ fontSize: "40",
|
|
68
|
+ color: "#fff"
|
|
69
|
+ }}/>
|
|
70
|
+ </IconButton>
|
161
|
71
|
<Typography component="h1" variant="h6" color="inherit" noWrap sx={{ flexGrow: 1 }} >
|
162
|
72
|
{
|
163
|
|
- !useCheckMobileScreen() && open ? (
|
|
73
|
+ !isMovil && open ? (
|
164
|
74
|
<React.Fragment>
|
165
|
75
|
|
166
|
76
|
<IconButton onClick={toggleDrawer}>
|