Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3476 Rev 3483
Línea 1... Línea 1...
1
import { axios } from '@utils';
1
import { api } from '@api';
Línea 2... Línea 2...
2
 
2
 
-
 
3
export const addComment = async (url, comment) => {
3
export const addComment = async (url, comment) => {
4
  try {
4
  const response = await axios.post(url, comment);
-
 
5
  const { success, data } = response.data;
-
 
6
 
5
    return await api.post(url, comment);
7
  if (!success) {
6
  } catch (error) {
8
    const errorMessage =
-
 
9
      typeof data === 'string'
-
 
10
        ? data
7
    console.log(error);
11
        : 'Ha ocurrido un error al agregar el comentario, por favor intente más tarde.';
-
 
12
    throw new Error(errorMessage);
8
    throw new Error('Ha ocurrido un error al agregar el comentario, por favor intente más tarde.');
13
  }
-
 
14
 
-
 
15
  return data;
9
  }
Línea 16... Línea 10...
16
};
10
};
-
 
11
 
17
 
12
export const deleteComment = async (url) => {
18
export const deleteComment = async (url) => {
-
 
19
  const response = await axios.post(url);
-
 
20
  const { success, data } = response.data;
13
  try {
21
 
14
    return await api.post(url);
22
  if (!success) {
-
 
23
    const errorMessage =
-
 
24
      typeof data === 'string'
15
  } catch (error) {
25
        ? data
-
 
26
        : 'Ha ocurrido un error al eliminar el comentario, por favor intente más tarde.';
16
    console.log(error);
27
    throw new Error(errorMessage);
-
 
28
  }
-
 
29
 
17
    throw new Error('Ha ocurrido un error al eliminar el comentario, por favor intente más tarde.');
Línea 30... Línea 18...
30
  return data;
18
  }
-
 
19
};
31
};
20
 
32
 
-
 
33
export const saveKnowledge = async (url, knowledge) => {
-
 
34
  const response = await axios.post(url, knowledge);
21
export const saveKnowledge = async (url, knowledge) => {
35
  const { success, data } = response.data;
22
  try {
36
 
-
 
37
  if (!success) {
23
    return await api.post(url, knowledge);
38
    const errorMessage =
24
  } catch (error) {
39
      typeof data === 'string'
25
    console.error(error);
40
        ? data
26
    throw new Error(
41
        : 'Ha ocurrido un error al guardar el conocimiento, por favor intente más tarde.';
-
 
42
    throw new Error(errorMessage);
-
 
43
  }
27
      'Ha ocurrido un error al guardar el conocimiento, por favor intente más tarde.'
Línea 44... Línea 28...
44
 
28
    );
-
 
29
  }
45
  return data;
30
};
46
};
-
 
47
 
-
 
48
export const deleteKnowledge = async (url) => {
31
 
49
  const response = await axios.post(url);
32
export const deleteKnowledge = async (url) => {
50
  const { success, data } = response.data;
-
 
51
 
33
  try {
52
  if (!success) {
34
    return await api.post(url);
53
    const errorMessage =
35
  } catch (error) {
54
      typeof data === 'string'
36
    console.error(error);
55
        ? data
-
 
56
        : 'Ha ocurrido un error al eliminar el conocimiento, por favor intente más tarde.';
-
 
57
    throw new Error(errorMessage);
37
    throw new Error(
Línea 58... Línea 38...
58
  }
38
      'Ha ocurrido un error al eliminar el conocimiento, por favor intente más tarde.'
-
 
39
    );
59
 
40
  }
60
  return data;
-
 
61
};
-
 
62
 
41
};
63
export const getKnowledge = async (url) => {
42
 
64
  const response = await axios.get(url);
-
 
65
  const { success, data } = response.data;
43
export const getKnowledge = async (url) => {
66
 
44
  try {
67
  if (!success) {
45
    return await api.get(url);
68
    const errorMessage =
46
  } catch (error) {
69
      typeof data === 'string'
-
 
70
        ? data
-
 
71
        : 'Ha ocurrido un error al obtener el conocimiento, por favor intente más tarde.';
47
    console.error(error);