Upravy UI, refaktoring, davkove upravy a mazani fotek
This commit is contained in:
@@ -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);
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import {defineStore} from 'pinia'
|
||||
|
||||
export const useFlashMessagesStore = defineStore('FlashMessages', {
|
||||
state: () => ({
|
||||
items: []
|
||||
}),
|
||||
|
||||
actions: {
|
||||
add(title, content, type) {
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -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
@@ -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}) => {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user