Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3331 Rev 3332
Línea 12... Línea 12...
12
 
12
 
13
const DailyPulse = ({ dailyPulseUrl = '' }) => {
13
const DailyPulse = ({ dailyPulseUrl = '' }) => {
14
  const [isSubmitting, setIsSubmitting] = useState(false)
14
  const [isSubmitting, setIsSubmitting] = useState(false)
Línea 15... Línea 15...
15
  const dispatch = useDispatch()
15
  const dispatch = useDispatch()
16
 
16
 
17
  const { data, isLoading, mutate } = useFetch(dailyPulseUrl, {
17
  const { data, isLoading, refetch } = useFetch(dailyPulseUrl, {
18
    emojis_how_are_you_feel: [],
18
    emojis_how_are_you_feel: [],
Línea -... Línea 19...
-
 
19
    emojis_climate_on_your_organization: []
-
 
20
  })
-
 
21
 
-
 
22
  /*  const updateEmojis = (id) => {
-
 
23
    const isClimate = data.emojis_climate_on_your_organization.some(
-
 
24
      (emoji) => emoji.id === id
-
 
25
    )
-
 
26
 
-
 
27
    if (isClimate) {
-
 
28
      data.emojis_climate_on_your_organization.filter(
-
 
29
        (emoji) => emoji.id === id
-
 
30
      )
19
    emojis_climate_on_your_organization: []
31
    }
20
  })
32
  } */
21
 
33
 
22
  const saveEmoji = async (url = '') => {
34
  const saveEmoji = async ({ link_save = '', id = '' }) => {
23
    try {
35
    try {
Línea 24... Línea 36...
24
      setIsSubmitting(true)
36
      setIsSubmitting(true)
25
      const response = await axios.post(url)
37
      const response = await axios.post(link_save)
26
      const { data, success } = response.data
38
      const { data, success } = response.data
27
 
39
 
Línea 28... Línea -...
28
      if (!success) {
-
 
29
        const errMsg = typeof data === 'string' ? data : 'Ha ocurrido un error'
-
 
30
        throw new Error(errMsg)
-
 
31
      }
-
 
32
 
-
 
33
      const isClimate = url.includes('climate')
-
 
34
 
40
      if (!success) {
35
      if (isClimate) {
-
 
36
        const selectedEmojis = data.emojis_climate_on_your_organization.filter(
-
 
37
          (emoji) => emoji.link_save === url
-
 
38
        )
-
 
39
        mutate({
-
 
40
          ...data,
-
 
41
          emojis_climate_on_your_organization: selectedEmojis
-
 
42
        })
-
 
43
      } else {
-
 
44
        const selectedEmojis = data.emojis_how_are_you_feel.filter(
-
 
45
          (emoji) => emoji.link_save === url
-
 
46
        )
-
 
47
        mutate({
41
        const errMsg = typeof data === 'string' ? data : 'Ha ocurrido un error'
48
          ...data,
42
        throw new Error(errMsg)
49
          emojis_how_are_you_feel: selectedEmojis
43
      }
50
        })
44
 
51
      }
45
      refetch()