"use client"; import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { ChevronDownIcon, SettingsIcon, UserRoundIcon, MessageCircle } from "lucide-react"; import { authClient } from "@/lib/auth/client"; import { safeAuthReturnPath } from "@/lib/auth/return-path"; import { SignOutButton } from "@/components/auth/sign-out-button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Separator } from "@/components/ui/separator" export function PublicAccountMenu() { const pathname = usePathname(); const { data, isPending } = authClient.useSession(); const [openedPath, setOpenedPath] = useState(null); const returnPath = safeAuthReturnPath(openedPath ?? pathname); const suffix = returnPath === "/" ? "" : `?next=${encodeURIComponent(returnPath)}`; const accountLabel = data?.user ? data.user.name.trim() || "โปรไฟล์" : "บัญชี"; return { if (open) setOpenedPath(window.location.pathname + window.location.search + window.location.hash); }}> }> {accountLabel} {data?.user ? <> }> }> : <> }>เข้าสู่ระบบ }>สมัครสมาชิก } ; }