1
0
Fork 0
mirror of synced 2024-07-02 04:50:44 +12:00

simplify fetching

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-17 16:16:51 +02:00
parent 50a7138486
commit 69471a42ce
2 changed files with 8 additions and 6 deletions

View file

@ -29,9 +29,10 @@
}
// Merge the Apps list and the roles response to get something that makes sense for the table
$: appList = Object.keys($apps?.data).map(app => ({
name: $apps?.data?.[app]?.name,
role: $roleFetch?.data?.roles?.[app],
$: appList = Object.keys($apps?.data).map(id => ({
...$apps?.data?.[id],
_id: id,
role: $roleFetch?.data?.roles?.[id],
}))
let selectedApp
@ -49,6 +50,7 @@
}
async function openUpdateRolesModal({ detail }) {
console.log(detail)
selectedApp = detail
editRolesModal.show()
}

View file

@ -9,8 +9,8 @@
const dispatch = createEventDispatcher()
const roles = fetchData(`/api/admin/roles/${app._id}`)
$: options = $roles?.data?.roles?.map(role => role._id)
const roles = app.roles
let options = roles.map(role => role._id)
let selectedRole
async function updateUserRoles() {
@ -22,7 +22,7 @@
},
})
if (res.status === 400) {
notifications.error("Failed to update role.")
notifications.error("Failed to update role")
} else {
notifications.success("Roles updated")
dispatch("update")