diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue index 03f2bb9..c150fac 100644 --- a/src/components/user/AddAmount.vue +++ b/src/components/user/AddAmount.vue @@ -1,12 +1,61 @@ - - - - - {{ user.firstname }} {{ user.lastname }} + + + Transaktion ist länger als 5 Minuten her! - + + Da die Transaktion länger als 5 Minutern her ist, kann eine + Stornierung nicht durchgeführt werden. Wende dich bitte an den + Finanzer. + + + + + Verstanden + + + + + + + + + + Verlauf + + + + + + + + {{ now(message.date) }} + {{ message.message }} + STORNIERT!!! + Klicken um zu Stornieren + + + + + + + + + {{ user.firstname }} {{ user.lastname }} + + + {{ menuIcon }} + + @@ -95,32 +144,71 @@ > + + {{ message.message }} + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index c8ea406..a9dd05f 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -37,7 +37,8 @@ const url = { answerTransactJob: main + 'user/answerTransactJob', jobRequests: main + 'user/jobRequests', getTransactJobs: main + 'user/getTransactJobs', - deleteTransactJobs: main + 'user/deleteTransactJob' + deleteTransactJobs: main + 'user/deleteTransactJob', + storno: main + 'user/storno' }, barU: { storno: main + 'bar/storno' diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 575501c..eb682d9 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -7,7 +7,8 @@ const state = { loading: false, addLoading: false, error: '', - days: [] + days: [], + message: [] } const mutations = { @@ -157,6 +158,48 @@ const mutations = { if (data.workers) state.days[day].workers = data.workers } } + }, + addMessage: (state, data) => { + var message = '' + if (data.error) { + message = + 'Konnte ' + + (data.amount / 100).toFixed(2) + + '€ zu ' + + data.user.firstname + + ' ' + + data.user.lastname + + ' hinzufügen.' + } else { + message = + '' + + (data.amount / 100).toFixed(2) + + '€ wurde zu ' + + data.user.firstname + + ' ' + + data.user.lastname + + ' hinzugefügt.' + } + state.message.unshift({ + message: message, + user: data.user, + error: data.error, + storno: false, + loading: false, + visible: true, + amount: data.amount, + date: new Date() + }) + console.log(state.message) + }, + updateMessage: (state, data) => { + var message = state.message.find(msg => { + return msg.date - data.date === 0 ? true : false + }) + if (message) { + if (data.storno !== undefined) message.storno = data.storno + if (data.loading !== undefined) message.loading = data.loading + } } } @@ -183,9 +226,20 @@ const actions = { { amount: amount }, { headers: { Token: rootState.login.user.accessToken } } ) + console.log(response.data) commit('setUser', response.data) + commit('addMessage', { + user: rootState.login.user, + amount: amount, + error: false + }) commit('setError', '') } catch (e) { + commit('addMessage', { + user: rootState.login.user, + amount: amount, + error: true + }) if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } @@ -238,6 +292,25 @@ const actions = { console.log(e) } commit('setLoading', false) + }, + async storno({ commit, rootState, dispatch }, data) { + commit('updateMessage', { date: data.date, loading: true }) + try { + const response = await axios.post( + url.user.storno, + { + amount: data.amount + }, + { headers: { Token: rootState.login.user.accessToken } } + ) + console.log(response.data) + commit('setUser', response.data) + commit('updateMessage', { date: data.date, storno: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + commit('updateMessage', { date: data.date, loading: false }) } } @@ -264,6 +337,9 @@ const getters = { }, days: state => { return state.days + }, + messages: state => { + return state.message } }