"use client" import { Logo } from "@ui/assets/Logo" import { Avatar, AvatarFallback, AvatarImage } from "@ui/components/avatar" import { useAuth } from "@lib/auth-context" import { motion } from "motion/react" import NovaOrb from "@/components/nova/nova-orb" import { useState, useEffect, useRef } from "react" import { cn } from "@lib/utils" import { dmSansClassName } from "@/lib/fonts" import Account from "@/components/new/settings/account" import Integrations from "@/components/new/settings/integrations" import ConnectionsMCP from "@/components/new/settings/connections-mcp" import Support from "@/components/new/settings/support" import { useRouter } from "next/navigation" import { useIsMobile } from "@hooks/use-mobile" import { analytics } from "@/lib/analytics" const TABS = ["account", "integrations", "connections", "support"] as const type SettingsTab = (typeof TABS)[number] type NavItem = { id: SettingsTab label: string description: string icon: React.ReactNode } const NAV_ITEMS: NavItem[] = [ { id: "account", label: "Account & Billing", description: "Manage your profile, plan, usage and payments", icon: ( ), }, { id: "integrations", label: "Integrations", description: "Save, sync and search memories across tools", icon: ( ), }, { id: "connections", label: "Connections & MCP", description: "Sync with Google Drive, Notion, OneDrive and MCP client", icon: ( ), }, { id: "support", label: "Support & Help", description: "Find answers or share feedback. We're here to help.", icon: ( ), }, ] function parseHashToTab(hash: string): SettingsTab { const cleaned = hash.replace("#", "").toLowerCase() return TABS.includes(cleaned as SettingsTab) ? (cleaned as SettingsTab) : "account" } export function UserSupermemory({ name }: { name: string }) { return (

{name.split(" ")[0]}'s

supermemory

) } export default function SettingsPage() { const { user } = useAuth() const [activeTab, setActiveTab] = useState("account") const hasInitialized = useRef(false) const router = useRouter() const isMobile = useIsMobile() useEffect(() => { if (hasInitialized.current) return hasInitialized.current = true const hash = window.location.hash const tab = parseHashToTab(hash) setActiveTab(tab) analytics.settingsTabChanged({ tab }) // If no hash or invalid hash, push #account if (!hash || !TABS.includes(hash.replace("#", "") as SettingsTab)) { window.history.pushState(null, "", "#account") } }, []) useEffect(() => { const handleHashChange = () => { const tab = parseHashToTab(window.location.hash) setActiveTab(tab) analytics.settingsTabChanged({ tab }) } window.addEventListener("hashchange", handleHashChange) return () => window.removeEventListener("hashchange", handleHashChange) }, []) return (
{user && ( {user?.name?.charAt(0)} )}
{!isMobile && ( )}
{activeTab === "account" && } {activeTab === "integrations" && } {activeTab === "connections" && } {activeTab === "support" && }
) }