Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3079 Rev 3081
Línea 1... Línea 1...
1
import React, { useMemo } from 'react'
1
import React, { useMemo } from 'react'
2
import { useForm } from 'react-hook-form'
2
import { Controller, useForm } from 'react-hook-form'
3
import {
3
import {
4
  FormControlLabel,
4
  FormControlLabel,
5
  Radio,
5
  Radio,
6
  RadioGroup,
6
  RadioGroup,
7
  styled,
7
  styled,
Línea 13... Línea 13...
13
import { getTimeDiff } from '@utils/dates'
13
import { getTimeDiff } from '@utils/dates'
14
import { updateFeed } from '@store/feed/feed.actions'
14
import { updateFeed } from '@store/feed/feed.actions'
15
import { addNotification } from '@store/notification/notification.actions'
15
import { addNotification } from '@store/notification/notification.actions'
Línea 16... Línea 16...
16
 
16
 
-
 
17
import Widget from '@components/UI/Widget'
Línea 17... Línea 18...
17
import Widget from '@components/UI/Widget'
18
import FormErrorFeedback from '@components/UI/form/FormErrorFeedback'
18
 
19
 
19
const AnswerContainer = styled('div')`
20
const AnswerContainer = styled('div')`
20
  display: flex;
21
  display: flex;
Línea 106... Línea 107...
106
            <LockClock sx={{ fontSize: '1.3rem' }} /> Privado
107
            <LockClock sx={{ fontSize: '1.3rem' }} /> Privado
107
          </Typography>
108
          </Typography>
108
        )}
109
        )}
Línea 109... Línea 110...
109
 
110
 
-
 
111
        <form onChange={sendVote}>
-
 
112
          <Controller
-
 
113
            name='vote'
110
        <form onChange={sendVote}>
114
            control={control}
-
 
115
            rules={{ required: 'Por favor seleccione una opción' }}
-
 
116
            defaultValue=''
-
 
117
            disabled={!active}
-
 
118
            render={({ field, fieldState: { error } }) => (
-
 
119
              <>
111
          <RadioGroup defaultValue='female' name='customized-radios'>
120
                <RadioGroup {...field}>
112
            {answers.map((answer, index) => {
121
                  {answers.map((answer, index) => {
113
              if (answer === null) return null
122
                    if (answer === null) return null
114
 
123
 
115
              return (
124
                    return (
116
                <AnswerContainer
125
                      <AnswerContainer
117
                  key={answer}
126
                        key={answer}
118
                  sx={{
127
                        sx={{
119
                    '::before': {
128
                          '::before': {
120
                      content: '',
129
                            content: '',
121
                      position: 'absolute',
130
                            position: 'absolute',
122
                      left: 0,
131
                            left: 0,
123
                      top: 0,
132
                            top: 0,
124
                      height: '100%',
133
                            height: '100%',
125
                      backgroundColor: '#0002',
134
                            backgroundColor: '#0002',
126
                      zIndex: 4,
135
                            zIndex: 4,
127
                      width: totalVotes
136
                            width: totalVotes
128
                        ? `${getPorcentage(votes[index], totalVotes)}%`
137
                              ? `${getPorcentage(votes[index], totalVotes)}%`
129
                        : 0
138
                              : 0
130
                    }
139
                          }
131
                  }}
140
                        }}
132
                >
141
                      >
133
                  <FormControlLabel
142
                        <FormControlLabel
134
                    value={index + 1}
143
                          value={index + 1}
135
                    control={<Radio sx={{ padding: 0 }} />}
144
                          control={<Radio sx={{ padding: 0 }} />}
136
                    label={answer}
145
                          label={answer}
-
 
146
                          sx={{ margin: 0, gap: 1 }}
137
                    sx={{ margin: 0, gap: 1 }}
147
                          disabled={field.disabled}
138
                  />
148
                        />
139
 
149
 
140
                  {totalVotes ? (
150
                        {totalVotes ? (
141
                    <Typography variant='overline'>
151
                          <Typography variant='overline'>
142
                      {getPorcentage(votes[index], totalVotes)}%
152
                            {getPorcentage(votes[index], totalVotes)}%
143
                    </Typography>
153
                          </Typography>
144
                  ) : null}
154
                        ) : null}
-
 
155
                      </AnswerContainer>
-
 
156
                    )
-
 
157
                  })}
-
 
158
                </RadioGroup>
-
 
159
                {error && (
145
                </AnswerContainer>
160
                  <FormErrorFeedback>{error.message}</FormErrorFeedback>
-
 
161
                )}
146
              )
162
              </>
147
            })}
163
            )}
Línea 148... Línea 164...
148
          </RadioGroup>
164
          />
149
 
165
 
150
          <Typography variant='overline'>
166
          <Typography variant='overline'>