"use client"; import { useState } from "react"; import { Bell } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { useNotifications } from "@/hooks/use-notifications"; import { useAtomValue } from "jotai"; import { currentUserAtom } from "@/atoms/user/user-query.atoms"; import { NotificationPopup } from "./NotificationPopup"; import { cn } from "@/lib/utils"; import { useParams } from "next/navigation"; export function NotificationButton() { const [open, setOpen] = useState(false); const { data: user } = useAtomValue(currentUserAtom); const params = useParams(); const userId = user?.id ? String(user.id) : null; // Get searchSpaceId from URL params - the component is rendered within /dashboard/[search_space_id]/ const searchSpaceId = params?.search_space_id ? Number(params.search_space_id) : null; const { notifications, unreadCount, loading, markAsRead, markAllAsRead } = useNotifications( userId, searchSpaceId ); return ( Notifications setOpen(false)} /> ); }