"use client"; import Link from "next/link"; import { useEffect } from "react"; import { Bell, CheckCheck, Trash2 } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { EmptyState } from "@/components/layout/empty-state"; import { PageHeader } from "@/components/layout/page-header"; import { ActiveJobsPanel } from "@/components/layout/active-jobs-panel"; import { useJobs } from "@/components/layout/jobs-provider"; import { useNotifications } from "@/lib/notifications/use-notifications"; import type { NotificationType } from "@/lib/notifications/store"; import { cn } from "@/lib/utils"; const typeStyle: Record = { success: "border-success-border bg-success-bg", error: "border-danger-border bg-danger-bg", warning: "border-warning-border bg-warning-bg", info: "border-border bg-muted", }; const typeLabel: Record = { success: "成功", error: "失敗", warning: "提醒", info: "訊息", }; export default function NotificationsPage() { const { activeJobs } = useJobs(); const { notifications, unreadCount, markRead, markAllRead, clearAll, removeNotification } = useNotifications(); useEffect(() => { markAllRead(); }, [markAllRead]); return (
0 ? (
{unreadCount > 0 && ( )}
) : undefined } /> {notifications.length === 0 && activeJobs.length === 0 ? ( ) : notifications.length === 0 ? null : (

通知紀錄

{notifications.map((item) => (
{!item.read && ( )}

{item.title}

{typeLabel[item.type]}
{item.message && (

{item.message}

)}

{new Date(item.createdAt).toLocaleString("zh-TW")}

{item.href && ( markRead(item.id)} > 前往查看 )}
{!item.read && ( )}
))}
)}
); }