Polish RBAC role/member stores and remove state-role cycle
This commit is contained in:
@@ -4,29 +4,21 @@
|
||||
import {roleColorToCSS} from "@app/core/roles"
|
||||
|
||||
type Props = {
|
||||
role: RoleDefinition | string
|
||||
label?: string
|
||||
color?: number
|
||||
role: RoleDefinition
|
||||
class?: string
|
||||
}
|
||||
|
||||
const {role, label, color, ...props}: Props = $props()
|
||||
|
||||
const roleName = $derived(typeof role === "string" ? role : role.name)
|
||||
const roleLabel = $derived(
|
||||
label || (typeof role === "string" ? undefined : role.label) || roleName,
|
||||
)
|
||||
const roleColor = $derived(color ?? (typeof role === "string" ? undefined : role.color))
|
||||
const {role, ...props}: Props = $props()
|
||||
|
||||
const style = $derived(
|
||||
roleColor === undefined
|
||||
role.color === undefined
|
||||
? ""
|
||||
: `color: ${roleColorToCSS(roleColor)}; border-color: ${roleColorToCSS(roleColor)};`,
|
||||
: `color: ${roleColorToCSS(role.color)}; border-color: ${roleColorToCSS(role.color)};`,
|
||||
)
|
||||
|
||||
const className = $derived(cx("badge badge-outline badge-sm", props.class))
|
||||
</script>
|
||||
|
||||
<span class={className} {style}>
|
||||
{roleLabel}
|
||||
{role.label || role.name}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user