simplify fetching
This commit is contained in:
parent
b0265efb29
commit
52c7980e08
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue