"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 ? (
<>
Expanded memory with connections and more
Unlimited Memories
{memoriesUsed}/
∞
{/* Free plan card */}
{/* Pro plan card - highlighted */}
{/* Header with ACTIVE badge */}
{/* Inset highlight */}
>
) : (
<>
Free Plan
You are on basic plan
Memories
{memoriesUsed}/{memoriesLimit}
{/* Progress bar */}
{/* Free plan card */}
{/* Pro plan card */}
{/* Header with badge */}
{/* Inset highlight */}
>
)}
Delete Account
Permanently delete all your data and cancel any active
subscriptions
)
}