composables, mazani letu, skeletony

This commit is contained in:
Michal Kváček
2023-07-24 17:31:54 +02:00
parent 4648c30f90
commit 864db6c6a2
53 changed files with 732 additions and 273 deletions
+14 -28
View File
@@ -1,6 +1,7 @@
import {defineStore} from 'pinia'
import {apolloWrapper} from "src/graphql/apollo";
import {POI_LIST} from "src/graphql/queries/poi";
import {POI_DETAIL, POI_LIST} from "src/graphql/queries/poi";
import {EDIT_POI} from "src/graphql/mutations/poi";
export const usePointsOfInterestStore = defineStore('PointsOfInterest', {
state: () => ({
@@ -18,42 +19,27 @@ export const usePointsOfInterestStore = defineStore('PointsOfInterest', {
console.log('item', item);
return item;
},
// pointTypeName() {
// return (typeName) => {
// const typeToNameMap = {
// poi: "General POI",
// airport: "Airport",
// }
// return typeToNameMap[typeName] || "Unknown";
// }
// },
// groupByTypes() {
// const groupedByType = {};
// for (const item of this.items) {
// if (!groupedByType[item.type]) groupedByType[item.type] = [];
// groupedByType[item.type].push(item);
// }
// return groupedByType;
// }
},
actions: {
fetchDetail(poiId) {
console.log("fetch poi detail");
this.items.push({id: poiId, "name": "Zamek " + poiId, "type": "poi", "location": {"lat": 50, "lng": 10}});
update(id, input) {
return apolloWrapper.mutate(EDIT_POI, {id, input}).then((data) => {
console.log("Pridat update POI ve store");
return data.data.editPointOfInterest;
})
},
fetchDetail(id) {
if (typeof id !== "number") {
id = parseInt(id);
}
return apolloWrapper.query(POI_DETAIL, {id}).then(result => result.data.pointOfInterest);
},
fetch() {
return apolloWrapper.query(POI_LIST).then(result => {
this.items = result.data.pointsOfInterest;
return result.data.pointsOfInterest;
});
// console.log("fetch poi");
// this.items = [
// {id: 1, "name": "LKLT", private: false, "type": "airport", "location": {"lat": 50, "lng": 10}},
// {id: 2, "name": "Hrad", "type": "poi", "location": {"lat": 50, "lng": 10}},
// {id: 3, "name": "Zamek", "type": "poi", "location": {"lat": 50, "lng": 10}},
// ]
}
}
})