Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5012 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5012 Rev 6248
Línea 10... Línea 10...
10
import AccordionSummary from '@mui/material/AccordionSummary'
10
import AccordionSummary from '@mui/material/AccordionSummary'
11
import AccordionDetails from '@mui/material/AccordionDetails'
11
import AccordionDetails from '@mui/material/AccordionDetails'
12
import Link from '@mui/material/Link'
12
import Link from '@mui/material/Link'
13
import Typography from '@mui/material/Typography'
13
import Typography from '@mui/material/Typography'
14
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
14
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
15
import AccountTreeRoundedIcon from '@mui/icons-material/AccountTreeRounded';
15
import AccountTreeRoundedIcon from '@mui/icons-material/AccountTreeRounded'
-
 
16
import { axios } from '../../../utils'
Línea -... Línea 17...
-
 
17
 
-
 
18
function MenuDrawer({
-
 
19
  isOpen = false,
-
 
20
  items = [],
16
 
21
  icons = [],
17
function MenuDrawer({ isOpen = false, items = [], icons = [], closeDrawer = () => { } }) {
22
  closeDrawer = () => {},
18
 
23
}) {
19
    return (
24
  return (
20
        <Drawer anchor='right' open={isOpen} onClose={closeDrawer}>
25
    <Drawer anchor="right" open={isOpen} onClose={closeDrawer}>
21
            <Box sx={{ width: 250 }} role="presentation">
26
      <Box sx={{ width: 250 }} role="presentation">
22
                <List>
27
        <List>
23
                    {items.map((navItem, index) => {
28
          {items.map((navItem, index) => {
24
                        return (
29
            return (
25
                            <MenuDrawer.Item
30
              <MenuDrawer.Item
26
                                key={index}
31
                key={index}
27
                                Icon={icons[index]}
32
                Icon={icons[index]}
28
                                title={navItem.label}
33
                title={navItem.label}
29
                                url={navItem.href}
34
                url={navItem.href}
-
 
35
                childs={navItem.childs}
30
                                childs={navItem.childs}
36
                ajaxRequest={navItem.ajax}
31
                            />
37
              />
32
                        )
38
            )
33
                    })}
39
          })}
34
                </List>
40
        </List>
35
            </Box>
-
 
36
 
41
      </Box>
37
        </Drawer>
42
    </Drawer>
38
    )
43
  )
Línea 39... Línea 44...
39
}
44
}
-
 
45
 
-
 
46
const Item = ({ Icon, title, url, childs = [], ajax }) => {
-
 
47
  const handleAjaxRequest = async () => {
-
 
48
    try {
-
 
49
      const { data } = await axios.get(url)
-
 
50
      if (data.success) {
-
 
51
        window.open(data.data, 'backend')
-
 
52
      }
-
 
53
    } catch (error) {
-
 
54
      console.log('>>: error > ', error)
-
 
55
    }
40
 
56
  }
41
const Item = ({ Icon, title, url, childs = [] }) => {
57
 
42
    return (
58
  return (
-
 
59
    <ListItem disablePadding>
-
 
60
      {!childs.length ? (
-
 
61
        <Link
43
        <ListItem disablePadding>
62
          href={`/${url}`}
44
            {!childs.length
63
          display="flex"
-
 
64
          gap=".5rem"
-
 
65
          paddingLeft="1rem"
45
                ?
66
          onClick={(e) => {
46
                <Link href={`/${url}`} display='flex' gap='.5rem' paddingLeft='1rem'>
67
            if (ajax) {
-
 
68
              e.preventDefault()
-
 
69
              handleAjaxRequest()
-
 
70
            }
47
                    <ListItemIcon>
71
          }}
48
                        {Icon && <Icon />}
72
        >
49
                    </ListItemIcon>
73
          <ListItemIcon>{Icon && <Icon />}</ListItemIcon>
50
                    <ListItemText primary={title} />
74
          <ListItemText primary={title} />
51
                </Link>
75
        </Link>
-
 
76
      ) : (
-
 
77
        <Accordion sx={{ border: 'none', width: '100%', boxShadow: 'none' }}>
-
 
78
          <AccordionSummary
-
 
79
            expandIcon={<ExpandMoreIcon />}
-
 
80
            sx={{
-
 
81
              minHeight: 'auto !important',
-
 
82
              margin: '0',
-
 
83
              padding: 0,
-
 
84
              paddingLeft: '1rem',
-
 
85
            }}
-
 
86
          >
-
 
87
            {Icon && <Icon />}
-
 
88
            <Typography margin="0">{title}</Typography>
-
 
89
          </AccordionSummary>
-
 
90
          <AccordionDetails sx={{ padding: 0 }}>
-
 
91
            {childs.map((child, index) => {
-
 
92
              if (child.childs?.length) {
-
 
93
                return (
-
 
94
                  <Accordion
-
 
95
                    key={index}
-
 
96
                    sx={{
-
 
97
                      border: 'none',
-
 
98
                      width: '100%',
-
 
99
                      boxShadow: 'none',
-
 
100
                      background: 'lightgray',
52
                :
101
                    }}
53
                <Accordion sx={{ border: 'none', width: '100%', boxShadow: 'none' }}>
102
                  >
54
                    <AccordionSummary
103
                    <AccordionSummary
55
                        expandIcon={<ExpandMoreIcon />}
104
                      expandIcon={<ExpandMoreIcon />}
56
                        sx={{ minHeight: 'auto !important', margin: '0', padding: 0, paddingLeft: '1rem' }}
105
                      sx={{ minHeight: 'auto !important', margin: '0' }}
57
                    >
106
                    >
58
                        {Icon && <Icon />}
107
                      <AccountTreeRoundedIcon />
59
                        <Typography margin='0'>{title}</Typography>
108
                      <Typography margin="0">{child.label}</Typography>
60
                    </AccordionSummary>
109
                    </AccordionSummary>
61
                    <AccordionDetails sx={{ padding: 0 }}>
-
 
62
                        {childs.map((child, index) => {
110
                    <AccordionDetails sx={{ padding: '0 16px' }}>
63
                            if (child.childs?.length) {
-
 
64
                                return (
-
 
65
                                    <Accordion key={index} sx={{ border: 'none', width: '100%', boxShadow: 'none', background: 'lightgray' }}>
-
 
66
                                        <AccordionSummary
-
 
67
                                            expandIcon={<ExpandMoreIcon />}
-
 
68
                                            sx={{ minHeight: 'auto !important', margin: '0' }}
-
 
69
                                        >
-
 
70
                                            <AccountTreeRoundedIcon />
-
 
71
                                            <Typography margin='0'>{child.label}</Typography>
-
 
72
                                        </AccordionSummary>
-
 
73
                                        <AccordionDetails sx={{ padding: '0 16px' }}>
-
 
74
                                            {child.childs.map((levelThree, index) => {
111
                      {child.childs.map((levelThree, index) => {
75
                                                return (
112
                        return (
76
                                                    <Link key={index} href={`/${levelThree.href}`} >
-
 
77
                                                        <ListItemText primary={levelThree.label} />
-
 
78
                                                    </Link>
-
 
79
                                                )
-
 
80
                                            })}
-
 
81
                                        </AccordionDetails>
-
 
82
                                    </Accordion>
-
 
83
                                )
-
 
84
                            }
-
 
85
                            return (
-
 
86
                                <Link key={index} href={child.href[0] === '/' ? child.href : `/${child.href}`}>
113
                          <Link key={index} href={`/${levelThree.href}`}>
87
                                    <ListItemText primary={child.label} sx={{ padding: '0 16px' }} />
114
                            <ListItemText primary={levelThree.label} />
88
                                </Link>
115
                          </Link>
89
                            )
116
                        )
90
                        })}
117
                      })}
-
 
118
                    </AccordionDetails>
-
 
119
                  </Accordion>
-
 
120
                )
-
 
121
              }
-
 
122
              return (
-
 
123
                <Link
-
 
124
                  key={index}
-
 
125
                  href={child.href[0] === '/' ? child.href : `/${child.href}`}
-
 
126
                >
-
 
127
                  <ListItemText
-
 
128
                    primary={child.label}
-
 
129
                    sx={{ padding: '0 16px' }}
-
 
130
                  />
91
                    </AccordionDetails>
131
                </Link>
-
 
132
              )
-
 
133
            })}
92
                </Accordion>
134
          </AccordionDetails>
93
            }
135
        </Accordion>
94
 
136
      )}
95
        </ListItem>
137
    </ListItem>
Línea 96... Línea 138...
96
    )
138
  )
Línea 97... Línea -...
97
}
-
 
98
 
139
}
-
 
140