"use client"; import { useRouter } from "next/navigation"; import { useSdk } from "@lynkd/messaging-inbox-sdk"; import { useUi } from "@/lib/ui-state"; import { Avatar, Chip } from "@/components/ui/primitives"; import { X, MessageSquare, Phone, Clock, Mail, AtSign, Smile, Pencil } from "lucide-react"; export function ProfileDrawer() { const { profileUserId, closeProfile, startHuddle, toast, openModal } = useUi(); const { userById, me, channels, client, refresh } = useSdk(); const router = useRouter(); if (!profileUserId) return null; const user = userById(profileUserId); if (!user) return null; const isMe = user.id === me?.id; async function openDm() { if (!user) return; const existing = channels.find((c) => c.kind === "dm" && c.memberIds.includes(user.id)); closeProfile(); if (existing) { router.push(`/c/${existing.id}`); return; } const { channel } = await client.createChannel({ name: user.name, kind: "dm", memberIds: [user.id] }); refresh(); router.push(`/c/${channel.id}`); } async function huddle() { if (!user) return; const existing = channels.find((c) => c.kind === "dm" && c.memberIds.includes(user.id)); closeProfile(); if (existing) startHuddle(existing.id); else toast(`Starting a huddle with ${user.name}…`, "success"); } return (
e.stopPropagation()}>
Profile

{user.name}

{user.title}
{user.statusText &&
{user.statusEmoji} {user.statusText}
}
{user.presence}
{!isMe && (
)} {isMe && ( <>
Availability
{([ { p: "active", label: "Active", dot: "bg-success" }, { p: "away", label: "Away", dot: "bg-warning" }, { p: "dnd", label: "Do not disturb", dot: "bg-danger" }, ] as const).map((o) => ( ))}
)}
{user.email && } {user.timezone && } {user.pronouns && }
); } function Field({ icon: Icon, label, value }: { icon: typeof Mail; label: string; value: string }) { return (
{label}
{value}
); }