"use client" import { dmSans125ClassName } from "@/lib/fonts" import { cn } from "@lib/utils" import { useAuth } from "@lib/auth-context" import { Avatar, AvatarFallback, AvatarImage } from "@ui/components/avatar" import { useMemoriesUsage } from "@/hooks/use-memories-usage" import { Dialog, DialogContent, DialogTrigger, DialogClose, } from "@ui/components/dialog" import { useCustomer } from "autumn-js/react" import { Check, X, Trash2, LoaderIcon, Settings } from "lucide-react" import { useState } from "react" function SectionTitle({ children }: { children: React.ReactNode }) { return (

{children}

) } function SettingsCard({ children }: { children: React.ReactNode }) { return (
{children}
) } function PlanFeatureRow({ icon, text, variant = "muted", }: { icon: "check" | "x" text: string variant?: "muted" | "highlight" }) { return (
{icon === "check" ? ( ) : ( )} {text}
) } export default function Account() { const { user, org } = useAuth() const autumn = useCustomer() const [isUpgrading, setIsUpgrading] = useState(false) const [deleteConfirmText, setDeleteConfirmText] = useState("") const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false) const { memoriesUsed, memoriesLimit, hasProProduct, isLoading: isCheckingStatus, usagePercent, } = useMemoriesUsage(autumn) // Handlers const handleUpgrade = async () => { setIsUpgrading(true) try { await autumn.attach({ productId: "consumer_pro", successUrl: "https://app.supermemory.ai/new/settings#account", }) window.location.reload() } catch (error) { console.error(error) setIsUpgrading(false) } } const handleDeleteAccount = () => { if (deleteConfirmText !== "DELETE") return // TODO: Implement account deletion API call console.log("Delete account requested") setIsDeleteDialogOpen(false) setDeleteConfirmText("") } const isDeleteEnabled = deleteConfirmText === "DELETE" // Format member since date const memberSince = user?.createdAt ? new Date(user.createdAt).toLocaleDateString("en-US", { month: "short", year: "numeric", }) : "—" return (
Profile Details
{/* Avatar + Name/Email */}
{user?.name?.charAt(0) ?? "U"}

{user?.name ?? "—"}

{user?.email ?? "—"}

{/* Organization + Member since */}

Organization

{org?.name ?? "Personal"}

Member since

{memberSince}

Billing & Subscription
{hasProProduct ? ( <>

Pro plan

ACTIVE

Expanded memory with connections and more

Unlimited Memories

{memoriesUsed}/
{/* Free plan card */}

Free plan

{/* Pro plan card - highlighted */}
{/* Header with ACTIVE badge */}

Pro plan

ACTIVE
{/* Inset highlight */}
) : ( <>

Free Plan

You are on basic plan

Memories

{memoriesUsed}/{memoriesLimit}

{/* Progress bar */}
{/* Free plan card */}

Free plan

{/* Pro plan card */}
{/* Header with badge */}

Pro plan

RECOMMENDED
{/* Inset highlight */}
)}
Delete Account

Permanently delete all your data and cancel any active subscriptions

{ setIsDeleteDialogOpen(open) if (!open) setDeleteConfirmText("") }} >
{/* Header */}

Delete account?

This will permanently delete your memories, conversations, settings and cancel any active subscriptions.

{/* Confirmation input */}

Type DELETE to confirm:

setDeleteConfirmText(e.target.value)} placeholder="DELETE" className={cn( "w-full px-4 py-3 bg-transparent", "text-[#FAFAFA] placeholder:text-[#737373]", "text-[14px] tracking-[-0.14px]", "outline-none", dmSans125ClassName(), )} />
{/* Footer */}
{/* Modal inset highlight */}
) }