composables, mazani letu, skeletony

This commit is contained in:
Michal Kváček
2023-07-24 17:31:54 +02:00
parent 4648c30f90
commit 864db6c6a2
53 changed files with 732 additions and 273 deletions
+15 -11
View File
@@ -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;
})
},
},
});