From e972e79df405f39b25c00fb7cca6d35387325729 Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Mon, 29 Nov 2021 20:16:23 +0100 Subject: [PATCH] Version 1.1 --- components/publicwishlist.vue | 8 ++++---- store/wishes.js | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/publicwishlist.vue b/components/publicwishlist.vue index 8597a94..2bd5043 100644 --- a/components/publicwishlist.vue +++ b/components/publicwishlist.vue @@ -39,17 +39,17 @@ export default { return wish.owner_id === id; }); }, - claimWish(id) { - let response = this.$swal({ + async claimWish(id) { + let response = await this.$swal({ title: 'Wunsch reservieren?', html: 'Du kannst Wünsche NICHT wieder freigeben!
Bitte sei dir sicher bevor du reservierst!', type: 'warning', showCancelButton: true, cancelButtonText: "Abbrechen", confirmButtonText: 'Reservieren', - }).value; + }); - if(!response) { + if (!response.value) { return; } diff --git a/store/wishes.js b/store/wishes.js index 453d0bb..b7cb406 100644 --- a/store/wishes.js +++ b/store/wishes.js @@ -41,13 +41,23 @@ export const actions = { deleteWish({ commit, state }, wishid) { return this.$axios.$delete(BASE_API_URL + '/wishes/' + wishid, getAxiosConfig(localStorage.getItem("token"))).then(() => { commit('setPersonal', state.personal.filter(w => w.id !== wishid)) + }).catch((err) => { + this._vm.$swal({ + text: err.response.data.toString(), + type: 'error', + showConfirmButton: false, + timerProgressBar: true, + timer: 3000, + toast: true, + position: 'bottom-center', + iconColor: 'white' + }) }) }, claimWish({ commit, state }, wishid) { return this.$axios.$post(BASE_API_URL + '/wishes/' + wishid + '/claim', {}, getAxiosConfig(localStorage.getItem("token"))).then(async () => { commit('setPublic', state.public.filter(w => w.id !== wishid)) - await this.dispatch('wishes/fetchPublic') - await this.dispatch('wishes/fetchClaimed') + await this.dispatch('fetchClaimed', state) }) }, }