enables functionality to delete users from frontend
This commit is contained in:
parent
f196f480be
commit
7137cc6f60
|
@ -11,13 +11,25 @@
|
|||
Input,
|
||||
Modal,
|
||||
ModalContent,
|
||||
notifications,
|
||||
} from "@budibase/bbui"
|
||||
import { fetchData } from "helpers"
|
||||
import { users } from "stores/portal"
|
||||
|
||||
export let userId
|
||||
let deleteUserModal
|
||||
|
||||
const request = fetchData(`/api/admin/users/${userId}`)
|
||||
|
||||
async function deleteUser() {
|
||||
const res = await users.del(userId)
|
||||
if (res.message) {
|
||||
notifications.success(res.message)
|
||||
$goto("./")
|
||||
} else {
|
||||
notifications.error("Failed to delete user.")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Layout noPadding gap="XS">
|
||||
|
@ -66,6 +78,7 @@
|
|||
<Modal bind:this={deleteUserModal}>
|
||||
<ModalContent
|
||||
warning
|
||||
onConfirm={deleteUser}
|
||||
title="Delete User"
|
||||
confirmText="Delete user"
|
||||
cancelText="Cancel"
|
||||
|
|
|
@ -25,6 +25,13 @@ export function createUsersStore() {
|
|||
|
||||
async function create({ email, password }) {
|
||||
const response = await api.post("/api/admin/users", { email, password, roles: {} })
|
||||
init()
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
async function del(id) {
|
||||
const response = await api.delete(`/api/admin/users/${id}`)
|
||||
init()
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
|
@ -42,6 +49,7 @@ export function createUsersStore() {
|
|||
init,
|
||||
invite,
|
||||
create,
|
||||
del
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue