"use client"; import { ArrowLeft, Check, ChevronRight, Copy, Key, type LucideIcon, Menu, Shield, X, } from "lucide-react"; import { AnimatePresence, motion } from "motion/react"; import { useRouter } from "next/navigation"; import { useTranslations } from "next-intl"; import { useCallback, useState } from "react"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { useApiKey } from "@/hooks/use-api-key"; import { cn } from "@/lib/utils"; interface SettingsNavItem { id: string; label: string; description: string; icon: LucideIcon; } function UserSettingsSidebar({ activeSection, onSectionChange, onBackToApp, isOpen, onClose, navItems, }: { activeSection: string; onSectionChange: (section: string) => void; onBackToApp: () => void; isOpen: boolean; onClose: () => void; navItems: SettingsNavItem[]; }) { const t = useTranslations("userSettings"); const handleNavClick = (sectionId: string) => { onSectionChange(sectionId); onClose(); }; return ( <> {isOpen && ( )} > ); } function ApiKeyContent({ onMenuClick }: { onMenuClick: () => void }) { const t = useTranslations("userSettings"); const { apiKey, isLoading, copied, copyToClipboard } = useApiKey(); return ( {t("api_key_title")} {t("api_key_description")} {t("api_key_warning_title")} {t("api_key_warning_description")} {t("your_api_key")} {isLoading ? ( ) : apiKey ? ( {apiKey} {copied ? : } {copied ? t("copied") : t("copy")} ) : ( {t("no_api_key")} )} {t("usage_title")} {t("usage_description")} Authorization: Bearer {apiKey || "YOUR_API_KEY"} ); } export default function UserSettingsPage() { const t = useTranslations("userSettings"); const router = useRouter(); const [activeSection, setActiveSection] = useState("api-key"); const [isSidebarOpen, setIsSidebarOpen] = useState(false); const navItems: SettingsNavItem[] = [ { id: "api-key", label: t("api_key_nav_label"), description: t("api_key_nav_description"), icon: Key, }, ]; const handleBackToApp = useCallback(() => { router.back(); }, [router]); return ( setIsSidebarOpen(false)} navItems={navItems} /> {activeSection === "api-key" && ( setIsSidebarOpen(true)} /> )} ); }
{t("api_key_description")}
{t("no_api_key")}
{t("usage_description")}
Authorization: Bearer {apiKey || "YOUR_API_KEY"}