Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -1,6 +1,7 @@
import { useState } from "react";
import { useParams } from "react-router";
import { useFetcher, useParams } from "react-router";
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
import { useRootData } from "~/utils/data/useRootData";
import AddFeedbackButton from "./buttons/AddFeedbackButton";
import ChatSupportButton from "./buttons/ChatSupportButton";
import CurrentSubscriptionButton from "./buttons/CurrentSubscriptionButton";
@@ -36,16 +37,40 @@ export default function NavBar({
children?: React.ReactNode;
}) {
const appOrAdminData = useAppOrAdminData();
const rootData = useRootData();
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 canReadPlatformLeads = appOrAdminData.permissions?.some(
(permission) => permission === "admin.leads.read_own" || permission === "admin.leads.read_all"
);
const isPlatformLeadAdmin = layout === "admin" && canReadPlatformLeads;
const notificationsPath = isPlatformLeadAdmin
? adminPath("leads", { mode: "host-aware" })
: layout === "admin"
? adminPath("notifications", { mode: "host-aware" })
: params.tenant
? appPath({ tenantSlug: params.tenant, path: "notifications", mode: "host-aware" })
: "/notifications";
const isTenantApp = layout === "app" && Boolean(params.tenant);
const streamPath = isTenantApp && params.tenant ? appPath({ tenantSlug: params.tenant, path: "notifications/stream", mode: "host-aware" }) : null;
const streamPath = isPlatformLeadAdmin
? adminPath("leads/notifications-stream", { mode: "host-aware" })
: isTenantApp && params.tenant
? appPath({ tenantSlug: params.tenant, path: "notifications/stream", mode: "host-aware" })
: null;
const notificationsStream = useNotificationsStream(streamPath, []);
const notificationReadFetcher = useFetcher();
const [notificationsDrawerOpen, setNotificationsDrawerOpen] = useState(false);
const hasNotificationDrawer = isTenantApp || isPlatformLeadAdmin;
function openNotificationsDrawer() {
setNotificationsDrawerOpen(true);
if (!isPlatformLeadAdmin || !streamPath) return;
const unreadIds = notificationsStream.items.filter((item) => !item.isRead).map((item) => item.id);
if (unreadIds.length === 0) return;
const form = new FormData();
if (rootData.csrf) form.set("csrf", rootData.csrf);
for (const deliveryId of unreadIds) form.append("deliveryId", deliveryId);
void notificationReadFetcher.submit(form, { method: "post", action: streamPath });
}
return (
<div className="flex flex-1 justify-between space-x-2">
<div className="flex flex-1 items-center">{title && <div className="font-extrabold">{title}</div>}</div>
@@ -53,7 +78,7 @@ export default function NavBar({
{/* {layout === "app" && (
<CreditsRemaining
feature={appOrAdminData.featureSyncs}
redirectTo={appOrAdminData.currentTenant ? `/${appOrAdminData.currentTenant.slug}/settings/subscription` : "/settings/subscription"}
redirectTo={appOrAdminData.currentTenant ? `/${appOrAdminData.currentTenant.slug}/settings/billing` : "/settings/billing"}
/>
)} */}
{buttons.onboarding && appOrAdminData?.onboardingSession && (
@@ -64,11 +89,11 @@ export default function NavBar({
{buttons.notifications && appOrAdminData?.user && (
<NotificationsButton
to={notificationsPath}
unseenCount={isTenantApp ? notificationsStream.unreadCount : undefined}
onOpen={isTenantApp ? () => setNotificationsDrawerOpen(true) : undefined}
unseenCount={hasNotificationDrawer ? notificationsStream.unreadCount : undefined}
onOpen={hasNotificationDrawer ? openNotificationsDrawer : undefined}
/>
)}
{isTenantApp && (
{hasNotificationDrawer && (
<NotificationsDrawer
open={notificationsDrawerOpen}
items={notificationsStream.items}