Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5206 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
5205 efrain 1
/* eslint-disable camelcase */
2
import React, { useEffect, useState } from 'react'
3
import { useDispatch } from 'react-redux'
4
import { addNotification } from '../../../redux/notification/notification.actions'
5
import { axios } from '../../../utils'
6
 
7
 
8
const DailyPulse =  ({ routeDailyPulse }) => {
9
  const [points, setPoints] = useState(0)
10
  const [emojisHowAreYouFeel, setEmojisHowAreYouFeel] = useState([])
11
  const [emojisClimateOnYourOrganization, setEmojisClimateOnYourOrganization] = useState([])
12
  const dispatch = useDispatch()
13
 
14
  const handleEmojiSave = (url) => {
15
 
16
 
17
	  if(url == '') {
18
		  return false;
19
	  }
20
 
21
 
22
    axios.post(url)
23
      .then(({ data }) => {
24
        if (!data.success) {
25
          return dispatch(addNotification({
26
            style: 'danger',
27
            msg: typeof data.data === 'string'
28
              ? data.data
29
              : 'Ha ocurrido un error'
30
          }))
31
        }
32
 
33
 
34
        return getData()
35
      })
36
  }
37
 
38
 
39
  const getData = async (url = routeDailyPulse) => {
40
    try {
41
      const { data: response } = await axios.get(url)
42
      if (response.success) {
43
 
44
 
45
		  setPoints(response.data.points)
46
		  setEmojisHowAreYouFeel(response.data.emojis_how_are_you_feel)
47
		  setEmojisClimateOnYourOrganization(response.data.emojis_climate_on_your_organization)
48
 
49
		}
50
    } catch (error) {
51
      console.log(error)
52
    }
53
  }
54
 
55
 
56
 
57
 
58
  useEffect(() => {
59
    getData()
60
  }, [])
61
 
62
 
63
 
64
  return (
65
    <div className='peopleYouMayKnow'>
66
      <div className="sd-title d-flex align-items-center justify-content-between">
67
        <h3>Pulso Diario</h3>
68
      </div>
69
      <div className='suggest-list'>
70
       	<div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
71
       		<h3>Puntos acumulados</h3>
72
       		<h1> {points} </h1>
73
       	</div>
74
        <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
75
      		<h3> Como te sientes hoy ? </h3>
76
      	</div>
77
      	<div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
78
      		{emojisHowAreYouFeel.map(item =>
79
 
80
   			<a href="#" onClick={() => handleEmojiSave(item.link_save)}>
81
          		<img   src={item.image} style={{ width: '32px', height: '32px' }} />
82
          	</a>
83
 
84
   			)}
85
		</div>
86
        <div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
87
      		<h3> Como esta el clima en la organización ? </h3>
88
      	</div>
89
      	<div className="w-100 d-flex align-items-center" style={{ gap: '.5rem' }}>
90
      		{emojisClimateOnYourOrganization.map(item =>
91
 
92
      		<a href="#"  onClick={() => handleEmojiSave(item.link_save)}>
93
          		<img   src={item.image} style={{ width: '32px', height: '32px' }} />
94
          	</a>
95
 
96
			)}
97
		</div>
98
      </div>
99
    </div>
100
  )
101
}
102
 
103
export default DailyPulse