fix: sync notification and shop dashboard state

This commit is contained in:
zetaloop
2026-02-22 06:43:24 +08:00
parent 02269dd9c3
commit 5f25043923
6 changed files with 152 additions and 74 deletions
+5 -2
View File
@@ -29,10 +29,11 @@ import {
} from "@/components/ui/dropdown-menu"
import { Input } from "@/components/ui/input"
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
import { currentUser, mockNotifications, mockShops } from "@/lib/mock"
import { currentUser, mockShops } from "@/lib/mock"
import type { UserRole } from "@/lib/types"
import { cn } from "@/lib/utils"
import { useAuthStore } from "@/store/auth"
import { useNotificationStore } from "@/store/notifications"
const roleLabels: Record<UserRole, string> = {
consumer: "消费者",
@@ -72,7 +73,9 @@ export function Header() {
setMobileOpen(false)
}
const unreadCount = mockNotifications.filter((n) => !n.read).length
const unreadCount = useNotificationStore(
(state) => state.notifications.filter((notification) => !notification.read).length,
)
const handleSearch = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()