From f212c5962c9628e06e821c5ea97c5f0f358bc9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 1 Sep 2020 10:04:21 +0200 Subject: [PATCH] Bugfix: Beim updaten der FreeDrinkListHistory kommt kein Networkfehler --- src/components/baruser/BarFreedrinks.vue | 2 ++ src/components/user/freedrink/freedrinkUserView.vue | 4 +++- src/store/modules/freeDrinkList.js | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/baruser/BarFreedrinks.vue b/src/components/baruser/BarFreedrinks.vue index e3ba181..82ccf53 100644 --- a/src/components/baruser/BarFreedrinks.vue +++ b/src/components/baruser/BarFreedrinks.vue @@ -285,6 +285,8 @@ export default { 'ERROR: ' + message.free_drink_type.name +': Konnte ' + message.label + ' für ' + (message.price / 100).toFixed(2) + '€ nicht hinzufügen.' + } else if (message.canceled) { + text = `${message.free_drink_type.name}: ${message.label} wurde für ${(message.price/100).toFixed(2)}€ storniert.` } else { text = message.free_drink_type.name + ': ' + message.label + ' wurde für ' + (message.price / 100).toFixed(2) + '€ hinzugefügt.' } diff --git a/src/components/user/freedrink/freedrinkUserView.vue b/src/components/user/freedrink/freedrinkUserView.vue index 1a94a5a..487a35e 100644 --- a/src/components/user/freedrink/freedrinkUserView.vue +++ b/src/components/user/freedrink/freedrinkUserView.vue @@ -296,7 +296,7 @@ export default { this.amount = null this.selectedReason = null this.reasonDescription = null - this.drinkCount = 0 + this.drinkCount = 1 this.free_drink_type_id = null this.free_drink = null }, @@ -321,6 +321,8 @@ export default { ' für ' + (message.price / 100).toFixed(2) + '€ nicht hinzufügen.' + } else if (message.canceled) { + text = `${message.free_drink_type.name}: ${message.label} wurde für ${(message.price/100).toFixed(2)}€ storniert.` } else { text = message.free_drink_type.name + diff --git a/src/store/modules/freeDrinkList.js b/src/store/modules/freeDrinkList.js index f95451b..acf03d6 100644 --- a/src/store/modules/freeDrinkList.js +++ b/src/store/modules/freeDrinkList.js @@ -44,9 +44,11 @@ const mutations = { add_snackbar_message(state, { data, error }) { data.error = error data.visible = true - data.free_drink_type = data.free_drink_types.find(item => { + data.label = data.free_drink_config != null && data.label == null ? data.free_drink_config.label : data.label + data.price = data.free_drink_config != null && data.price == null ? data.free_drink_config.price : data.price + data.free_drink_type = data.free_drink_type == null ? data.free_drink_types.find(item => { return item.id == data.free_drink_type_id - }) + }) : data.free_drink_type data.timer = setTimeout(() => { if (!data.error) { data.visible = false @@ -98,8 +100,10 @@ const actions = { headers: { Token: rootState.login.user.accessToken }, timeout }) + console.log(response.data) commit('set_free_drink_list_history', response.data) } catch (e) { + console.log(e) if (e.message == 'Network Error') { dispatch('connectionError/addError', null, { root: true }) } @@ -138,6 +142,7 @@ const actions = { timeout } ) + console.log(data) commit('set_free_drink_list_history', response.data) commit('add_snackbar_message', { data, error: false }) } catch (e) { @@ -153,15 +158,18 @@ const actions = { }, async update_free_drink_list_history({ commit, dispatch, rootState }, data) { try { + console.log(data) commit('set_free_drink_list_history_loading', true) const response = await axios.put( url.freeDrinkListHistory, { ...data }, { headers: { Token: rootState.login.user.accessToken }, timeout } ) + console.log(response.data) commit('set_free_drink_list_history', response.data) commit('add_snackbar_message', { data, error: false }) } catch (e) { + console.log(e) dispatch('connectionError/addError', null, { root: true }) if (e.message == 'Network Error') { dispatch('connectionError/addError', null, { root: true })