diff --git a/package.json b/package.json index 1402162..72d874d 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dotenv-webpack": "^1.7.0", "jquery": "^3.4.1", "lodash": "^4.17.15", + "luxon": "^1.21.3", "node-sass": "^4.13.0", "popper.js": "^1.16.0", "ramda": "^0.26.1", diff --git a/src/App.vue b/src/App.vue index 3b6caa7..2d34a41 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,22 +3,27 @@ +
+ +
\ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 18d1a37..440638b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -12,16 +12,32 @@ const axios = AxiosBootstrap.create({ }); axios.interceptors.response.use(response => response, error => { + console.log('error interceptor fired'); console.error(error); // todo: toast error + console.log(Object.entries(error)); + + if (error.isAxiosError) { + const message = ` +

A HTTP ${error.config.method} request failed.

+

url: ${error.config.url}

+

timeout: ${!!error.request.timeout}

+

response-body: ${error.response && error.response.body}

+ `; + store.commit('createToast', {title: 'HTTP Error', message, color: 'danger'}); + } else { + store.commit('createToast', {title: 'Unknown Error', message: error.toString(), color: 'danger'}); + } return Promise.reject(error); }); const store = new Vuex.Store({ state: { + keyIncrement: 0, events: [], layout: 'cards', loadedItems: [], loadedBoxes: [], + toasts: [] }, getters: { getEventSlug: state => state.route && state.route.params.event? state.route.params.event : state.events.length ? state.events[0].slug : '36C3', @@ -54,6 +70,13 @@ const store = new Vuex.Store({ }, appendItem(state, item) { state.loadedItems.push(item); + }, + createToast(state, { title, message, color }) { + state.toasts.push({ title, message, color, key: state.keyIncrement }); + state.keyIncrement += 1; + }, + removeToast(state, key) { + state.toasts = state.toasts.filter(toast => toast.key !== key); } }, actions: { @@ -103,5 +126,4 @@ export default store; store.dispatch('loadEvents').then(() =>{ store.dispatch('loadEventItems'); store.dispatch('loadBoxes'); -} -); +}); diff --git a/yarn.lock b/yarn.lock index 66a5dac..e8545df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5074,6 +5074,11 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +luxon@^1.21.3: + version "1.21.3" + resolved "https://registry.yarnpkg.com/luxon/-/luxon-1.21.3.tgz#f1d5c2a7e855d039836cf4954f883ecac8fc4727" + integrity sha512-lLRwNcNnkZLuv13A1FUuZRZmTWF7ro2ricYvb0L9cvBYHPvZhQdKwrYnZzi103D2XKmlVmxWpdn2wfIiOt2YEw== + make-dir@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"