import { useNotifications } from "@/hooks/useNotifications"; import { Loader2, BellOff, Trash2, Send, Monitor } from "lucide-react"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; import { Button } from "@/components/ui/button"; import { showToast } from "@/lib/toast"; import { formatDistanceToNow } from "date-fns"; export function NotificationSettings() { const { isSupported, isAvailable, permission, isEnabled, preferences, subscriptions, isLoadingSubscriptions, enable, disable, updateEventPreference, removeDevice, sendTest, isSubscribing, isTesting, } = useNotifications(); if (!isSupported) { return (
Push notifications are not supported in this browser.
Push notifications are not configured on the server. Set VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY environment variables to enable.
Notification permission was denied. Please enable notifications in your browser settings for this site.
Receive notifications when the app is in the background
When the agent needs approval to proceed
When the agent has a question for you
When a session encounters an error
When a session finishes processing
No devices registered for push notifications.
) : ({sub.deviceName ?? (sub.endpoint.length > 60 ? sub.endpoint.slice(0, 60) + "..." : sub.endpoint)}
{sub.lastUsedAt ? `Last used ${formatDistanceToNow(sub.lastUsedAt, { addSuffix: true })}` : `Added ${formatDistanceToNow(sub.createdAt, { addSuffix: true })}`}