import { useState } from "react"; import { useParams } from "react-router"; import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData"; import AddFeedbackButton from "./buttons/AddFeedbackButton"; import ChatSupportButton from "./buttons/ChatSupportButton"; import CurrentSubscriptionButton from "./buttons/CurrentSubscriptionButton"; import OnboardingButton from "./buttons/OnboardingButton"; import ProfileButton from "./buttons/ProfileButton"; import SearchButton from "./buttons/SearchButton"; import NotificationsButton from "./buttons/NotificationsButton"; import { NotificationsDrawer } from "~/components/screens/notifications/NotificationsDrawer"; import { useNotificationsStream } from "~/components/notifications/useNotificationsStream"; import { adminPath, appPath } from "~/utils/app/CanonicalUrlUtils"; export default function NavBar({ layout, title, buttons, onOpenCommandPalette, onOpenOnboardingModal, children, }: { layout?: string; title?: string; buttons: { mySubscription: boolean; feedback: boolean; chatSupport: boolean; search: boolean; notifications: boolean; onboarding: boolean; userProfile: boolean; }; onOpenCommandPalette: () => void; onOpenOnboardingModal: () => void; children?: React.ReactNode; }) { const appOrAdminData = useAppOrAdminData(); const params = useParams(); const notificationsPath = layout === "admin" ? adminPath("notifications", { mode: "host-aware" }) : params.tenant ? appPath({ tenantSlug: params.tenant, path: "notifications", mode: "host-aware" }) : "/notifications"; // AK-P3 (AD-28): tenant-app bell opens the notifications drawer with a live // SSE unseen count; the stream route is tenant-scoped, so the admin layout // keeps the plain link (documented Dev-Nachzug in the ticket doc). const isTenantApp = layout === "app" && Boolean(params.tenant); const streamPath = isTenantApp && params.tenant ? appPath({ tenantSlug: params.tenant, path: "notifications/stream", mode: "host-aware" }) : null; const notificationsStream = useNotificationsStream(streamPath, []); const [notificationsDrawerOpen, setNotificationsDrawerOpen] = useState(false); return (