Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6437 Rev 6438
Línea 19... Línea 19...
19
  resultType,
19
  resultType,
20
  voteUrl,
20
  voteUrl,
21
  addNotification, // Redux action
21
  addNotification, // Redux action
22
  updateFeed, // Redux action
22
  updateFeed, // Redux action
23
}) => {
23
}) => {
24
  const [remainingTime, setRemainingTime] = useState({
24
  const [remainingTime, setRemainingTime] = useState('00:00:00')
25
    days: 0,
-
 
26
    hours: 0,
-
 
27
    minutes: 0,
-
 
28
  })
-
 
29
  const [isActive, setIsActive] = useState(Boolean(active))
25
  const [isActive, setIsActive] = useState(Boolean(active))
30
  const timeRef = useRef(time)
26
  const timeRef = useRef(time)
31
  const { register, handleSubmit } = useForm()
27
  const { register, handleSubmit } = useForm()
Línea 32... Línea 28...
32
 
28
 
Línea 68... Línea 64...
68
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))
64
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))
69
    const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
65
    const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
70
    const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
66
    const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
Línea 71... Línea 67...
71
 
67
 
-
 
68
    // Devolver el resultado
-
 
69
    return `${addZero(days)}:${addZero(hours)}:${addZero(minutes)}`
-
 
70
  }
-
 
71
 
72
    // Devolver el resultado
72
  function addZero(unit) {
73
    return { days, hours, minutes }
73
    return String(unit).padStart(2, '0')
Línea 74... Línea 74...
74
  }
74
  }
75
 
75
 
76
  useEffect(() => {
-
 
Línea 77... Línea -...
77
    setRemainingTime(getTimeDiff(time))
-
 
78
  }, [])
76
  useEffect(() => {
79
 
77
    setRemainingTime(getTimeDiff(time))
80
  useEffect(() => {
78
 
81
    const interval = setInterval(() => {
79
    const interval = setInterval(() => {
Línea 122... Línea 120...
122
              />
120
              />
123
              <label htmlFor={`vote-${index + 1}`}>{option}</label>
121
              <label htmlFor={`vote-${index + 1}`}>{option}</label>
124
            </div>
122
            </div>
125
          )
123
          )
126
      )}
124
      )}
127
      <span>
-
 
128
        Tiempo restante:{' '}
-
 
129
        {Boolean(remainingTime.days) && remainingTime.days + ':'}
-
 
130
        {Boolean(remainingTime.hours) && remainingTime.hours + ':'}
-
 
131
        {Boolean(remainingTime.minutes) && remainingTime.minutes}
125
      <span>Tiempo restante: {remainingTime}</span>
132
      </span>
-
 
133
    </form>
126
    </form>
134
  )
127
  )
135
}
128
}
Línea 136... Línea 129...
136
 
129