Zaklad pro zadavani novych letu

This commit is contained in:
Michal Kváček
2023-06-06 07:35:04 +02:00
parent 9d843c62a6
commit 25bf93589e
19 changed files with 413 additions and 197 deletions
+14 -10
View File
@@ -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({