Added the new mutation to the admin, Implemented the send massCreation in admin, changed the log entries for not created pendingcreation.

This commit is contained in:
ogerly 2021-12-09 11:53:21 +01:00 committed by elweyn
parent 9237f139f2
commit 5ca221a0c0
3 changed files with 47 additions and 14 deletions

View File

@ -122,6 +122,7 @@
<script> <script>
import { verifyLogin } from '../graphql/verifyLogin' import { verifyLogin } from '../graphql/verifyLogin'
import { createPendingCreation } from '../graphql/createPendingCreation' import { createPendingCreation } from '../graphql/createPendingCreation'
import { createPendingCreations } from '../graphql/createPendingCreations'
export default { export default {
name: 'CreationFormular', name: 'CreationFormular',
props: { props: {
@ -202,28 +203,52 @@ export default {
submitCreation() { submitCreation() {
if (this.type === 'massCreation') { if (this.type === 'massCreation') {
// Die anzahl der Mitglieder aus der Mehrfachschöpfung // Die anzahl der Mitglieder aus der Mehrfachschöpfung
const i = Object.keys(this.itemsMassCreation).length const i = Object.keys(this.items).length
// hinweis das eine Mehrfachschöpfung ausgeführt wird an (Anzahl der MItgleider an die geschöpft wird) // hinweis das eine Mehrfachschöpfung ausgeführt wird an (Anzahl der MItgleider an die geschöpft wird)
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder') console.log('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder')
this.submitObj = [ this.submitObj = []
{ this.items.forEach((item) => {
item: this.itemsMassCreation, this.submitObj.push({
email: this.item.email, email: item.email,
creationDate: this.radioSelected.long, creationDate: this.radioSelected.long,
amount: this.value, amount: Number(this.value),
memo: this.text, memo: this.text,
moderator: this.$store.state.moderator.id, moderator: Number(this.$store.state.moderator.id),
}, })
] })
console.log('submitObj', this.submitObj)
// this.submitObj = [
// {
// item: this.itemsMassCreation,
// email: this.item.email,
// creationDate: this.radioSelected.long,
// amount: this.value,
// memo: this.text,
// moderator: this.$store.state.moderator.id,
// },
// ]
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('MehrfachSCHÖPFUNG ABSENDEN FÜR >> ' + i + ' Mitglieder') console.log('MehrfachSCHÖPFUNG ABSENDEN FÜR >> ' + i + ' Mitglieder')
this.$apollo
.mutate({
mutation: createPendingCreations,
variables: {
pendingCreations: this.submitObj,
},
})
.then(() => {
this.$store.commit('openCreationsPlus', this.submitObj.length)
this.$emit('remove-all-bookmark')
})
.catch(() => {
console.log('Fehler bei der mehrfach Schöpfung')
})
// $store - offene Schöpfungen hochzählen // $store - offene Schöpfungen hochzählen
this.$store.commit('openCreationsPlus', i) // this.$store.commit('openCreationsPlus', i)
// lösche alle Mitglieder aus der MehrfachSchöpfungsListe nach dem alle Mehrfachschpfungen zum bestätigen gesendet wurden. // lösche alle Mitglieder aus der MehrfachSchöpfungsListe nach dem alle Mehrfachschpfungen zum bestätigen gesendet wurden.
this.$emit('remove-all-bookmark') // this.$emit('remove-all-bookmark')
} else if (this.type === 'singleCreation') { } else if (this.type === 'singleCreation') {
this.submitObj = { this.submitObj = {
email: this.item.email, email: this.item.email,

View File

@ -0,0 +1,7 @@
import gql from 'graphql-tag'
export const createPendingCreations = gql`
mutation ($pendingCreations: [CreatePendingCreationArgs!]!) {
createPendingCreations(pendingCreations: $pendingCreations)
}
`

View File

@ -69,8 +69,9 @@ export class AdminResolver {
pendingCreations: CreatePendingCreationArgs[], pendingCreations: CreatePendingCreationArgs[],
): Promise<boolean> { ): Promise<boolean> {
pendingCreations.forEach((pendingCreation) => { pendingCreations.forEach((pendingCreation) => {
console.log('pendingCreation', pendingCreation) this.createPendingCreation(pendingCreation).catch((error) => {
this.createPendingCreation(pendingCreation) console.log('pendingCreation ' + JSON.stringify(pendingCreation) + ' had an error ' + error)
})
}) })
return true return true
} }