1
0
Fork 0
mirror of synced 2024-07-07 23:35:49 +12:00

enables functionality to delete users from frontend

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-12 11:08:21 +02:00
parent f196f480be
commit 7137cc6f60
2 changed files with 21 additions and 0 deletions

View file

@ -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"

View file

@ -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
}
}