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