check if user is member before adding user to group

This commit is contained in:
Moriz Wahl 2022-11-07 16:58:21 +01:00
parent a1fcc40432
commit 55003447e5
3 changed files with 12 additions and 1 deletions

View File

@ -179,12 +179,17 @@ export default {
}, },
async addMemberToGroup() { async addMemberToGroup() {
const newRole = 'usual' const newRole = 'usual'
if (this.groupMembers.find((member) => member.id === this.slugUser[0].id)) {
this.$toast.error(
this.$t('group.errors.userAlreadyMember', { slug: this.slugUser[0].slug }),
)
return
}
try { try {
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: changeGroupMemberRoleMutation(), mutation: changeGroupMemberRoleMutation(),
variables: { groupId: this.groupId, userId: this.slugUser[0].id, roleInGroup: newRole }, variables: { groupId: this.groupId, userId: this.slugUser[0].id, roleInGroup: newRole },
}) })
// this.$apollo.queries.GroupMembers.refetch()
this.$emit('loadGroupMembers') this.$emit('loadGroupMembers')
this.slugUser = [] this.slugUser = []
this.form.query = '' this.form.query = ''

View File

@ -422,6 +422,9 @@
"groupName": "Einstellungen für „{name}“", "groupName": "Einstellungen für „{name}“",
"title": "Meine Gruppe ändern" "title": "Meine Gruppe ändern"
}, },
"errors": {
"userAlreadyMember": "Nutzer @{slug} ist bereits Mitglied"
},
"follow": "Folge", "follow": "Folge",
"foundation": "Gründung", "foundation": "Gründung",
"general": "Allgemein", "general": "Allgemein",

View File

@ -422,6 +422,9 @@
"groupName": "Settings Of “{name}”", "groupName": "Settings Of “{name}”",
"title": "Edit My Group" "title": "Edit My Group"
}, },
"errors": {
"userAlreadyMember": "User @{slug} is already a member"
},
"follow": "Follow", "follow": "Follow",
"foundation": "Foundation", "foundation": "Foundation",
"general": "General", "general": "General",