Polish RBAC role/member stores and remove state-role cycle

This commit is contained in:
2026-04-21 12:00:15 +05:30
parent 7259e4d2cf
commit 39d87fcb50
7 changed files with 29 additions and 71 deletions
+5 -13
View File
@@ -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>