fix: Creation Confirmation User Ids

This commit is contained in:
Moriz Wahl 2022-01-26 14:31:13 +01:00
parent c595c47d90
commit 43d811e2fa
3 changed files with 65 additions and 73 deletions

View File

@ -161,8 +161,6 @@ import ConfirmRegisterMailFormular from '../components/ConfirmRegisterMailFormul
import CreationTransactionListFormular from '../components/CreationTransactionListFormular.vue'
import RowDetails from '../components/RowDetails.vue'
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
const slotNames = ['show-creation', 'show-register-mail', 'show-transaction-list']
export default {
@ -272,7 +270,7 @@ export default {
this.bookmarkRemove(item)
}
if (bookmarkType === 'confirm') {
this.bookmarkConfirm(item)
this.$emit('confirm-creation', item)
}
this.overlay = false
},
@ -288,24 +286,9 @@ export default {
}
if (this.type === 'PageCreationConfirm') {
this.$emit('remove-confirm-result', item, 'remove')
this.$emit('remove-creation', item)
}
},
bookmarkConfirm(item) {
this.$apollo
.mutate({
mutation: confirmPendingCreation,
variables: {
id: item.id,
},
})
.then(() => {
this.$emit('remove-confirm-result', item, 'confirmed')
})
.catch((error) => {
this.$toasted.error(error.message)
})
},
updateCreationData(data) {
this.creationUserData.amount = data.amount
this.creationUserData.date = data.date

View File

@ -126,6 +126,7 @@ export default {
currentPage: this.currentPage,
pageSize: this.perPage,
},
fetchPolicy: 'network-only',
})
.then((result) => {
this.rows = result.data.searchUsers.userCount
@ -162,8 +163,8 @@ export default {
}
},
removeAllBookmark() {
this.itemsMassCreation.forEach((item) => this.itemsList.push(item))
this.itemsMassCreation = []
this.getUsers()
},
},
watch: {

View File

@ -5,7 +5,8 @@
type="PageCreationConfirm"
:itemsUser="confirmResult"
:fieldsTable="fields"
@remove-confirm-result="removeConfirmResult"
@remove-creation="removeCreation"
@confirm-creation="confirmCreation"
/>
</div>
</template>
@ -13,6 +14,7 @@
import UserTable from '../components/UserTable.vue'
import { getPendingCreations } from '../graphql/getPendingCreations'
import { deletePendingCreation } from '../graphql/deletePendingCreation'
import { confirmPendingCreation } from '../graphql/confirmPendingCreation'
export default {
name: 'CreationConfirm',
@ -21,8 +23,63 @@ export default {
},
data() {
return {
showArrays: false,
fields: [
confirmResult: [],
}
},
methods: {
removeCreation(item) {
this.$apollo
.mutate({
mutation: deletePendingCreation,
variables: {
id: item.id,
},
})
.then((result) => {
this.confirmResult = this.confirmResult.filter((obj) => obj.id !== item.id)
this.$store.commit('openCreationsMinus', 1)
this.$toasted.success(this.$t('creation_form.toasted_delete'))
})
.catch((error) => {
this.$toasted.error(error.message)
})
},
confirmCreation(item) {
this.$apollo
.mutate({
mutation: confirmPendingCreation,
variables: {
id: item.id,
},
})
.then(() => {
this.confirmResult = this.confirmResult.filter((obj) => obj.id !== item.id)
this.$store.commit('openCreationsMinus', 1)
this.$toasted.success(this.$t('creation_form.toasted_created'))
})
.catch((error) => {
this.$toasted.error(error.message)
})
},
getPendingCreations() {
this.$apollo
.query({
query: getPendingCreations,
fetchPolicy: 'network-only',
})
.then((result) => {
this.$store.commit('resetOpenCreations')
this.confirmResult = result.data.getPendingCreations
this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
})
.catch((error) => {
this.$toasted.error(error.message)
})
},
},
computed: {
fields() {
return [
{ key: 'bookmark', label: 'löschen' },
{ key: 'email', label: 'Email' },
{ key: 'firstName', label: 'Vorname' },
@ -45,56 +102,7 @@ export default {
{ key: 'moderator', label: 'Moderator' },
{ key: 'edit_creation', label: 'ändern' },
{ key: 'confirm', label: 'speichern' },
],
confirmResult: [],
}
},
methods: {
removeConfirmResult(e, event) {
let index = 0
const findArr = this.confirmResult.find((arr) => arr.id === e.id)
switch (event) {
case 'remove':
this.$apollo
.mutate({
mutation: deletePendingCreation,
variables: {
id: findArr.id,
},
})
.then((result) => {
index = this.confirmResult.indexOf(findArr)
this.confirmResult.splice(index, 1)
this.$store.commit('openCreationsMinus', 1)
this.$toasted.success(this.$t('creation_form.toasted_delete'))
})
.catch((error) => {
this.$toasted.error(error.message)
})
break
case 'confirmed':
this.confirmResult.splice(index, 1)
this.$store.commit('openCreationsMinus', 1)
this.$toasted.success(this.$t('creation_form.toasted_created'))
break
default:
this.$toasted.error(this.$t('creation_form.toasted_default', { event }))
}
},
getPendingCreations() {
this.$apollo
.query({
query: getPendingCreations,
fetchPolicy: 'network-only',
})
.then((result) => {
this.$store.commit('resetOpenCreations')
this.confirmResult = result.data.getPendingCreations
this.$store.commit('setOpenCreations', result.data.getPendingCreations.length)
})
.catch((error) => {
this.$toasted.error(error.message)
})
]
},
},
async created() {