Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5215 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5207 stevensc 1
/* eslint-disable react/prop-types */
5205 efrain 2
/* eslint-disable camelcase */
3
import React, { useEffect, useState } from 'react'
4
import { axios } from '../../../utils'
5214 stevensc 5
import PulseList from './PulseList'
5205 efrain 6
 
5206 stevensc 7
const DailyPulse = ({ routeDailyPulse }) => {
5205 efrain 8
  const [emojisHowAreYouFeel, setEmojisHowAreYouFeel] = useState([])
9
  const [emojisClimateOnYourOrganization, setEmojisClimateOnYourOrganization] = useState([])
10
 
11
  const getData = async (url = routeDailyPulse) => {
12
    try {
13
      const { data: response } = await axios.get(url)
14
      if (response.success) {
5206 stevensc 15
        setEmojisHowAreYouFeel(response.data.emojis_how_are_you_feel)
16
        setEmojisClimateOnYourOrganization(response.data.emojis_climate_on_your_organization)
17
      }
5205 efrain 18
    } catch (error) {
19
      console.log(error)
20
    }
21
  }
22
 
23
  useEffect(() => {
24
    getData()
25
  }, [])
26
 
27
  return (
5215 stevensc 28
    <div className='daily_pulse-widget'>
29
      <h3>Pulso Diario</h3>
30
      <PulseList options={emojisHowAreYouFeel} title='¿Como te sientes hoy?' onComplete={getData} />
31
      <PulseList options={emojisClimateOnYourOrganization} title='¿Como esta el clima en la organización?' onComplete={getData} />
5205 efrain 32
    </div>
33
  )
34
}
35
 
36
export default DailyPulse