update company & crud budgets

This commit is contained in:
Alexandro Uc Santos
2023-12-30 14:41:07 -06:00
parent 7afd77b218
commit 25528cae8f
12 changed files with 380 additions and 48 deletions

View File

@@ -12,10 +12,12 @@ export const getCompany = async(companyId) => {
}
}
export const editCompany = async(companyId, formData) => {
export const updateCompany = async(companyId, formData) => {
try {
const endpoint = `/companies/${companyId}`;
console.log(endpoint);
const {data} = await api.patch(endpoint, formData);
console.log(data);
return data;
} catch (error) {
console.log(error);
@@ -26,7 +28,6 @@ export const editCompany = async(companyId, formData) => {
export const getBudgets = async(filter) => {
try {
const endpoint = `/budgets/${filter}`;
console.log(endpoint);
const {data} = await api.get(endpoint);
console.log(data);
return data;
@@ -37,6 +38,40 @@ export const getBudgets = async(filter) => {
}
export const updateBudget = async(id, formData) => {
try {
const endpoint = `/budgets/${id}`;
const {data} = await api.patch(endpoint, formData);
return data;
} catch (error) {
console.log(error);
return null;
}
}
export const createBudget = async(formData) => {
try {
const endpoint = `/budgets`;
const {data} = await api.post(endpoint, formData);
return data;
} catch (error) {
console.log(error);
return null;
}
}
export const deleteBudget = async(id) => {
try {
const endpoint = `/budgets/${id}`;
const {data} = await api.delete(endpoint);
return data;
} catch (error) {
console.log(error);
return null;
}
}
// export const editCompany = async(companyId, formData) => {
// try {
// const endpoint = `/companies/${companyId}`;