Jiny pristup k vytvareni letu, polofunkcni editace letu

This commit is contained in:
Michal Kváček
2023-06-27 22:45:24 +02:00
parent 4d9950e362
commit d399e1aaf1
20 changed files with 672 additions and 261 deletions
+10 -1
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 {CREATE_FLIGHT} from "src/graphql/mutations/flight";
import {EDIT_FLIGHT, CREATE_FLIGHT} from "src/graphql/mutations/flight";
export const useFlightsStore = defineStore('Flights', {
state: () => ({
@@ -23,7 +23,16 @@ export const useFlightsStore = defineStore('Flights', {
return data.createFlight;
})
},
update(id, formData) {
return apolloWrapper.mutate(EDIT_FLIGHT, {id: id, input: formData}).then(({data}) => {
console.log("Pridat update ve storu")
return data.editFlight;
});
},
fetchDetail(id) {
if (typeof id !== "number") {
id = parseInt(id);
}
return apolloWrapper.query(FLIGHT_DETAIL, {id}).then(result => result.data.flight);
},
fetch() {