import type { ReactNode } from "react"; import { BoltIcon, ChatBubbleLeftEllipsisIcon, Cog6ToothIcon, CpuChipIcon, ServerIcon, } from "@heroicons/react/20/solid"; import type { Principal } from "@qltysh/fabro-api-client"; export interface PrincipalDisplay { glyph: ReactNode; label: string; } function principalIconGlyph(icon: ReactNode) { return ( {icon} ); } export function principalDisplay(actor: Principal): PrincipalDisplay { switch (actor.kind) { case "user": { let glyph: ReactNode; if (actor.avatar_url) { glyph = ( ); } else { const initial = actor.login.charAt(0).toUpperCase() || "?"; glyph = ( {initial} ); } return { glyph, label: actor.login }; } case "agent": return { glyph: principalIconGlyph(), label: "agent" }; case "system": return { glyph: principalIconGlyph(), label: "system" }; case "slack": return { glyph: principalIconGlyph(), label: "slack", }; case "webhook": return { glyph: principalIconGlyph(), label: "webhook" }; case "worker": return { glyph: principalIconGlyph(), label: "worker" }; } }