add deletedUser and unDeleteUser function in admin frontend

This commit is contained in:
ogerly 2022-02-18 14:15:18 +01:00 committed by Ulf Gebhardt
parent 0de018b296
commit 9f4762647b
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
3 changed files with 47 additions and 4 deletions

View File

@ -6,12 +6,14 @@
</div>
<div class="mt-3">GDD Stand: 20 GDD</div>
<div class="mt-3 mb-5">
<b-button v-if="checked" variant="success" @click="deleteAdd">User now deleted</b-button>
<b-button v-if="checked" variant="danger" @click="deleteUser">Delete User</b-button>
<b-button v-if="checked" variant="success" @click="unDeleteUser">Undelete User</b-button>
</div>
</div>
</template>
<script>
// import { sendActivationEmail } from '../graphql/sendActivationEmail'
import { deleteUser } from '../graphql/deleteUser'
import { unDeleteUser } from '../graphql/unDeleteUser'
export default {
name: 'DeletedUser',
@ -26,8 +28,35 @@ export default {
}
},
methods: {
deleteAdd() {
alert('TODO: Apollo query deleteAdd')
deleteUser() {
this.$apollo
.mutate({
mutation: deleteUser,
variables: {
userId: this.item.userId,
},
})
.then(() => {
this.$toasted.success('user is deleted')
})
.catch((error) => {
this.$toasted.error('user deleted error', error)
})
},
unDeleteUser() {
this.$apollo
.mutate({
mutation: unDeleteUser,
variables: {
userId: this.item.userId,
},
})
.then(() => {
this.$toasted.success('user is undeleted')
})
.catch((error) => {
this.$toasted.error('user undeleted error', error)
})
},
},
}

View File

@ -0,0 +1,7 @@
import gql from 'graphql-tag'
export const deleteUser = gql`
mutation ($userId: Int!) {
deleteUser(userId: $userId)
}
`

View File

@ -0,0 +1,7 @@
import gql from 'graphql-tag'
export const unDeleteUser = gql`
mutation ($userId: Int!) {
unDeleteUser(userId: $userId)
}
`