Línea 1... |
Línea 1... |
1 |
import { axios } from '@utils'
|
1 |
import { axios } from '@utils';
|
2 |
|
2 |
|
3 |
export const savePurpose = async (url, purpose) => {
|
3 |
export const savePurpose = async (url, purpose) => {
|
4 |
const formData = new FormData()
|
4 |
const formData = new FormData();
|
5 |
Object.entries(purpose).forEach(([key, value]) => formData.append(key, value))
|
5 |
Object.entries(purpose).forEach(([key, value]) => formData.append(key, value));
|
6 |
const response = await axios.post(url, formData)
|
6 |
const response = await axios.post(url, formData);
|
7 |
const { data, message, success } = response.data
|
7 |
const { data, message, success } = response.data;
|
8 |
if (!success) throw new Error('Error al guardar el propósito')
|
8 |
if (!success) throw new Error('Error al guardar el propósito');
|
9 |
return { data, message }
|
9 |
return { data, message };
|
10 |
}
|
10 |
};
|
11 |
|
11 |
|
12 |
export const editPurpose = async (url, purpose) => {
|
12 |
export const editPurpose = async (url, purpose) => {
|
13 |
const formData = new FormData()
|
13 |
const formData = new FormData();
|
14 |
Object.entries(purpose).forEach(([key, value]) => formData.append(key, value))
|
14 |
Object.entries(purpose).forEach(([key, value]) => formData.append(key, value));
|
15 |
const response = await axios.post(url, formData)
|
15 |
const response = await axios.post(url, formData);
|
16 |
const { data, message, success } = response.data
|
16 |
const { data, message, success } = response.data;
|
17 |
if (!success) throw new Error('Error al editar el propósito')
|
17 |
if (!success) throw new Error('Error al editar el propósito');
|
18 |
return { data, message }
|
18 |
return { data, message };
|
19 |
}
|
19 |
};
|
20 |
|
20 |
|
21 |
export const deletePurpose = async (url) => {
|
21 |
export const deletePurpose = async (url) => {
|
22 |
const response = await axios.post(url)
|
22 |
const response = await axios.post(url);
|
23 |
const { data, success } = response.data
|
23 |
const { data, success } = response.data;
|
24 |
if (!success) throw new Error('Error al eliminar el propósito')
|
24 |
if (!success) throw new Error('Error al eliminar el propósito');
|
25 |
return data
|
25 |
return data;
|
26 |
}
|
26 |
};
|