Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 813 Rev 814
Línea 69... Línea 69...
69
  color: var(--font-color) !important;
69
  color: var(--font-color) !important;
70
  font-weight: 600;
70
  font-weight: 600;
71
`
71
`
Línea 72... Línea 72...
72
 
72
 
-
 
73
const SurveyForm = ({
73
const SurveyForm = ({
74
  active = false,
74
  question,
75
  question,
75
  answers = [],
76
  answers = [],
76
  votes,
-
 
77
  active = false,
77
  votes,
78
  time,
78
  time,
79
  resultType,
79
  resultType,
80
  voteUrl,
80
  voteUrl,
81
  addNotification, // Redux action
81
  addNotification, // Redux action
Línea 97... Línea 97...
97
      .post(voteUrl, formData)
97
      .post(voteUrl, formData)
98
      .then(({ data: response }) => {
98
      .then(({ data: response }) => {
99
        const { success, data } = response
99
        const { success, data } = response
Línea 100... Línea 100...
100
 
100
 
-
 
101
        if (!success) {
-
 
102
          const errorMessage =
-
 
103
            typeof data === 'string'
101
        if (!success) {
104
              ? data
102
          addNotification({ style: 'danger', msg: `Error: ${data}` })
105
              : 'Error interno, por favor intente mas tarde.'
103
          setIsActive(true)
106
          throw new Error(errorMessage)
Línea 104... Línea 107...
104
        }
107
        }
105
 
108
 
106
        updateFeed({ feed: data, uuid: data.feed_uuid })
109
        updateFeed({ feed: data, uuid: data.feed_uuid })
107
        addNotification({ style: 'success', msg: 'Voto emitido con exito' })
110
        addNotification({ style: 'success', msg: 'Voto emitido con exito' })
108
      })
-
 
109
      .catch((err) => {
111
      })
110
        addNotification({ style: 'danger', msg: `Error: ${err}` })
112
      .catch((err) => {
111
        setIsActive(true)
113
        setIsActive(true)
112
        throw new Error(err)
114
        addNotification({ style: 'danger', msg: err.message })
Línea 113... Línea 115...
113
      })
115
      })
114
  })
-
 
115
 
116
  })
116
  function getTimeDiff(segundos) {
-
 
117
    // Obtener la fecha y hora actual
-
 
118
    const currentDate = new Date()
117
 
119
 
-
 
120
    // Calcular la fecha y hora futura sumando los segundos proporcionados
-
 
121
    const futureDate = new Date(currentDate.getTime() + segundos * 1000)
118
  function getTimeDiff(segundos) {
Línea 122... Línea -...
122
 
-
 
123
    // Calcular la diferencia entre la fecha futura y la fecha actual
119
    const currentDate = new Date()
124
    const diff = futureDate - currentDate
120
    const futureDate = new Date(currentDate.getTime() + segundos * 1000)
125
 
121
    const diff = futureDate - currentDate
Línea 126... Línea -...
126
    // Calcular los componentes de la diferencia de tiempo
-
 
127
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))
122
 
128
    const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
123
    const days = Math.floor(diff / (1000 * 60 * 60 * 24))
Línea 129... Línea 124...
129
    const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
124
    const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
130
 
125
    const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
Línea 166... Línea 161...
166
      clearInterval(interval)
161
      clearInterval(interval)
167
    }
162
    }
168
  }, [])
163
  }, [])
Línea 169... Línea 164...
169
 
164
 
-
 
165
  useEffect(() => {
170
  useEffect(() => {
166
    const total = votes.reduce((acum, current) => {
-
 
167
      if (!current) {
-
 
168
        return acum
-
 
169
      }
171
    if (!votes) return
170
 
-
 
171
      return acum + Number(current)
-
 
172
    }, 0)
172
    const total = votes.reduce((acum, current) => acum + Number(current), 0)
173
 
173
    setTotalVotes(total)
174
    setTotalVotes(total)
Línea 174... Línea 175...
174
  }, [votes])
175
  }, [votes])
175
 
176
 
176
  useEffect(() => {
177
  useEffect(() => {
Línea 177... Línea 178...
177
    setIsActive(Boolean(active))
178
    setIsActive(!!active)
178
  }, [active])
179
  }, [active])
179
 
180