Bugfix: Beim updaten der FreeDrinkListHistory kommt kein Networkfehler

This commit is contained in:
Tim Gröger 2020-09-01 10:04:21 +02:00
parent 3d311d3677
commit f212c5962c
3 changed files with 15 additions and 3 deletions

View File

@ -285,6 +285,8 @@ export default {
'ERROR: ' + message.free_drink_type.name +': Konnte ' + message.label + ' für ' + 'ERROR: ' + message.free_drink_type.name +': Konnte ' + message.label + ' für ' +
(message.price / 100).toFixed(2) + (message.price / 100).toFixed(2) +
'€ nicht hinzufügen.' '€ 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 { } else {
text = message.free_drink_type.name + ': ' + message.label + ' wurde für ' + (message.price / 100).toFixed(2) + '€ hinzugefügt.' text = message.free_drink_type.name + ': ' + message.label + ' wurde für ' + (message.price / 100).toFixed(2) + '€ hinzugefügt.'
} }

View File

@ -296,7 +296,7 @@ export default {
this.amount = null this.amount = null
this.selectedReason = null this.selectedReason = null
this.reasonDescription = null this.reasonDescription = null
this.drinkCount = 0 this.drinkCount = 1
this.free_drink_type_id = null this.free_drink_type_id = null
this.free_drink = null this.free_drink = null
}, },
@ -321,6 +321,8 @@ export default {
' für ' + ' für ' +
(message.price / 100).toFixed(2) + (message.price / 100).toFixed(2) +
'€ nicht hinzufügen.' '€ 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 { } else {
text = text =
message.free_drink_type.name + message.free_drink_type.name +

View File

@ -44,9 +44,11 @@ const mutations = {
add_snackbar_message(state, { data, error }) { add_snackbar_message(state, { data, error }) {
data.error = error data.error = error
data.visible = true 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 return item.id == data.free_drink_type_id
}) }) : data.free_drink_type
data.timer = setTimeout(() => { data.timer = setTimeout(() => {
if (!data.error) { if (!data.error) {
data.visible = false data.visible = false
@ -98,8 +100,10 @@ const actions = {
headers: { Token: rootState.login.user.accessToken }, headers: { Token: rootState.login.user.accessToken },
timeout timeout
}) })
console.log(response.data)
commit('set_free_drink_list_history', response.data) commit('set_free_drink_list_history', response.data)
} catch (e) { } catch (e) {
console.log(e)
if (e.message == 'Network Error') { if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true }) dispatch('connectionError/addError', null, { root: true })
} }
@ -138,6 +142,7 @@ const actions = {
timeout timeout
} }
) )
console.log(data)
commit('set_free_drink_list_history', response.data) commit('set_free_drink_list_history', response.data)
commit('add_snackbar_message', { data, error: false }) commit('add_snackbar_message', { data, error: false })
} catch (e) { } catch (e) {
@ -153,15 +158,18 @@ const actions = {
}, },
async update_free_drink_list_history({ commit, dispatch, rootState }, data) { async update_free_drink_list_history({ commit, dispatch, rootState }, data) {
try { try {
console.log(data)
commit('set_free_drink_list_history_loading', true) commit('set_free_drink_list_history_loading', true)
const response = await axios.put( const response = await axios.put(
url.freeDrinkListHistory, url.freeDrinkListHistory,
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken }, timeout } { headers: { Token: rootState.login.user.accessToken }, timeout }
) )
console.log(response.data)
commit('set_free_drink_list_history', response.data) commit('set_free_drink_list_history', response.data)
commit('add_snackbar_message', { data, error: false }) commit('add_snackbar_message', { data, error: false })
} catch (e) { } catch (e) {
console.log(e)
dispatch('connectionError/addError', null, { root: true }) dispatch('connectionError/addError', null, { root: true })
if (e.message == 'Network Error') { if (e.message == 'Network Error') {
dispatch('connectionError/addError', null, { root: true }) dispatch('connectionError/addError', null, { root: true })