Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2506 stevensc 1
import React, { useContext, useRef, useState } from 'react'
2
import { DataGrid } from '@mui/x-data-grid'
3
import { IconButton, Menu, MenuItem } from '@mui/material'
4
import { MoreVert } from '@mui/icons-material'
5
 
6
import { ValuesContext } from '@app/contexts/values'
7
import Widget from '@app/components/UI/Widget'
8
 
9
export default function Values() {
10
  const { values, toggleModal } = useContext(ValuesContext)
11
  const [open, setOpen] = useState(false)
12
  const actionsEl = useRef()
13
 
14
  const toggleActions = () => setOpen(!open)
15
 
16
  const columns = [{ field: 'description', headerName: 'Descripción' }]
17
 
18
  return (
19
    <>
20
      <Widget>
21
        <Widget.Header
22
          title='Valores'
23
          renderAction={() => (
24
            <>
25
              <IconButton
26
                id='values-button'
27
                aria-controls={open ? 'values-menu' : undefined}
28
                aria-haspopup='true'
29
                aria-expanded={open ? 'true' : undefined}
30
                onClick={toggleActions}
31
                ref={actionsEl}
32
              >
33
                <MoreVert />
34
              </IconButton>
35
              <Menu
36
                id='values-menu'
37
                anchorEl={actionsEl.current}
38
                open={open}
39
                onClose={toggleActions}
40
                MenuListProps={{
41
                  'aria-labelledby': 'values-button'
42
                }}
43
                anchorOrigin={{
44
                  vertical: 'bottom',
2508 stevensc 45
                  horizontal: 'left'
2506 stevensc 46
                }}
47
                transformOrigin={{
48
                  vertical: 'top',
49
                  horizontal: 'left'
50
                }}
51
              >
52
                <MenuItem
53
                  onClick={() => {
54
                    toggleModal()
55
                    toggleActions()
56
                  }}
57
                >
58
                  Agregar
59
                </MenuItem>
60
              </Menu>
61
            </>
62
          )}
63
        />
64
        <Widget.Body>
65
          <DataGrid
66
            rows={values}
67
            columns={columns}
68
            initialState={{
69
              pagination: {
70
                paginationModel: { page: 0, pageSize: 10 }
71
              }
72
            }}
73
            pageSizeOptions={[10]}
74
          />
75
        </Widget.Body>
76
      </Widget>
77
    </>
78
  )
79
}