{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-feed",
  "title": "Activity feed",
  "description": "Color-coded team timeline of bookings, payments, notes, status changes and uploads, with type filters and load more.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "avatar",
    "button"
  ],
  "files": [
    {
      "path": "registry/blocks/notifications/activity-feed.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ArrowRightLeft, CalendarPlus, ChevronDown, CreditCard, FileUp, Loader2, StickyNote } from \"lucide-react\"\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\"\nimport { Button } from \"@/components/ui/button\"\nimport { cn } from \"@/lib/utils\"\n\ntype EventType = \"booking\" | \"payment\" | \"note\" | \"status\" | \"file\"\n\ntype Activity = {\n  id: number\n  type: EventType\n  /** Minutes before \"now\". Converted to a real timestamp after mount. */\n  ago: number\n  who: string\n  initials: string\n  title: React.ReactNode\n  detail?: string\n  amount?: string\n  from?: string\n  to?: string\n  file?: { name: string; size: string }\n}\n\nconst TYPES: Record<EventType, { label: string; icon: React.ElementType; dot: string; chip: string }> = {\n  booking: { label: \"Bookings\", icon: CalendarPlus, dot: \"bg-violet-500 text-white\", chip: \"data-[on=true]:border-violet-500/40 data-[on=true]:bg-violet-500/10 data-[on=true]:text-violet-700 dark:data-[on=true]:text-violet-300\" },\n  payment: { label: \"Payments\", icon: CreditCard, dot: \"bg-emerald-500 text-white\", chip: \"data-[on=true]:border-emerald-500/40 data-[on=true]:bg-emerald-500/10 data-[on=true]:text-emerald-700 dark:data-[on=true]:text-emerald-300\" },\n  note: { label: \"Notes\", icon: StickyNote, dot: \"bg-amber-400 text-amber-950\", chip: \"data-[on=true]:border-amber-500/40 data-[on=true]:bg-amber-500/10 data-[on=true]:text-amber-700 dark:data-[on=true]:text-amber-300\" },\n  status: { label: \"Status\", icon: ArrowRightLeft, dot: \"bg-sky-500 text-white\", chip: \"data-[on=true]:border-sky-500/40 data-[on=true]:bg-sky-500/10 data-[on=true]:text-sky-700 dark:data-[on=true]:text-sky-300\" },\n  file: { label: \"Files\", icon: FileUp, dot: \"bg-rose-500 text-white\", chip: \"data-[on=true]:border-rose-500/40 data-[on=true]:bg-rose-500/10 data-[on=true]:text-rose-700 dark:data-[on=true]:text-rose-300\" },\n}\n\nconst RECENT: Activity[] = [\n  { id: 1, type: \"booking\", ago: 3, who: \"Sofia Martinez\", initials: \"SM\", title: <>booked <b>Hannah Lee</b> for Balayage</>, detail: \"Sat, Nov 8 · 10:45 AM · 2h 30m with Sofia\" },\n  { id: 2, type: \"payment\", ago: 11, who: \"Stripe\", initials: \"ST\", title: <>received a payment from <b>Ethan Wilson</b></>, amount: \"$85.00\", detail: \"Visa •••• 4242 · Classic cut + beard\" },\n  { id: 3, type: \"status\", ago: 26, who: \"Liam Brooks\", initials: \"LB\", title: <>updated <b>Ava Johnson</b>&apos;s appointment</>, from: \"Pending\", to: \"Confirmed\" },\n  { id: 4, type: \"note\", ago: 48, who: \"Olivia Chen\", initials: \"OC\", title: <>added a note to <b>Mia Wong</b></>, detail: \"Prefers almond shape, no cuticle oil — sensitive skin. Offer the hypoallergenic top coat.\" },\n  { id: 5, type: \"file\", ago: 95, who: \"Jonas Weber\", initials: \"JW\", title: <>uploaded an intake form</>, file: { name: \"noah-patel-consent.pdf\", size: \"182 KB\" } },\n  { id: 6, type: \"booking\", ago: 140, who: \"Online booking\", initials: \"OB\", title: <><b>Lucas Rossi</b> booked a Deep tissue massage</>, detail: \"Mon, Nov 10 · 5:30 PM · 60 min with Jonas\" },\n  { id: 7, type: \"payment\", ago: 210, who: \"Front desk\", initials: \"FD\", title: <>sold a gift card to <b>Sophie Scott</b></>, amount: \"$150.00\", detail: \"Cash · valid 12 months\" },\n  { id: 8, type: \"status\", ago: 330, who: \"Automation\", initials: \"AU\", title: <>marked <b>Ruby Hall</b> as no-show</>, from: \"Confirmed\", to: \"No-show\" },\n]\n\nconst OLDER: Activity[][] = [\n  [\n    { id: 9, type: \"note\", ago: 26 * 60, who: \"Sofia Martinez\", initials: \"SM\", title: <>pinned a note on <b>Ethan Wilson</b></>, detail: \"Always books the last slot on Fridays — offer recurring.\" },\n    { id: 10, type: \"file\", ago: 27 * 60, who: \"Olivia Chen\", initials: \"OC\", title: <>uploaded before/after photos</>, file: { name: \"mia-wong-nails-03.jpg\", size: \"2.4 MB\" } },\n    { id: 11, type: \"payment\", ago: 29 * 60, who: \"Stripe\", initials: \"ST\", title: <>refunded a deposit to <b>Ruby Hall</b></>, amount: \"−$40.00\", detail: \"Cancelled more than 24h before\" },\n    { id: 12, type: \"booking\", ago: 31 * 60, who: \"Liam Brooks\", initials: \"LB\", title: <>rebooked <b>Noah Patel</b> every 4 weeks</>, detail: \"6 appointments created through March\" },\n  ],\n  [\n    { id: 13, type: \"status\", ago: 50 * 60, who: \"Jonas Weber\", initials: \"JW\", title: <>moved <b>Room 2</b> to maintenance</>, from: \"Available\", to: \"Blocked\" },\n    { id: 14, type: \"file\", ago: 53 * 60, who: \"Sofia Martinez\", initials: \"SM\", title: <>shared the November price list</>, file: { name: \"northside-prices-nov.pdf\", size: \"640 KB\" } },\n    { id: 15, type: \"payment\", ago: 70 * 60, who: \"Payouts\", initials: \"PO\", title: <>sent a payout to your bank</>, amount: \"$2,418.60\", detail: \"Arrives in 1–2 business days\" },\n  ],\n]\n\nconst ACTOR_COLOR: Record<string, string> = { SM: \"bg-violet-500\", LB: \"bg-sky-500\", OC: \"bg-pink-500\", JW: \"bg-teal-500\" }\n\nexport default function ActivityFeed() {\n  const [base, setBase] = React.useState<number | null>(null)\n  const [now, setNow] = React.useState<number | null>(null)\n  const [items, setItems] = React.useState(RECENT)\n  const [page, setPage] = React.useState(0)\n  const [loading, setLoading] = React.useState(false)\n  const [active, setActive] = React.useState<EventType[]>([])\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n  React.useEffect(() => {\n    const t = Date.now()\n    setBase(t)\n    setNow(t)\n    const id = setInterval(() => setNow(Date.now()), 30_000)\n    return () => {\n      clearInterval(id)\n      if (timer.current) clearTimeout(timer.current)\n    }\n  }, [])\n\n  const toggle = (t: EventType) => setActive((a) => (a.includes(t) ? a.filter((x) => x !== t) : [...a, t]))\n  const shown = items.filter((i) => active.length === 0 || active.includes(i.type))\n  const hasMore = page < OLDER.length\n\n  const loadMore = () => {\n    setLoading(true)\n    timer.current = setTimeout(() => {\n      setItems((l) => [...l, ...(OLDER[page] ?? [])])\n      setPage((p) => p + 1)\n      setLoading(false)\n    }, 700)\n  }\n\n  const relative = (ago: number) => {\n    if (now === null || base === null) return \"\"\n    const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: \"auto\" })\n    const diff = (base - ago * 60_000 - now) / 60_000\n    if (Math.abs(diff) < 1) return \"just now\"\n    if (Math.abs(diff) < 60) return rtf.format(Math.round(diff), \"minute\")\n    if (Math.abs(diff) < 60 * 24) return rtf.format(Math.round(diff / 60), \"hour\")\n    return rtf.format(Math.round(diff / 60 / 24), \"day\")\n  }\n  const absolute = (ago: number) => (base === null ? \"\" : new Intl.DateTimeFormat(undefined, { weekday: \"short\", hour: \"numeric\", minute: \"2-digit\" }).format(new Date(base - ago * 60_000)))\n\n  const counts = (Object.keys(TYPES) as EventType[]).map((t) => ({ t, n: items.filter((i) => i.type === t).length }))\n  const total = items.length\n\n  return (\n    <div className=\"p-4 md:p-6\">\n      <div className=\"mx-auto grid max-w-4xl gap-6 md:grid-cols-[240px_1fr]\">\n        {/* Summary rail */}\n        <aside className=\"flex flex-col gap-5 md:sticky md:top-6 md:self-start\">\n          <div>\n            <p className=\"text-xs font-semibold tracking-widest text-muted-foreground uppercase\">Team activity</p>\n            <div className=\"mt-1 flex items-baseline gap-2\">\n              <span className=\"text-5xl font-bold tracking-tight tabular-nums\">{total}</span>\n              <span className=\"text-sm text-muted-foreground\">events loaded</span>\n            </div>\n          </div>\n          {/* Stacked distribution bar */}\n          <div>\n            <div className=\"flex h-2.5 overflow-hidden rounded-full bg-muted\">\n              {counts.map(({ t, n }) => (\n                <div key={t} className={cn(\"h-full transition-all duration-500\", TYPES[t].dot.split(\" \")[0], active.length && !active.includes(t) && \"opacity-25\")} style={{ width: `${(n / total) * 100}%` }} />\n              ))}\n            </div>\n            <p className=\"mt-2 text-xs text-muted-foreground\">Share of events by type</p>\n          </div>\n          <div className=\"flex flex-wrap gap-2\" role=\"group\" aria-label=\"Filter by event type\">\n            {counts.map(({ t, n }) => {\n              const T = TYPES[t]\n              const on = active.includes(t)\n              return (\n                <button\n                  key={t}\n                  type=\"button\"\n                  data-on={on}\n                  aria-pressed={on}\n                  onClick={() => toggle(t)}\n                  className={cn(\"inline-flex items-center gap-1.5 rounded-full border bg-background px-3 py-1 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground\", T.chip)}\n                >\n                  <T.icon className=\"size-3.5\" /> {T.label}\n                  <span className=\"tabular-nums opacity-70\">{n}</span>\n                </button>\n              )\n            })}\n            {active.length > 0 && (\n              <button type=\"button\" onClick={() => setActive([])} className=\"px-1 text-sm font-medium text-primary underline-offset-4 hover:underline\">\n                Clear\n              </button>\n            )}\n          </div>\n        </aside>\n\n        {/* Timeline */}\n        <div className=\"min-w-0\">\n          {now === null || base === null ? (\n            <div className=\"flex flex-col gap-4\">\n              {[0, 1, 2, 3, 4].map((i) => <div key={i} className=\"h-[76px] animate-pulse rounded-xl bg-muted\" />)}\n            </div>\n          ) : (\n            <ol className=\"relative\">\n              <span className=\"absolute top-2 bottom-2 left-[17px] w-px bg-gradient-to-b from-border via-border to-transparent\" aria-hidden />\n              {shown.length === 0 && (\n                <li className=\"ml-12 rounded-xl border border-dashed p-8 text-center text-sm text-muted-foreground\">No {active.map((t) => TYPES[t].label.toLowerCase()).join(\" or \")} in this period. Load older activity or clear the filter.</li>\n              )}\n              {shown.map((a, idx) => {\n                const T = TYPES[a.type]\n                const dayKey = (x: Activity) => new Date(base - x.ago * 60_000).toDateString()\n                const dayBreak = idx === 0 ? dayKey(a) !== new Date(now).toDateString() : dayKey(a) !== dayKey(shown[idx - 1]!)\n                return (\n                  <React.Fragment key={a.id}>\n                    {dayBreak && (\n                      <li className=\"relative mb-4 ml-12 text-xs font-semibold tracking-wide text-muted-foreground uppercase\">\n                        {new Intl.DateTimeFormat(undefined, { weekday: \"long\", month: \"short\", day: \"numeric\" }).format(new Date(base - a.ago * 60_000))}\n                      </li>\n                    )}\n                    <li className=\"relative flex gap-4 pb-6 animate-in fade-in-0 slide-in-from-bottom-1\">\n                      <span className={cn(\"relative z-10 flex size-9 shrink-0 items-center justify-center rounded-full ring-4 ring-background\", T.dot)}>\n                        <T.icon className=\"size-4\" />\n                      </span>\n                      <div className=\"min-w-0 flex-1 pt-1\">\n                        <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n                          <Avatar className=\"size-5\">\n                            <AvatarFallback className={cn(\"text-[9px] font-semibold\", ACTOR_COLOR[a.initials] ? cn(ACTOR_COLOR[a.initials], \"text-white\") : \"\")}>{a.initials}</AvatarFallback>\n                          </Avatar>\n                          <p className=\"min-w-0 text-sm text-muted-foreground [&_b]:font-semibold [&_b]:text-foreground\">\n                            <span className=\"font-semibold text-foreground\">{a.who}</span> {a.title}\n                          </p>\n                          <time className=\"ml-auto shrink-0 text-xs text-muted-foreground tabular-nums\" title={absolute(a.ago)}>{relative(a.ago)}</time>\n                        </div>\n                        <Detail a={a} />\n                      </div>\n                    </li>\n                  </React.Fragment>\n                )\n              })}\n            </ol>\n          )}\n\n          <div className=\"ml-12\">\n            {hasMore ? (\n              <Button variant=\"outline\" className=\"w-full\" onClick={loadMore} disabled={loading || now === null}>\n                {loading ? <Loader2 className=\"animate-spin\" /> : <ChevronDown />}\n                {loading ? \"Loading older activity…\" : \"Load more\"}\n              </Button>\n            ) : (\n              <p className=\"py-2 text-center text-xs text-muted-foreground\">You&apos;ve reached the beginning of this week&apos;s activity.</p>\n            )}\n          </div>\n        </div>\n      </div>\n    </div>\n  )\n}\n\nfunction Detail({ a }: { a: Activity }) {\n  if (a.type === \"payment\")\n    return (\n      <div className=\"mt-2 flex items-center justify-between gap-3 rounded-xl border bg-card px-3 py-2.5\">\n        <span className=\"truncate text-xs text-muted-foreground\">{a.detail}</span>\n        <span className={cn(\"shrink-0 text-base font-semibold tabular-nums\", a.amount?.startsWith(\"−\") ? \"text-rose-600 dark:text-rose-400\" : \"text-emerald-600 dark:text-emerald-400\")}>{a.amount}</span>\n      </div>\n    )\n  if (a.type === \"status\")\n    return (\n      <div className=\"mt-2 flex items-center gap-2 text-xs\">\n        <span className=\"rounded-md border bg-muted px-2 py-0.5 text-muted-foreground line-through decoration-muted-foreground/50\">{a.from}</span>\n        <ArrowRightLeft className=\"size-3 text-muted-foreground\" />\n        <span className=\"rounded-md border border-sky-500/30 bg-sky-500/10 px-2 py-0.5 font-medium text-sky-700 dark:text-sky-300\">{a.to}</span>\n      </div>\n    )\n  if (a.type === \"note\")\n    return <p className=\"mt-2 rounded-xl border-l-2 border-amber-400 bg-amber-500/5 px-3 py-2 text-sm text-foreground/80 italic dark:bg-amber-500/10\">“{a.detail}”</p>\n  if (a.type === \"file\" && a.file)\n    return (\n      <div className=\"mt-2 inline-flex max-w-full items-center gap-3 rounded-xl border bg-card py-2 pr-4 pl-2\">\n        <span className=\"flex h-9 w-8 shrink-0 items-end justify-center rounded-md bg-rose-500/10 pb-1 text-[9px] font-bold text-rose-700 uppercase dark:text-rose-300\">{a.file.name.split(\".\").pop()}</span>\n        <span className=\"min-w-0\">\n          <span className=\"block truncate text-sm font-medium\">{a.file.name}</span>\n          <span className=\"block text-xs text-muted-foreground\">{a.file.size}</span>\n        </span>\n      </div>\n    )\n  return a.detail ? <p className=\"mt-1 text-sm text-muted-foreground\">{a.detail}</p> : null\n}\n",
      "type": "registry:component",
      "target": "components/goodui/activity-feed.tsx"
    }
  ],
  "categories": [
    "notifications"
  ],
  "type": "registry:block"
}