add: edit proposal
This commit is contained in:
@@ -2,6 +2,7 @@ import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { getBudgets, getCompany, updateBudget, updateCompany, deleteBudget, createBudget, getUsers, updateUser, createUser, deleteUser, getLocations, createLocation, updateLocation, deleteLocation } from "../services/company";
|
||||
import api from "../lib/axios";
|
||||
import { saveProposal, updateProposal } from "../services/vehicles";
|
||||
|
||||
export const useCompanyStore = defineStore('company', () => {
|
||||
|
||||
@@ -123,6 +124,32 @@ export const useCompanyStore = defineStore('company', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const createPropsal = async(formData) => {
|
||||
const data = await saveProposal(formData);
|
||||
console.log(data);
|
||||
if(data) {
|
||||
return 'success';
|
||||
} else {
|
||||
return 'Algo salio mal, intente más tarde';
|
||||
}
|
||||
}
|
||||
|
||||
const updatePropsalLoad = async(id, formData, localData) => {
|
||||
const data = await updateProposal(id, formData);
|
||||
if(data) {
|
||||
console.log(data);
|
||||
const index = proposals.value.findIndex((prop) => prop._id === id);
|
||||
proposals.value[index] = {
|
||||
...proposals.value[index],
|
||||
...data,
|
||||
...localData
|
||||
};
|
||||
return 'success';
|
||||
} else {
|
||||
return 'Algo salio mal, intente más tarde';
|
||||
}
|
||||
}
|
||||
|
||||
const getBudgetsCompany = async(filterQuery, reload = false) => {
|
||||
let filterArr = Object.values(filterQuery);
|
||||
|
||||
@@ -261,6 +288,8 @@ export const useCompanyStore = defineStore('company', () => {
|
||||
return {
|
||||
getCompanyData,
|
||||
getProposalsCompany,
|
||||
createPropsal,
|
||||
updatePropsalLoad,
|
||||
getBudgetsCompany,
|
||||
getUsersCompany,
|
||||
createUserCompany,
|
||||
|
||||
Reference in New Issue
Block a user