Zaklad pro zadavani novych letu
This commit is contained in:
@@ -39,7 +39,6 @@ export const useAircraftsStore = defineStore('Aircrafts', {
|
||||
});
|
||||
},
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {apolloWrapper} from "src/graphql/apollo";
|
||||
import {AIRPORTS_LIST} from "src/graphql/queries/airports";
|
||||
|
||||
export const useAirportsStore = defineStore('Airports', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
}),
|
||||
|
||||
actions: {
|
||||
fetch() {
|
||||
return apolloWrapper
|
||||
.query(AIRPORTS_LIST)
|
||||
.then((result) => {
|
||||
this.items = result.data.airports;
|
||||
return result.data.airports;
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,13 @@
|
||||
import {defineStore} from 'pinia'
|
||||
|
||||
export const useFlashMessagesStore = defineStore('FlashMessages', {
|
||||
state: () => ({
|
||||
items: []
|
||||
}),
|
||||
|
||||
actions: {
|
||||
add(title, content, type) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
+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({
|
||||
|
||||
@@ -24,6 +24,7 @@ export const useUserStore = defineStore('LoggedUser', {
|
||||
},
|
||||
|
||||
async setupCredentials() {
|
||||
// TODO: aktualne se vola s kazdym prechodem mezi routami, to je urcite zbytecne!
|
||||
await api.get("/me").then(({data}) => {
|
||||
this.user = data;
|
||||
}).catch(e => {
|
||||
|
||||
Reference in New Issue
Block a user