diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index cbad491..90b99ac 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -24,18 +24,19 @@ - -
- +
+ {{ now(message.date) }} {{ message.message }} + STORNIERT!!! Klicken um zu Stornieren - + >Klicken um zu Stornieren +
@@ -214,7 +215,8 @@ export default { ...mapActions({ addAmount: 'barUsers/addAmount', getUsers: 'barUsers/getUsers', - deactivate: 'barUsers/deactivateMenu' + deactivate: 'barUsers/deactivateMenu', + commitStorno: 'barUsers/storno' }), getColor(type) { return type === 'credit' ? 'title green--text' : 'title red--text' @@ -231,9 +233,10 @@ export default { }, storno(message) { if (!message.error) { - console.log(message) - message.storno = true if (!this.under5minutes(message.date)) this.dialog = true + else { + this.commitStorno({username: message.user.username, amount: message.amount, date: message.date}) + } } } }, @@ -267,7 +270,6 @@ export default { var actual = new Date() var zero = new Date(0) var date = new Date(actual - now) - console.log(date) if (date.getFullYear() === zero.getFullYear()) { if (date.getMonth() === zero.getMonth()) { if (date.getDate() === zero.getDate()) { @@ -301,13 +303,10 @@ export default { }, watch: { menu(newValue) { - console.log('menu', newValue) if (!newValue) this.deactivate() }, menu_from_store(newValue) { - console.log('for menu_from_store', newValue, this.menu) if (newValue) this.menu = this.menu_from_store - console.log('after menu_from_store', newValue, this.menu) } } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index f7f0e25..caabd83 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,7 +1,7 @@ //const main = 'https://192.168.5.128:5000/' -//const main = 'http://localhost:5000/' +const main = 'http://localhost:5000/' //const main = 'http://192.168.5.118:5000/' -const main = 'https://groeger-clan.duckdns.org:5000/' +//const main = 'https://groeger-clan.duckdns.org:5000/' const url = { login: main + 'login', @@ -30,6 +30,9 @@ const url = { user: { config: main + 'user/saveConfig', job: main + 'user/job' + }, + barU: { + storno: main + 'bar/storno' } } diff --git a/src/store/modules/barUsers.js b/src/store/modules/barUsers.js index 0744c48..ba72e29 100644 --- a/src/store/modules/barUsers.js +++ b/src/store/modules/barUsers.js @@ -96,6 +96,7 @@ const mutations = { } state.message.unshift({ message: message, + user: data.user, error: data.error, storno: false, visible: true, @@ -104,6 +105,12 @@ const mutations = { }) console.log(state.message) }, + updateMessage: (state, data) => { + var message = state.message.find(msg => {return msg.date - data.date === 0 ? true : false}) + if (message) { + message.storno = true + } + }, setMenu: (state, value) => { state.menu = value } @@ -179,6 +186,25 @@ const actions = { } commit('setAllUsersLoading', false) }, + async storno({ commit, rootState, dispatch }, data) { + commit('setUsersLoading', true) + try { + const response = await axios.post( + url.barU.storno, + { + userId: data.username, + amount: data.amount + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('setUsers', { [response.data.username]: response.data }) + commit('updateMessage', { date: data.date }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + commit('setUsersLoading', false) + }, setFilter({ commit }, data) { commit('setFilter', data) },