Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3659 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3659 Rev 3719
Línea 1... Línea 1...
1
import { api } from '@shared/libs';
1
import { api } from '@shared/libs';
2
 
2
 
3
export const addCapsuleComment = async (url, { comment, rating }) => {
3
export const addCapsuleComment = async (url, { comment, rating }) => {
4
  try {
4
  try {
5
    const { message, comment: newComment, capsule } = await api.post(url, { comment, rating });
5
    const { message, comment: newComment, capsule } = await api.post(url, { comment, rating });
6
    return { message, comment: newComment, capsule };
6
    return { message, comment: newComment, capsule };
7
  } catch (error) {
7
  } catch (error) {
8
    console.error(error);
8
    console.error(error);
9
    throw new Error('Error al agregar el comentario');
9
    throw new Error('Error al agregar el comentario');
10
  }
10
  }
11
};
11
};
12
 
12
 
13
export const deleteCapsuleComment = async (url) => {
13
export const deleteCapsuleComment = async (url) => {
14
  try {
14
  try {
15
    const { message, capsule } = await api.post(url);
15
    const { message, capsule } = await api.post(url);
16
    return { message, capsule };
16
    return { message, capsule };
17
  } catch (error) {
17
  } catch (error) {
18
    console.error(error);
18
    console.error(error);
19
    throw new Error('Error al eliminar el comentario');
19
    throw new Error('Error al eliminar el comentario');
20
  }
20
  }
21
};
21
};
22
 
22
 
23
export const getCapsules = async (url, { params = undefined } = {}) => {
23
export const getCapsules = async (url, { params = undefined } = {}) => {
24
  try {
24
  try {
25
    return await api.get(url, { params });
25
    return await api.get(url, { params });
26
  } catch (error) {
26
  } catch (error) {
27
    console.error(error);
27
    console.error(error);
28
    throw new Error('Error al obtener las cápsulas');
28
    throw new Error('Error al obtener las cápsulas');
29
  }
29
  }
30
};
30
};
31
 
31
 
32
export const getLastCapsuleInProgress = async () => {
32
export const getLastCapsuleInProgress = async () => {
33
  try {
33
  try {
34
    return await api.get('/microlearning/last-capsule-in-progress');
34
    return await api.get('/microlearning/last-capsule-in-progress');
35
  } catch (error) {
35
  } catch (error) {
36
    console.error(error);
36
    console.error(error);
37
    throw new Error('Error al obtener la última cápsula en progreso');
37
    throw new Error('Error al obtener la última cápsula en progreso');
38
  }
38
  }
39
};
39
};
40
 
40
 
41
export const getCapsule = async (uuid) => {
41
export const getCapsule = async (uuid) => {
42
  try {
42
  try {
43
    return await api.get(`/microlearning/capsules/${uuid}`);
43
    return await api.get(`/microlearning/capsules/${uuid}`);
44
  } catch (error) {
44
  } catch (error) {
45
    console.error(error);
45
    console.error(error);
46
    throw new Error('Error al obtener la cápsula');
46
    throw new Error('Error al obtener la cápsula');
47
  }
47
  }
48
};
48
};