Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

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