add working development access toggle

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-19 11:52:12 +02:00
parent 538b51b660
commit 7d8bb8d3bb
2 changed files with 16 additions and 4 deletions

View File

@ -43,7 +43,7 @@
const apps = fetchData(`/api/admin/roles`)
async function deleteUser() {
const res = await users.del(userId)
const res = await users.delete(userId)
if (res.message) {
notifications.success(`User ${$userFetch?.data?.email} deleted.`)
$goto("./")
@ -52,7 +52,14 @@
}
}
async function toggleBuilderAccess() {}
let toggleDisabled = false
async function toggleBuilderAccess({ detail }) {
toggleDisabled = true
await users.save({ ...$userFetch?.data, builder: { global: detail } })
await userFetch.refresh()
toggleDisabled = false
}
async function openUpdateRolesModal({ detail }) {
console.log(detail)
@ -90,7 +97,12 @@
</div>
<div class="field">
<Label size="L">Development access?</Label>
<Toggle text="" value={$userFetch?.data?.builder?.global} />
<Toggle
text=""
value={$userFetch?.data?.builder?.global}
on:change={toggleBuilderAccess}
disabled={toggleDisabled}
/>
</div>
</div>
<div class="regenerate">

View File

@ -14,7 +14,7 @@
let selectedRole
async function updateUserRoles() {
const res = await users.updateRoles({
const res = await users.save({
...user,
roles: {
...user.roles,