import { Button, Popover, Switch } from '@mantine/core'; import { IconBell } from '@/components/icons'; import { useState } from 'react'; import { Link } from 'react-router-dom'; import { CoworkerAvatar } from '../components/CoworkerAvatar'; import { COWORKERS } from '../domain/coworkers'; import { toPath, useBrowserPref, useNotifications, whenWords, type Notice } from './useNotifications'; import './notify.css'; /** The coworker's face, or the Astra mark for the app itself (and anyone not on the team). */ function Face({ name }: { name: string }) { const known = COWORKERS.some((c) => c.name === name); if (!known) return ; return ; } function Item({ n, unread, onPick }: { n: Notice; unread: boolean; onPick: () => void }) { const { path, external } = toPath(n.link); const inner = ( <> {unread && }{n.title} {n.body && {n.body}} {n.coworker} ยท {whenWords(n.created_at)}{unread && , unread} ); return (
  • {external ? {inner} : {inner}}
  • ); } /** The bell in the top bar: what the coworkers want you to know, newest first, with the unread count. */ export function NotificationBell() { const [open, setOpen] = useState(false); const { items, unread, lastSeen, markAllSeen, error } = useNotifications(); const browser = useBrowserPref(); const count = unread.length; const shown = items.slice(0, 15); return (

    Notifications

    {error ?

    Notifications could not be loaded. They will try again shortly.

    : shown.length === 0 ?

    Nothing new. You'll see it here when a coworker needs you.

    : (
      {shown.map((n) => lastSeen} onPick={() => setOpen(false)} />)}
    )} {browser.supported && (
    void browser.setOn(e.currentTarget.checked)} /> {browser.blocked &&

    Your browser blocks notifications for this site. Allow them in the site settings to turn this on.

    }
    )}
    ); }