Verejna cast, hezci 404ka, refaktoring
This commit is contained in:
+3
-1
@@ -3,12 +3,14 @@ import {defineStore} from 'pinia'
|
||||
export const useAppStore = defineStore('App', {
|
||||
state: () => ({
|
||||
pageTitle: null,
|
||||
breadcrumbs: []
|
||||
breadcrumbs: [],
|
||||
appStatus: 200
|
||||
}),
|
||||
actions: {
|
||||
resetAfterRouteChange() {
|
||||
this.setPageTitle("");
|
||||
this.setBreadcrumbs([]);
|
||||
this.appStatus = 200;
|
||||
},
|
||||
setPageTitle(pageTitle) {
|
||||
this.pageTitle = pageTitle;
|
||||
|
||||
+11
-4
@@ -25,15 +25,22 @@ export const useFlightsStore = defineStore('Flights', {
|
||||
},
|
||||
update(id, formData) {
|
||||
return apolloWrapper.mutate(EDIT_FLIGHT, {id: id, input: formData}).then(({data}) => {
|
||||
console.log("Pridat update ve storu")
|
||||
return data.editFlight;
|
||||
const flight = data.editFlight;
|
||||
const idx = this.items.findIndex(item => item.id === id);
|
||||
if (idx < 0) {
|
||||
this.items.push(flight)
|
||||
} else {
|
||||
this.items[idx] = flight;
|
||||
}
|
||||
|
||||
return flight;
|
||||
});
|
||||
},
|
||||
fetchDetail(id) {
|
||||
fetchDetail(id, username) {
|
||||
if (typeof id !== "number") {
|
||||
id = parseInt(id);
|
||||
}
|
||||
return apolloWrapper.query(FLIGHT_DETAIL, {id}).then(result => result.data.flight);
|
||||
return apolloWrapper.query(FLIGHT_DETAIL, {id, username}).then(result => result.data.flight);
|
||||
},
|
||||
fetch(username) {
|
||||
return apolloWrapper
|
||||
|
||||
+10
-8
@@ -12,22 +12,24 @@ export const useUserStore = defineStore('LoggedUser', {
|
||||
|
||||
actions: {
|
||||
update(id, formData) {
|
||||
apolloWrapper.mutate(EDIT_USER, {id, input: formData}).then(({data}) => {
|
||||
this.user = data.editLoggedUser;
|
||||
return data.editLoggedUser;
|
||||
apolloWrapper.mutate(EDIT_USER, {id, input: formData}).then((response) => {
|
||||
const user = response.data?.editLoggedUser;
|
||||
this.user = user;
|
||||
return user;
|
||||
});
|
||||
},
|
||||
|
||||
fetchLoggedUserDetail() {
|
||||
return apolloWrapper.query(LOGGED_USER_DETAIL).then(({data}) => {
|
||||
this.user = data.loggedUser;
|
||||
return data.loggedUser;
|
||||
return apolloWrapper.query(LOGGED_USER_DETAIL).then((response) => {
|
||||
const user = response.data?.loggedUser;
|
||||
this.user = user;
|
||||
return user;
|
||||
})
|
||||
},
|
||||
|
||||
fetchDetail(username) {
|
||||
return apolloWrapper.query(USER_DETAIL, {username}).then(({data}) => {
|
||||
return data.user
|
||||
return apolloWrapper.query(USER_DETAIL, {username}).then((response) => {
|
||||
return response.data?.user;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user