Update browser confirm prompts to use confirm prompt modal instead

This commit is contained in:
advplyr 2025-02-24 17:44:17 -06:00
parent c7d8021a16
commit b0045b5b8b
5 changed files with 129 additions and 73 deletions

View file

@ -91,24 +91,36 @@ export default {
},
deleteUserClick(user) {
if (this.isDeletingUser) return
if (confirm(this.$getString('MessageRemoveUserWarning', [user.username]))) {
this.isDeletingUser = true
this.$axios
.$delete(`/api/users/${user.id}`)
.then((data) => {
this.isDeletingUser = false
if (data.error) {
this.$toast.error(data.error)
} else {
this.$toast.success(this.$strings.ToastUserDeleteSuccess)
}
})
.catch((error) => {
console.error('Failed to delete user', error)
this.$toast.error(this.$strings.ToastUserDeleteFailed)
this.isDeletingUser = false
})
const payload = {
message: this.$getString('MessageRemoveUserWarning', [user.username]),
callback: (confirmed) => {
if (confirmed) {
this.deleteUser(user)
}
},
type: 'yesNo'
}
this.$store.commit('globals/setConfirmPrompt', payload)
},
deleteUser(user) {
this.isDeletingUser = true
this.$axios
.$delete(`/api/users/${user.id}`)
.then((data) => {
if (data.error) {
this.$toast.error(data.error)
} else {
this.$toast.success(this.$strings.ToastUserDeleteSuccess)
}
})
.catch((error) => {
console.error('Failed to delete user', error)
this.$toast.error(this.$strings.ToastUserDeleteFailed)
})
.finally(() => {
this.isDeletingUser = false
})
},
editUser(user) {
this.$emit('edit', user)