Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6448 Rev 6449
Línea 39... Línea 39...
39
    position: absolute;
39
    position: absolute;
40
    left: 0;
40
    left: 0;
41
    top: 0;
41
    top: 0;
42
    height: 100%;
42
    height: 100%;
43
    width: ${(props) => (props.porcentage ? `${props.porcentage}%` : '0%')};
43
    width: ${(props) => (props.porcentage ? `${props.porcentage}%` : '0%')};
44
    background-color: #0006;
44
    background-color: #0002;
45
    z-index: 4;
45
    z-index: 4;
46
  }
46
  }
Línea 47... Línea 47...
47
 
47
 
48
  &:hover {
48
  &:hover {
Línea 68... Línea 68...
68
`
68
`
Línea 69... Línea 69...
69
 
69
 
70
const SurveyForm = ({
70
const SurveyForm = ({
71
  question,
71
  question,
72
  answers = [],
72
  answers = [],
73
  votes = [],
73
  votes,
74
  active,
74
  active,
75
  time,
75
  time,
76
  resultType,
76
  resultType,
77
  voteUrl,
77
  voteUrl,
78
  addNotification, // Redux action
78
  addNotification, // Redux action
79
  updateFeed, // Redux action
79
  updateFeed, // Redux action
80
}) => {
80
}) => {
81
  const [remainingTime, setRemainingTime] = useState('00:00:00')
81
  const [remainingTime, setRemainingTime] = useState('00:00:00')
82
  const [isActive, setIsActive] = useState(Boolean(active))
82
  const [isActive, setIsActive] = useState(Boolean(active))
-
 
83
  const timeRef = useRef(time)
83
  const timeRef = useRef(time)
84
  const voteRef = useRef(0)
Línea 84... Línea 85...
84
  const { register, handleSubmit } = useForm()
85
  const { register, handleSubmit } = useForm()
85
 
86
 
86
  const sendVote = handleSubmit(({ vote }) => {
87
  const sendVote = handleSubmit(({ vote }) => {
Línea 121... Línea 122...
121
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))
122
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))
122
    const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
123
    const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
123
    const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
124
    const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
Línea 124... Línea 125...
124
 
125
 
125
    // Devolver el resultado
126
    // Devolver el resultado
-
 
127
    return `${addZero(days)}días ${addZero(hours)} horas ${addZero(
-
 
128
      minutes
126
    return `${addZero(days)}:${addZero(hours)}:${addZero(minutes)}`
129
    )} minutos`
Línea 127... Línea 130...
127
  }
130
  }
128
 
131
 
129
  function addZero(unit) {
132
  function addZero(unit) {
Línea 145... Línea 148...
145
    return () => {
148
    return () => {
146
      clearInterval(interval)
149
      clearInterval(interval)
147
    }
150
    }
148
  }, [])
151
  }, [])
Línea -... Línea 152...
-
 
152
 
-
 
153
  useEffect(() => {
-
 
154
    votes && votes.forEach((vote) => (voteRef.current += vote))
-
 
155
  }, [])
149
 
156
 
150
  return (
157
  return (
151
    <form onChange={sendVote} className={styles.survey_form}>
158
    <form onChange={sendVote} className={styles.survey_form}>
152
      <h3>{question}</h3>
159
      <h3>{question}</h3>
153
      {resultType === 'pu' && (
160
      {resultType === 'pu' && (
Línea 162... Línea 169...
162
        </span>
169
        </span>
163
      )}
170
      )}
164
      {answers.map(
171
      {answers.map(
165
        (option, index) =>
172
        (option, index) =>
166
          option && (
173
          option && (
-
 
174
            <RadioButton
167
            <RadioButton disabled={!isActive} porcentage={50} key={index}>
175
              disabled={!isActive}
-
 
176
              porcentage={
-
 
177
                !time && votes && getPorcentage(votes[index], voteRef.current)
-
 
178
              }
-
 
179
              key={index}
-
 
180
            >
168
              <input
181
              <input
169
                type="radio"
182
                type="radio"
170
                name="vote"
183
                name="vote"
171
                id={`vote-${index + 1}`}
184
                id={`vote-${index + 1}`}
172
                disabled={!isActive}
185
                disabled={!isActive}