From 36b098bc7320c90eaa61e559a612bb702601a025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Wed, 19 May 2021 11:52:12 +0200 Subject: [PATCH] add working development access toggle --- .../portal/manage/users/[userId].svelte | 18 +++++++++++++++--- .../users/_components/UpdateRolesModal.svelte | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte b/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte index 8968384c91..00b6d15b79 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/[userId].svelte @@ -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 @@
- +
diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/UpdateRolesModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/UpdateRolesModal.svelte index 4e47d96552..7c5500acd8 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/UpdateRolesModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/UpdateRolesModal.svelte @@ -14,7 +14,7 @@ let selectedRole async function updateUserRoles() { - const res = await users.updateRoles({ + const res = await users.save({ ...user, roles: { ...user.roles,