Proyectos de Subversion LeadersLinked - SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2652 stevensc 1
import React, { useRef, useState } from 'react'
2
import {
3
  Accordion,
4
  AccordionDetails,
5
  AccordionSummary,
6
  Box,
7
  Checkbox,
8
  IconButton,
9
  Menu,
10
  MenuItem,
11
  Typography
12
} from '@mui/material'
13
import {
14
  MoreVert,
15
  RadioButtonUnchecked,
16
  CheckCircle,
17
  ArrowDropDown
18
} from '@mui/icons-material'
19
 
20
import Widget from '@app/components/UI/Widget'
21
import TagsList from '@app/components/UI/TagsList'
22
 
3209 stevensc 23
export default function GoalCard({ goal }) {
2652 stevensc 24
  const [showAction, setShowActions] = useState(false)
25
  const actionsEl = useRef()
26
 
27
  const { title, description, habits } = goal
28
 
29
  const toggleActions = () => setShowActions(!showAction)
30
 
31
  return (
32
    <Widget>
33
      <Widget.Body>
34
        <Box
35
          sx={{
36
            display: 'flex',
37
            gap: 0.5
38
          }}
39
        >
40
          <Box>
41
            <Checkbox
42
              edge='start'
43
              icon={<RadioButtonUnchecked />}
44
              checkedIcon={<CheckCircle color='success' />}
45
              disableRipple
46
              sx={{ borderRadius: '50px' }}
47
            />
48
          </Box>
49
          <Box flexGrow='1'>
50
            <Typography variant='h2'>{title}</Typography>
51
            <Typography>{description}</Typography>
52
 
53
            <Accordion
54
              sx={{ backgroundColor: 'transparent', boxShadow: 'none' }}
55
            >
56
              <AccordionSummary
57
                expandIcon={<ArrowDropDown />}
58
                sx={{ padding: 1 }}
59
              >
60
                <Typography variant='h3'>Hábitos:</Typography>
61
              </AccordionSummary>
62
              <AccordionDetails sx={{ padding: 0 }}>
63
                <TagsList tags={habits} />
64
              </AccordionDetails>
65
            </Accordion>
66
          </Box>
67
          <Box>
68
            <IconButton
69
              id='goal-button'
70
              aria-controls={showAction ? 'goal-menu' : undefined}
71
              aria-haspopup='true'
72
              aria-expanded={showAction ? 'true' : undefined}
73
              onClick={toggleActions}
74
              ref={actionsEl}
75
            >
76
              <MoreVert />
77
            </IconButton>
78
            <Menu
79
              id='goal-menu'
80
              anchorEl={actionsEl.current}
81
              open={showAction}
82
              onClose={toggleActions}
83
              MenuListProps={{
84
                'aria-labelledby': 'goal-button'
85
              }}
86
              anchorOrigin={{
87
                vertical: 'bottom',
88
                horizontal: 'left'
89
              }}
90
              transformOrigin={{
91
                vertical: 'top',
92
                horizontal: 'left'
93
              }}
94
            >
95
              <MenuItem onClick={() => toggleActions()}>Agregar</MenuItem>
96
            </Menu>
97
          </Box>
98
        </Box>
99
      </Widget.Body>
100
    </Widget>
101
  )
102
}