composables, mazani letu, skeletony
This commit is contained in:
+15
-11
@@ -1,7 +1,7 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloWrapper} from "src/graphql/apollo"
|
||||
import {FLIGHT_DETAIL, FLIGHTS_LIST} from "src/graphql/queries/flights";
|
||||
import {EDIT_FLIGHT, CREATE_FLIGHT} from "src/graphql/mutations/flight";
|
||||
import {EDIT_FLIGHT, CREATE_FLIGHT, DELETE_FLIGHT} from "src/graphql/mutations/flight";
|
||||
|
||||
export const useFlightsStore = defineStore('Flights', {
|
||||
state: () => ({
|
||||
@@ -38,16 +38,20 @@ export const useFlightsStore = defineStore('Flights', {
|
||||
fetch() {
|
||||
return apolloWrapper
|
||||
.query(FLIGHTS_LIST)
|
||||
.then((result) => {
|
||||
this.items = result.data.flights;
|
||||
.then(({data}) => {
|
||||
this.items = data.flights;
|
||||
|
||||
return result.data.flights;
|
||||
return data.flights;
|
||||
});
|
||||
},
|
||||
deleteItem(id) {
|
||||
const idx = this.items.indexOf(this.items.find(f => f.id === id));
|
||||
this.items.splice(idx, 1);
|
||||
console.log("maxu let ID " + id + " na indexu " + idx);
|
||||
}
|
||||
}
|
||||
})
|
||||
delete(id) {
|
||||
return apolloWrapper.mutate(DELETE_FLIGHT, {id}).then(({data}) => {
|
||||
|
||||
const idx = this.items.indexOf(this.items.find(f => f.id === id));
|
||||
this.items.splice(idx, 1);
|
||||
|
||||
return data.deleteFlight;
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user