{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notifications-03",
  "description": "Every notification grouped by day, filtered by unread and mentions, each markable as read or unread or archived.",
  "registryDependencies": [
    "button",
    "tabs",
    "https://www.dashboardblocks.com/r/radix/activity-feed.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/tag.json",
    "https://www.dashboardblocks.com/r/radix/notifications.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/notifications/notifications-03.tsx",
      "content": "'use client'\n\nimport {\n  groupActivityByDay,\n  MarkAllReadButton,\n} from '@/registry/components/dashboardblocks/activity-feed'\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  type AppNotification,\n  NotificationItem,\n  NotificationList,\n} from '@/registry/components/dashboardblocks/notifications'\nimport { Tag } from '@/registry/components/dashboardblocks/tag'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatNumber } from '@/registry/lib/dashboardblocks/format'\nimport { useState } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'\n\ninterface InboxNotification extends AppNotification {\n  mention?: boolean\n}\n\ntype Filter = 'all' | 'unread' | 'mentions'\n\ninterface Notifications3Props extends BlockStateProps {\n  /** Leave out, or pass none, to show the empty state. */\n  notifications?: InboxNotification[]\n  /** Pass a fixed date, so times and day headings render the same on the server and in the browser. */\n  now: Date\n  /** @default 'UTC' */\n  timeZone?: string\n  title: string\n}\n\nconst exampleNow = new Date(Date.UTC(2026, 8, 26, 12))\nconst hoursAgo = (hours: number) => new Date(exampleNow.getTime() - hours * 3_600_000)\n\nconst mentionIcon = (\n  <IconPlaceholder\n    lucide='AtSignIcon'\n    tabler='IconAt'\n    hugeicons='AtIcon'\n    phosphor='AtIcon'\n    remixicon='RiAtLine'\n  />\n)\n\nconst exampleProps: Notifications3Props = {\n  notifications: [\n    {\n      at: hoursAgo(0.2),\n      body: '“@Amara can you check the refund flow before release?”',\n      icon: mentionIcon,\n      id: '1',\n      mention: true,\n      read: false,\n      title: (\n        <>\n          <span className='font-medium'>Priya Nair</span> mentioned you in TCK-381\n        </>\n      ),\n      tone: 'info',\n    },\n    {\n      at: hoursAgo(1.5),\n      icon: (\n        <IconPlaceholder\n          lucide='TriangleAlertIcon'\n          tabler='IconAlertTriangle'\n          hugeicons='Alert02Icon'\n          phosphor='WarningIcon'\n          remixicon='RiErrorWarningLine'\n        />\n      ),\n      id: '2',\n      read: false,\n      title: 'Deploy to production failed on the migration step',\n      tone: 'danger',\n    },\n    {\n      at: hoursAgo(5),\n      icon: (\n        <IconPlaceholder\n          lucide='CircleCheckIcon'\n          tabler='IconCircleCheckFilled'\n          hugeicons='CheckmarkCircle01Icon'\n          phosphor='CheckCircleIcon'\n          remixicon='RiCheckboxCircleFill'\n        />\n      ),\n      id: '3',\n      read: true,\n      title: 'Weekly revenue report is ready',\n      tone: 'success',\n    },\n    {\n      at: hoursAgo(28),\n      body: '“Moved the launch to Thursday, see the updated plan.”',\n      icon: mentionIcon,\n      id: '4',\n      mention: true,\n      read: true,\n      title: (\n        <>\n          <span className='font-medium'>Lena Fischer</span> mentioned you in Launch plan\n        </>\n      ),\n      tone: 'info',\n    },\n    {\n      at: hoursAgo(31),\n      icon: (\n        <IconPlaceholder\n          lucide='CreditCardIcon'\n          tabler='IconCreditCard'\n          hugeicons='CreditCardIcon'\n          phosphor='CreditCardIcon'\n          remixicon='RiBankCardLine'\n        />\n      ),\n      id: '5',\n      read: false,\n      title: 'Invoice INV-2026-09 for $1,240.00 was paid',\n      tone: 'neutral',\n    },\n  ],\n  now: exampleNow,\n  title: 'Inbox',\n}\n\nconst Notifications3 = (props: Notifications3Props) => {\n  const {\n    notifications: loaded = [],\n    now,\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    title,\n  } = props\n  const [readOverrides, setReadOverrides] = useState<ReadonlyMap<string, boolean>>(\n    () => new Map(),\n  )\n  const [archived, setArchived] = useState<ReadonlySet<string>>(() => new Set())\n  const [filter, setFilter] = useState<Filter>('all')\n  const state = getBlockState(status, loaded)\n  const notifications = loaded\n    .filter((notification) => !archived.has(notification.id))\n    .map((notification) => ({\n      ...notification,\n      read: readOverrides.get(notification.id) ?? notification.read,\n    }))\n  const unread = notifications.filter((notification) => !notification.read).length\n  const unreadMentions = notifications.filter(\n    (notification) => !notification.read && notification.mention,\n  ).length\n\n  const filters: { items: InboxNotification[]; label: string; value: Filter }[] = [\n    { items: notifications, label: 'All', value: 'all' },\n    {\n      items: notifications.filter((notification) => !notification.read),\n      label: 'Unread',\n      value: 'unread',\n    },\n    {\n      items: notifications.filter((notification) => notification.mention),\n      label: 'Mentions',\n      value: 'mentions',\n    },\n  ]\n\n  function setRead(ids: string[], read: boolean) {\n    setReadOverrides((current) => {\n      const next = new Map(current)\n      for (const id of ids) next.set(id, read)\n      return next\n    })\n  }\n\n  function archive(id: string) {\n    setArchived((current) => new Set(current).add(id))\n  }\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <section className='@container flex flex-col gap-4'>\n        <header className='flex items-start justify-between gap-3'>\n          <div className='flex min-w-0 flex-col gap-0.5'>\n            <h2 className='font-semibold tracking-tight'>{title}</h2>\n            <BlockReady className='text-sm'>\n              <p className='text-muted-foreground text-sm'>\n                {unread === 0\n                  ? 'You’re all caught up.'\n                  : `${unread} unread${unreadMentions > 0 ? `, ${unreadMentions} mentioning you` : ''}.`}\n              </p>\n            </BlockReady>\n          </div>\n          <MarkAllReadButton\n            variant='outline'\n            disabled={Boolean(state) || unread === 0}\n            onClick={() =>\n              setRead(\n                notifications.map((notification) => notification.id),\n                true,\n              )\n            }\n          />\n        </header>\n        <Tabs value={filter} onValueChange={(value) => setFilter(value as Filter)}>\n          <TabsList>\n            {filters.map((item) => (\n              <TabsTrigger key={item.value} value={item.value}>\n                {item.label}\n                {!state && item.value !== 'all' && item.items.length > 0 && (\n                  <Tag>{formatNumber(item.items.length)}</Tag>\n                )}\n              </TabsTrigger>\n            ))}\n          </TabsList>\n          {filters.map((item) => (\n            <TabsContent key={item.value} value={item.value} className='mt-2'>\n              {state ? (\n                <div className='border-t'>\n                  <BlockStateRows rows={5} />\n                </div>\n              ) : item.items.length === 0 ? (\n                <p className='text-muted-foreground border-t py-12 text-center text-sm'>\n                  {item.value === 'unread'\n                    ? 'You’re all caught up.'\n                    : 'Nothing here yet.'}\n                </p>\n              ) : (\n                groupActivityByDay(item.items, now, timeZone).map((group) => (\n                  <section key={group.key} aria-labelledby={`${item.value}-${group.key}`}>\n                    <h3\n                      id={`${item.value}-${group.key}`}\n                      className='text-muted-foreground border-b pt-4 pb-2 text-xs font-medium'\n                    >\n                      {group.label}\n                    </h3>\n                    <NotificationList label={group.label}>\n                      {group.items.map((notification) => (\n                        <NotificationItem\n                          key={notification.id}\n                          className='px-2'\n                          notification={notification}\n                          now={now}\n                          onOpen={() => setRead([notification.id], true)}\n                          trailing={\n                            <div className='flex gap-1'>\n                              <Button\n                                variant='ghost'\n                                size='icon-sm'\n                                aria-label={\n                                  notification.read ? 'Mark as unread' : 'Mark as read'\n                                }\n                                onClick={() =>\n                                  setRead([notification.id], !notification.read)\n                                }\n                              >\n                                {notification.read ? (\n                                  <IconPlaceholder\n                                    lucide='MailIcon'\n                                    tabler='IconMail'\n                                    hugeicons='MailIcon'\n                                    phosphor='EnvelopeIcon'\n                                    remixicon='RiMailLine'\n                                  />\n                                ) : (\n                                  <IconPlaceholder\n                                    lucide='MailOpenIcon'\n                                    tabler='IconMailOpened'\n                                    hugeicons='MailOpen01Icon'\n                                    phosphor='EnvelopeOpenIcon'\n                                    remixicon='RiMailOpenLine'\n                                  />\n                                )}\n                              </Button>\n                              <Button\n                                variant='ghost'\n                                size='icon-sm'\n                                aria-label='Archive'\n                                onClick={() => archive(notification.id)}\n                              >\n                                <IconPlaceholder\n                                  lucide='ArchiveIcon'\n                                  tabler='IconArchive'\n                                  hugeicons='Archive01Icon'\n                                  phosphor='ArchiveIcon'\n                                  remixicon='RiArchiveLine'\n                                />\n                              </Button>\n                            </div>\n                          }\n                        />\n                      ))}\n                    </NotificationList>\n                  </section>\n                ))\n              )}\n            </TabsContent>\n          ))}\n        </Tabs>\n      </section>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  Notifications3,\n  exampleProps as notifications3ExampleProps,\n  type Notifications3Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/notifications/notifications-03.tsx"
    }
  ],
  "meta": {
    "shows": "Every notification grouped by day, filtered by unread and mentions, each markable as read or unread or archived.",
    "size": "full",
    "usedWith": [
      "notifications-01",
      "notifications-02"
    ],
    "component": "Notifications3",
    "props": "{ notifications?: { mention?: boolean; at: Date; body?: string; href?: string; icon: ReactNode; id: string; read: boolean; title: ReactNode; tone?: \"success\" | \"warning\" | \"danger\" | \"info\" | \"neutral\" | \"accent\" }[]; now: Date; timeZone?: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
