From 07ac93a8f708aeeb03e2747ffe118032a1c30fc5 Mon Sep 17 00:00:00 2001 From: jedi Date: Thu, 12 Dec 2019 19:25:55 +0100 Subject: [PATCH] display boxes --- src/store/index.js | 22 +++++++++++++++------- src/views/Boxes.vue | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index fca6dda..29057ee 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -17,10 +17,7 @@ const store = new Vuex.Store({ loadedBoxes: [], }, getters: { - getEventSlug: state => { - console.log('foo', state.events); - return state.route && state.route.params.event? state.route.params.event : state.events.length ? state.events[0].slug : '36C3'; - }, + getEventSlug: state => state.route && state.route.params.event? state.route.params.event : state.events.length ? state.events[0].slug : '36C3', getActiveView: state => state.route.name || 'items', }, mutations: { @@ -35,7 +32,10 @@ const store = new Vuex.Store({ }, setLayout(state, layout) { state.layout = layout; - } + }, + replaceBoxes(state, loadedBoxes) { + state.loadedBoxes = loadedBoxes; + }, }, actions: { async loadEvents({ commit }) { @@ -58,11 +58,19 @@ const store = new Vuex.Store({ }); commit('replaceLoadedItems', resp.data); - } + }, + async loadBoxes({ commit }) { + const resp = await axios.get('https://c3lf.de/api/1/boxes', { + auth: getAuth(), + }); + + commit('replaceBoxes', resp.data); + }, } }); export default store; store.dispatch('loadEvents'); -store.dispatch('loadEventItems'); \ No newline at end of file +store.dispatch('loadEventItems'); +store.dispatch('loadBoxes'); \ No newline at end of file diff --git a/src/views/Boxes.vue b/src/views/Boxes.vue index 06575b7..9acc170 100644 --- a/src/views/Boxes.vue +++ b/src/views/Boxes.vue @@ -3,8 +3,8 @@