"use client" import { Bell, CheckCheck, MessageSquare, ShoppingBag } from "lucide-react" import Link from "next/link" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import type { Notification } from "@/lib/types" import { useNotificationStore } from "@/store/notifications" const typeIcons: Record = { order: ShoppingBag, community: MessageSquare, system: Bell, } const typeLabels: Record = { order: "订单", community: "社区", system: "系统", } function NotificationItem({ notification }: { notification: Notification }) { const Icon = typeIcons[notification.type] const content = (
{notification.title} {!notification.read && }

{notification.content}

{new Date(notification.createdAt).toLocaleString("zh-CN")}

{typeLabels[notification.type]}
) return notification.link ? {content} : content } export default function NotificationsPage() { const notifications = useNotificationStore((state) => state.notifications) const markAllAsRead = useNotificationStore((state) => state.markAllAsRead) const unreadCount = notifications.filter((notification) => !notification.read).length const orderNotifs = notifications.filter((notification) => notification.type === "order") const communityNotifs = notifications.filter((notification) => notification.type === "community") const systemNotifs = notifications.filter((notification) => notification.type === "system") return (

通知中心

{unreadCount > 0 && {unreadCount} 条未读}
全部 订单 社区 系统 {notifications.map((notification) => ( ))} {orderNotifs.length === 0 ? ( 暂无订单通知 ) : ( orderNotifs.map((n) => ) )} {communityNotifs.length === 0 ? ( 暂无社区通知 ) : ( communityNotifs.map((n) => ) )} {systemNotifs.length === 0 ? ( 暂无系统通知 ) : ( systemNotifs.map((n) => ) )}
) }