diff --git a/src/components/pages/UsersPage/UserCard.tsx b/src/components/pages/UsersPage/UserCard.tsx index 704f0c0..38871d3 100644 --- a/src/components/pages/UsersPage/UserCard.tsx +++ b/src/components/pages/UsersPage/UserCard.tsx @@ -1,6 +1,13 @@ import { useNavigate } from "react-router" -import { Calendar, Shield, ChevronRight } from "lucide-react" -import type { UserListResponse, UserRoleResponse, AppResponse } from "@/types" +import { + Calendar, + Shield, + ChevronRight, + UserCog, + User as UserIcon, + type LucideIcon, +} from "lucide-react" +import type { UserListResponse, UserRoleResponse, AppResponse, UserRole } from "@/types" import { cn } from "@/utils/cn" import { Badge } from "@/components/ui/badge" import { card } from "@/styles" @@ -13,6 +20,15 @@ interface UserCardProps { apps: AppResponse[] } +const roleBadge: Record< + UserRole, + { variant: "admin" | "manager" | "member"; icon: LucideIcon; label: string } +> = { + platform_admin: { variant: "admin", icon: Shield, label: "Admin" }, + manager: { variant: "manager", icon: UserCog, label: "Manager" }, + member: { variant: "member", icon: UserIcon, label: "Member" }, +} + function getUniqueApps(roles: UserRoleResponse[], apps: AppResponse[]) { const appKeys = [...new Set(roles.map((r) => r.app_key))] return appKeys.map((key) => { @@ -24,6 +40,8 @@ function getUniqueApps(roles: UserRoleResponse[], apps: AppResponse[]) { export function UserCard({ user, roles, apps }: UserCardProps) { const navigate = useNavigate() const userApps = getUniqueApps(roles, apps) + const role = user.role ?? (user.is_platform_admin ? "platform_admin" : "member") + const { variant, icon: RoleIcon, label } = roleBadge[role] return (