"use client"; import { useState } from "react"; import { useNotifications } from "@/hooks/useNotifications"; import { useActiveDownloads } from "@/hooks/useNotifications"; import { NotificationsTab } from "@/components/activity/NotificationsTab"; import { ActiveDownloadsTab } from "@/components/activity/ActiveDownloadsTab"; import { HistoryTab } from "@/components/activity/HistoryTab"; import { Bell, Download, History, ChevronLeft, ChevronRight, X, } from "lucide-react"; import { cn } from "@/utils/cn"; import { useIsMobile, useIsTablet } from "@/hooks/useMediaQuery"; type ActivityTab = "notifications" | "active" | "history"; const TABS: { id: ActivityTab; label: string; icon: React.ElementType }[] = [ { id: "notifications", label: "Notifications", icon: Bell }, { id: "active", label: "Active", icon: Download }, { id: "history", label: "History", icon: History }, ]; interface ActivityPanelProps { isOpen: boolean; onToggle: () => void; activeTab?: ActivityTab; onTabChange?: (tab: ActivityTab) => void; } export function ActivityPanel({ isOpen, onToggle, activeTab, onTabChange, }: ActivityPanelProps) { const [internalActiveTab, setInternalActiveTab] = useState("notifications"); const resolvedActiveTab = activeTab ?? internalActiveTab; const setResolvedActiveTab = onTabChange ?? setInternalActiveTab; const { unreadCount } = useNotifications(); const { downloads: activeDownloads } = useActiveDownloads(); const isMobile = useIsMobile(); const isTablet = useIsTablet(); const isMobileOrTablet = isMobile || isTablet; // Badge counts const notificationBadge = unreadCount > 0 ? unreadCount : null; const activeBadge = activeDownloads.length > 0 ? activeDownloads.length : null; const hasActivity = unreadCount > 0 || activeDownloads.length > 0; // Mobile/Tablet: Full-screen overlay if (isMobileOrTablet) { if (!isOpen) return null; return ( <> {/* Backdrop */}
{/* Panel - slides in from right */}
{/* Header */}

Activity

{/* Tabs */}
{TABS.map((tab) => { const Icon = tab.icon; const badge = tab.id === "notifications" ? notificationBadge : tab.id === "active" ? activeBadge : null; return ( ); })}
{/* Tab Content */}
{resolvedActiveTab === "notifications" && ( )} {resolvedActiveTab === "active" && ( )} {resolvedActiveTab === "history" && }
); } // Desktop: Side panel return (
{/* Collapsed state overlay */} {!isOpen && (
{/* Activity badge */} {hasActivity && ( )}
)} {/* Expanded content - only visible when open */}
{/* Header */}

Activity

{/* Tabs */}
{TABS.map((tab) => { const Icon = tab.icon; const badge = tab.id === "notifications" ? notificationBadge : tab.id === "active" ? activeBadge : null; return ( ); })}
{/* Tab Content */}
{resolvedActiveTab === "notifications" && ( )} {resolvedActiveTab === "active" && } {resolvedActiveTab === "history" && }
); } // Toggle button for TopBar export function ActivityPanelToggle() { const { unreadCount } = useNotifications(); const { downloads: activeDownloads } = useActiveDownloads(); const isMobile = useIsMobile(); const isTablet = useIsTablet(); if (isMobile || isTablet) { return null; } const hasActivity = unreadCount > 0 || activeDownloads.length > 0; return ( ); }