"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { useInbox, useSdk, type InboxItem, type InboxKind, type InboxState } from "@lynkd/messaging-inbox-sdk"; import { Header } from "@/components/nav/Header"; import { Avatar, Chip } from "@/components/ui/primitives"; import { relativeTime } from "@/lib/format"; import clsx from "clsx"; import { AtSign, Heart, MessageSquare, Bookmark, LifeBuoy, CalendarClock, Bot, Reply, Check, Clock, Archive, ArrowRight, } from "lucide-react"; const kindMeta: Record = { NEEDS_REPLY: { icon: Reply, label: "Needs reply", tone: "text-accent" }, MENTION: { icon: AtSign, label: "Mention", tone: "text-info" }, REACTION: { icon: Heart, label: "Reaction", tone: "text-danger" }, THREAD_REPLY: { icon: MessageSquare, label: "Thread", tone: "text-info" }, SAVED: { icon: Bookmark, label: "Saved", tone: "text-warning" }, APP: { icon: Bot, label: "App", tone: "text-muted" }, SUPPORT_UPDATE: { icon: LifeBuoy, label: "Support", tone: "text-success" }, MEETING_FOLLOWUP: { icon: CalendarClock, label: "Follow-up", tone: "text-info" }, }; const STATES: InboxState[] = ["OPEN", "SNOOZED", "DONE", "ARCHIVED"]; export function InboxView() { const { items, state, setState, loading, markDone, snooze, archive } = useInbox("OPEN"); const [filter, setFilter] = useState("ALL"); const shown = items.filter((i) => filter === "ALL" || i.kind === filter); const kinds: (InboxKind | "ALL")[] = ["ALL", "NEEDS_REPLY", "MENTION", "REACTION", "THREAD_REPLY", "SUPPORT_UPDATE", "SAVED"]; return (
{/* state tabs */}
{STATES.map((s) => ( ))}
{kinds.map((k) => ( ))}
{loading &&
Loading…
} {!loading && shown.length === 0 && (
You're all caught up
Nothing in “{state.toLowerCase()}”.
)}
{shown.map((item) => ( markDone(item.id)} onSnooze={() => snooze(item.id)} onArchive={() => archive(item.id)} /> ))}
); } function InboxRow({ item, onDone, onSnooze, onArchive, }: { item: InboxItem; onDone: () => void; onSnooze: () => void; onArchive: () => void; }) { const { userById } = useSdk(); const router = useRouter(); const meta = kindMeta[item.kind]; const actor = item.actorId ? userById(item.actorId) : undefined; return (
{item.title} {item.priority === "urgent" && urgent} {item.priority === "high" && high} {relativeTime(item.ts)}
{item.preview}
{actor && ( {actor.name} )} {meta.label} {item.dueAt && ( due {relativeTime(item.dueAt)} )}
{/* actions — always visible on touch, hover/focus-reveal on desktop */}
(item.channelId ? router.push(`/c/${item.channelId}`) : router.push("/support"))} />
); } function RowBtn({ title, icon: Icon, onClick, accent, }: { title: string; icon: typeof Check; onClick: () => void; accent?: boolean; }) { return ( ); }