refactor: better error prompts
This commit is contained in:
parent
3992650fd6
commit
d5c5fb7435
2 changed files with 21 additions and 17 deletions
|
|
@ -312,13 +312,26 @@ export default {
|
|||
})
|
||||
return
|
||||
}
|
||||
let invalidEmail = false
|
||||
this.$data.newMembers.forEach((element) => {
|
||||
if (!this.validateEmail(element.key)) {
|
||||
this.$toast.error(this.$t("invalid_emailID_format"), {
|
||||
icon: "error",
|
||||
})
|
||||
invalidEmail = true
|
||||
}
|
||||
})
|
||||
if (invalidEmail) return
|
||||
let invalidPermission = false
|
||||
this.$data.newMembers.forEach((element) => {
|
||||
if (!element.value) {
|
||||
this.$toast.error(this.$t("invalid_member_permission"), {
|
||||
icon: "error",
|
||||
})
|
||||
invalidPermission = true
|
||||
}
|
||||
})
|
||||
if (invalidPermission) return
|
||||
this.$data.newMembers.forEach((element) => {
|
||||
// Call to the graphql mutation
|
||||
teamUtils
|
||||
|
|
@ -333,17 +346,15 @@ export default {
|
|||
this.$toast.success(this.$t("team_saved"), {
|
||||
icon: "done",
|
||||
})
|
||||
this.hideModal()
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
this.$toast.error(error, {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
})
|
||||
let messageShown = true
|
||||
this.members.forEach((element) => {
|
||||
teamUtils
|
||||
.updateTeamMemberRole(
|
||||
|
|
@ -354,22 +365,15 @@ export default {
|
|||
)
|
||||
.then(() => {
|
||||
// Result
|
||||
if (messageShown) {
|
||||
this.$toast.success(this.$t("role_updated"), {
|
||||
icon: "done",
|
||||
})
|
||||
messageShown = false
|
||||
}
|
||||
this.hideModal()
|
||||
this.$toast.success(this.$t("role_updated"), {
|
||||
icon: "done",
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
if (messageShown) {
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
messageShown = false
|
||||
}
|
||||
this.$toast.error(error, {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
})
|
||||
|
|
@ -389,7 +393,6 @@ export default {
|
|||
this.$toast.success(this.$t("team_saved"), {
|
||||
icon: "done",
|
||||
})
|
||||
this.hideModal()
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@
|
|||
"use_team": "Use Team",
|
||||
"add_one_member": "(add at least one member)",
|
||||
"permissions": "Permissions",
|
||||
"invalid_member_permission": "Please provide a valid permission to the team member",
|
||||
"email": "E-mail",
|
||||
"create_new_team": "Create new team",
|
||||
"new_team_created": "New team created",
|
||||
|
|
|
|||
Loading…
Reference in a new issue