Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3379 Rev 3416
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from "react";
2
import { useDispatch } from 'react-redux'
2
import { useDispatch } from "react-redux";
3
import { Typography } from '@mui/material'
3
import { Typography } from "@mui/material";
Línea 4... Línea 4...
4
 
4
 
5
import { axios } from '@utils'
5
import { axios } from "@utils";
6
import { useFetch } from '@hooks'
6
import { useFetch } from "@hooks";
Línea 7... Línea 7...
7
import { addNotification } from '@store/notification/notification.actions'
7
import { addNotification } from "@store/notification/notification.actions";
Línea 8... Línea 8...
8
 
8
 
9
import Widget from '@components/UI/Widget'
9
import Widget from "@components/UI/Widget";
Línea 10... Línea 10...
10
 
10
 
11
import LoadingWrapper from '@components/common/loading-wrapper'
11
import LoadingWrapper from "@components/common/loading-wrapper";
12
import EmojiGroup from '@components/common/emoji-selector'
12
import EmojiGroup from "@components/common/emoji-selector";
Línea 13... Línea 13...
13
 
13
 
14
const DailyPulse = ({ dailyPulseUrl = '' }) => {
14
const DailyPulse = ({ dailyPulseUrl = "" }) => {
15
  const [isSubmitting, setIsSubmitting] = useState(false)
15
  const [isSubmitting, setIsSubmitting] = useState(false);
16
  const dispatch = useDispatch()
16
  const dispatch = useDispatch();
Línea 17... Línea 17...
17
 
17
 
18
  const { data, isLoading, refetch } = useFetch(dailyPulseUrl, {
18
  const { data, loading, refetch } = useFetch(dailyPulseUrl, {
19
    emojis_how_are_you_feel: [],
19
    emojis_how_are_you_feel: [],
20
    emojis_climate_on_your_organization: []
20
    emojis_climate_on_your_organization: [],
21
  })
21
  });
Línea 22... Línea 22...
22
 
22
 
23
  const saveEmoji = async (link_save = '') => {
23
  const saveEmoji = async (link_save = "") => {
24
    try {
24
    try {
25
      setIsSubmitting(true)
25
      setIsSubmitting(true);
Línea 26... Línea 26...
26
      const response = await axios.post(link_save)
26
      const response = await axios.post(link_save);
27
      const { data, success } = response.data
27
      const { data, success } = response.data;
28
 
28
 
29
      if (!success) {
29
      if (!success) {
30
        const errMsg = typeof data === 'string' ? data : 'Error al guardar'
30
        const errMsg = typeof data === "string" ? data : "Error al guardar";
31
        throw new Error(errMsg)
31
        throw new Error(errMsg);
32
      }
32
      }
Línea 33... Línea 33...
33
 
33
 
34
      refetch()
34
      refetch();
35
    } catch (error) {
35
    } catch (error) {
36
      dispatch(addNotification({ style: 'danger', msg: error.message }))
36
      dispatch(addNotification({ style: "danger", msg: error.message }));
37
    } finally {
37
    } finally {
38
      setIsSubmitting(false)
38
      setIsSubmitting(false);
Línea 39... Línea 39...
39
    }
39
    }
40
  }
40
  };
41
 
41
 
Línea 42... Línea 42...
42
  if (
42
  if (
43
    data.emojis_how_are_you_feel.length <= 1 &&
43
    data.emojis_how_are_you_feel.length <= 1 &&
44
    data.emojis_climate_on_your_organization.length <= 1
44
    data.emojis_climate_on_your_organization.length <= 1
45
  ) {
45
  ) {
46
    return null
46
    return null;
47
  }
47
  }
48
 
48
 
49
  return (
49
  return (
Línea 50... Línea 50...
50
    <Widget>
50
    <Widget>
51
      <Widget.Header title='Pulso Diario' />
51
      <Widget.Header title="Pulso Diario" />
Línea 70... Línea 70...
70
                />
70
                />
71
              )
71
              )
72
            )}
72
            )}
73
          </EmojiGroup>
73
          </EmojiGroup>
Línea 74... Línea 74...
74
 
74
 
75
          <Typography variant='h4' textAlign='center'>
75
          <Typography variant="h4" textAlign="center">
76
            ¿Como esta el clima en la organización?
76
            ¿Como esta el clima en la organización?
Línea 77... Línea 77...
77
          </Typography>
77
          </Typography>
78
 
78
 
Línea 89... Línea 89...
89
            )}
89
            )}
90
          </EmojiGroup>
90
          </EmojiGroup>
91
        </LoadingWrapper>
91
        </LoadingWrapper>
92
      </Widget.Body>
92
      </Widget.Body>
93
    </Widget>
93
    </Widget>
94
  )
94
  );
95
}
95
};
Línea 96... Línea 96...
96
 
96