Aircraft CRUD
This commit is contained in:
@@ -24,28 +24,24 @@ export const useAircraftsStore = defineStore('Aircrafts', {
|
||||
create(formData) {
|
||||
delete formData['id'];
|
||||
return apolloWrapper.mutate(CREATE_AIRCRAFT, {input: formData}).then(({data}) => {
|
||||
// this.items.push(data.createAircraft);
|
||||
this.items.push(data.createAircraft);
|
||||
|
||||
return data.createAircraft;
|
||||
})
|
||||
},
|
||||
delete(id) {
|
||||
return apolloWrapper.mutate(DELETE_AIRCRAFT, {id}).then(({data}) => {
|
||||
// const idx = this.items.findIndex(a => a.id === id);
|
||||
// console.log(idx);
|
||||
// this.items.splice(idx, 1);
|
||||
const idx = this.items.findIndex(a => a.id === id);
|
||||
console.log(idx);
|
||||
this.items.splice(idx, 1);
|
||||
|
||||
this.items = this.items.filter(a => {
|
||||
console.log(a.id, id);
|
||||
return a.id !== id
|
||||
});
|
||||
console.log(this.items);
|
||||
return data;
|
||||
});
|
||||
},
|
||||
update(id, formData) {
|
||||
console.log(id, formData);
|
||||
return apolloWrapper.mutate(EDIT_AIRCRAFT, {id: id, input: formData}).then(({data}) => {
|
||||
console.log("Pridat update ve storu")
|
||||
return data.editAircraft;
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user