Upravy UI, refaktoring, davkove upravy a mazani fotek

This commit is contained in:
Michal Kváček
2023-08-28 22:02:24 +02:00
parent dcc3230cbe
commit dd248d4432
53 changed files with 636 additions and 357 deletions
+9 -7
View File
@@ -6,7 +6,8 @@ import {updateInItems} from "stores/helpers";
export const useCopilotsStore = defineStore('SecondPilots', {
state: () => ({
items: []
items: [],
isMutationRunning: false,
}),
actions: {
@@ -21,19 +22,20 @@ export const useCopilotsStore = defineStore('SecondPilots', {
},
create(formData) {
delete formData['id'];
return apolloWrapper.mutate(CREATE_COPILOT, {input: formData}).then(({data}) => {
this.items.push(data.createCopilot);
return data.createCopilot;
})
this.isMutationRunning = true;
return apolloWrapper.mutate(CREATE_COPILOT, {input: formData}).then(({data}) => {
const copilot = data.createCopilot;
this.items.push(copilot);
return copilot;
}).finally(() => this.isMutationRunning = false);
},
update(id, formData) {
return apolloWrapper.mutate(EDIT_COPILOT, {id: id, input: formData}).then(({data}) => {
const copilot = data.editCopilot;
updateInItems(this.items, "id", copilot);
return copilot;
});
}).finally(() => this.isMutationRunning = false);
},
}
})
-13
View File
@@ -1,13 +0,0 @@
import {defineStore} from 'pinia'
export const useFlashMessagesStore = defineStore('FlashMessages', {
state: () => ({
items: []
}),
actions: {
add(title, content, type) {
}
}
})
-3
View File
@@ -49,11 +49,8 @@ export const useFlightsStore = defineStore('Flights', {
return apolloWrapper
.query(FLIGHTS_LIST, {username})
.then((resp) => {
console.log(resp);
const data = resp.data;
this.items = data.flights;
return data.flights;
}).catch(err => console.log(err));
},
+8 -3
View File
@@ -3,6 +3,9 @@ import {apolloWrapper} from "src/graphql/apollo";
import {DELETE_PHOTO, EDIT_PHOTO, UPLOAD_PHOTO} from "src/graphql/mutations/photo";
export const usePhotosStore = defineStore('photos', {
state: () => ({
isMutationRunning: false,
}),
actions: {
upload(flightId, formData) {
@@ -20,15 +23,17 @@ export const usePhotosStore = defineStore('photos', {
if (!formData.description) {
formData.description = "";
}
this.isMutationRunning = true;
return apolloWrapper.mutate(UPLOAD_PHOTO, {input: formData}).then(({data}) => {
return data.uploadPhoto;
})
}).finally(() => this.isMutationRunning = false);
},
update(id, formData) {
this.isMutationRunning = true;
return apolloWrapper.mutate(EDIT_PHOTO, {id, input: formData}).then(({data}) => {
return data.editPhoto;
})
}).finally(() => this.isMutationRunning = false);
},
delete(photoId) {
return apolloWrapper.mutate(DELETE_PHOTO, {id: photoId}).then(({data}) => {
-1
View File
@@ -13,7 +13,6 @@ import { createPinia } from 'pinia'
export default store((/* { ssrContext } */) => {
const pinia = createPinia()
console.log("Pinia index");
// You can add Pinia plugins here
// pinia.use(SomePiniaPlugin)