"use client"; import { useState } from "react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardTitle, } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Icons } from "@/components/icons"; import { Badge } from "@/components/ui/badge"; // Mock notification data - in a real app, this would come from an API const mockNotifications = [ { id: 1, title: "New task assigned", description: "You have been assigned a new task 'Update documentation'", time: "5 minutes ago", read: false, type: "task", }, { id: 2, title: "Task completed", description: "Your task 'Update documentation' has been completed", time: "1 hour ago", read: false, type: "task", }, { id: 3, title: "Meeting reminder", description: "Team meeting starts in 30 minutes", time: "2 hours ago", read: false, type: "reminder", }, { id: 4, title: "New comment", description: "John commented on your task 'Design homepage'", time: "1 day ago", read: true, type: "comment", }, { id: 5, title: "Task deadline approaching", description: "Task 'Finalize project proposal' is due tomorrow", time: "1 day ago", read: true, type: "reminder", }, { id: 6, title: "System update", description: "The system will be updated tonight at 2 AM", time: "2 days ago", read: true, type: "system", }, ]; export default function NotificationsPage() { const [notifications, setNotifications] = useState(mockNotifications); const [activeTab, setActiveTab] = useState("all"); const [isLoading, setIsLoading] = useState(false); const unreadCount = notifications.filter((n) => !n.read).length; const filteredNotifications = notifications.filter((notification) => { if (activeTab === "all") return true; if (activeTab === "unread") return !notification.read; if (activeTab === "read") return notification.read; return true; }); const markAsRead = (id: number) => { setNotifications( notifications.map((notification) => notification.id === id ? { ...notification, read: true } : notification ) ); toast.success("Notification marked as read"); }; const markAllAsRead = () => { setIsLoading(true); // Simulate API call setTimeout(() => { setNotifications( notifications.map((notification) => ({ ...notification, read: true })) ); setIsLoading(false); toast.success("All notifications marked as read"); }, 500); }; const getNotificationIcon = (type: string) => { switch (type) { case "task": return ; case "reminder": return ; case "comment": return ; case "system": return ; default: return ; } }; return (

Notifications

You have {unreadCount} unread notification{unreadCount !== 1 && "s"}

{unreadCount > 0 && ( )}
All {notifications.length} Unread {unreadCount} Read {notifications.length - unreadCount} {filteredNotifications.length === 0 ? (

No notifications

{activeTab === "unread" ? "You have no unread notifications" : activeTab === "read" ? "You have no read notifications" : "You have no notifications"}

) : (
{filteredNotifications.map((notification) => (
{getNotificationIcon(notification.type)}
{notification.title}
{notification.time} {!notification.read && ( )}
{notification.description}
))}
)}
); }