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