add signout logic
This commit is contained in:
parent
7b7bd6f430
commit
e4c4c18749
@ -9,10 +9,16 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { User } from "@/lib/types"
|
||||
import { useClerk } from "@clerk/nextjs"
|
||||
import { LogOut, Pencil } from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
|
||||
export default function UserButton({ userData }: { userData: User }) {
|
||||
if (!userData) return null
|
||||
|
||||
const { signOut } = useClerk()
|
||||
const router = useRouter()
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger>
|
||||
@ -30,7 +36,10 @@ export default function UserButton({ userData }: { userData: User }) {
|
||||
{/* open modal with name and email (disabled) */}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem className="!text-destructive cursor-pointer">
|
||||
<DropdownMenuItem
|
||||
onClick={() => signOut(() => router.push("/"))}
|
||||
className="!text-destructive cursor-pointer"
|
||||
>
|
||||
<LogOut className="mr-2 h-4 w-4" />
|
||||
<span>Log Out</span>
|
||||
</DropdownMenuItem>
|
||||
|
Loading…
x
Reference in New Issue
Block a user