supermemory/apps/web/app/(navigation)/layout.tsx
Prasanna721 11a0abd5c0 feat: migrate to api_pro billing and add credits-based usage display (#729)
Summary

  - Migrate from consumer_pro to api_pro billing product across the app
  - Enable Nova app for all users (remove feature flag)
  - Add credits-based usage tracking with tokens abstraction
2026-02-10 05:53:47 +00:00

72 lines
1.8 KiB
TypeScript

"use client"
import { GraphDialog } from "@/components/graph-dialog"
import { Header } from "@/components/header"
import { AddMemoryView } from "@/components/views/add-memory"
import { usePathname, useRouter } from "next/navigation"
import { useFeatureFlagEnabled } from "posthog-js/react"
import { useEffect, useState } from "react"
export default function NavigationLayout({
children,
}: {
children: React.ReactNode
}) {
const [showAddMemoryView, setShowAddMemoryView] = useState(false)
const pathname = usePathname()
const router = useRouter()
const flagEnabled = true
useEffect(() => {
if (flagEnabled && !pathname.includes("/new")) {
router.replace("/new")
}
}, [flagEnabled, router, pathname])
useEffect(() => {
const handleKeydown = (event: KeyboardEvent) => {
const target = event.target as HTMLElement
const isInputField =
target.tagName === "INPUT" ||
target.tagName === "TEXTAREA" ||
target.isContentEditable ||
target.closest('[contenteditable="true"]')
if (isInputField) return
// add memory shortcut
if (
event.key === "c" &&
!event.ctrlKey &&
!event.metaKey &&
!event.altKey &&
!event.shiftKey
) {
event.preventDefault()
setShowAddMemoryView(true)
}
}
document.addEventListener("keydown", handleKeydown)
return () => {
document.removeEventListener("keydown", handleKeydown)
}
}, [])
return (
<div className="relative h-screen flex flex-col">
<div className="sticky top-0 z-50 bg-background/80 backdrop-blur-md border-b border-white/10">
<Header onAddMemory={() => setShowAddMemoryView(true)} />
</div>
<div className="flex-1">{children}</div>
{showAddMemoryView && (
<AddMemoryView
initialTab="note"
onClose={() => setShowAddMemoryView(false)}
/>
)}
<GraphDialog />
</div>
)
}