Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3505 Rev 3510
Línea 1... Línea 1...
1
import { useEffect, useState } from 'react';
1
import { useEffect, useState } from 'react';
Línea 2... Línea 2...
2
 
2
 
-
 
3
import { useAlert, useFetch } from '@shared/hooks';
Línea 3... Línea 4...
3
import { useFetch } from '@shared/hooks';
4
import { api } from '@shared/libs';
4
 
5
 
5
const DEFAULT_STATE = {
6
const DEFAULT_STATE = {
6
  uuid: '',
7
  uuid: '',
Línea 23... Línea 24...
23
};
24
};
Línea 24... Línea 25...
24
 
25
 
25
export function useCapsule(uuid) {
26
export function useCapsule(uuid) {
Línea -... Línea 27...
-
 
27
  const [capsule, setCapsule] = useState(DEFAULT_STATE);
-
 
28
 
26
  const [capsule, setCapsule] = useState(DEFAULT_STATE);
29
  const { showSuccess, showError } = useAlert();
-
 
30
 
-
 
31
  const { data, loading, refetch } = useFetch(`/microlearning/get-capsule/${uuid}`);
-
 
32
  const { data: comments, loading: loadingComments } = useFetch(capsule.link_comments);
-
 
33
 
-
 
34
  const addComment = async ({ comment, rating }) => {
-
 
35
    try {
-
 
36
      const { message } = await api.post(capsule.link_comment_add, { comment, rating });
-
 
37
      showSuccess(message);
-
 
38
    } catch (error) {
-
 
39
      showError(error.message);
Línea 27... Línea 40...
27
 
40
    }
28
  const { data, loading, refetch } = useFetch(`/microlearning/get-capsule/${uuid}`);
41
  };
29
 
42
 
Línea 30... Línea 43...
30
  useEffect(() => {
43
  useEffect(() => {
31
    if (data) setCapsule(data);
44
    if (data) setCapsule(data);