Zaklad pro zadavani novych letu
This commit is contained in:
+14
-10
@@ -1,6 +1,7 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloClient} from "src/graphql/apollo"
|
||||
import {apolloWrapper} from "src/graphql/apollo"
|
||||
import {FLIGHTS_LIST} from "src/graphql/queries/flights";
|
||||
import {CREATE_FLIGHT} from "src/graphql/mutations/flight";
|
||||
|
||||
export const useFlightsStore = defineStore('Flights', {
|
||||
state: () => ({
|
||||
@@ -9,27 +10,30 @@ export const useFlightsStore = defineStore('Flights', {
|
||||
|
||||
getters: {
|
||||
getDetail: (state) => (flightId) => {
|
||||
console.log(state.items);
|
||||
return state.items.find(f => f.id === flightId);
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
create(formData) {
|
||||
this.items.push(formData);
|
||||
delete formData['id'];
|
||||
return apolloWrapper.mutate(CREATE_FLIGHT, {input: formData}).then(({data}) => {
|
||||
this.items.push(data.createFlight);
|
||||
|
||||
return data.createFlight;
|
||||
})
|
||||
},
|
||||
fetchDetail(id) {
|
||||
this.items.push({id: id, takeOffLocation: "LKLT", landingLocation: "LKLT", date: "2023-02-01", aircraft: {id: 1, name: "OK-AUR28"}, flightDurationMinutes: 76})
|
||||
},
|
||||
fetch() {
|
||||
apolloClient
|
||||
.query({
|
||||
return apolloWrapper
|
||||
.query(FLIGHTS_LIST)
|
||||
.then((result) => {
|
||||
this.items = result.data.flights;
|
||||
|
||||
query: FLIGHTS_LIST,
|
||||
|
||||
})
|
||||
|
||||
.then((result) => console.log(result));
|
||||
return result.data.flights;
|
||||
});
|
||||
// if (this.items.length > 0) return;
|
||||
//
|
||||
// this.$patch({
|
||||
|
||||
Reference in New Issue
Block a user