Add logout button to home page header
This commit is contained in:
@@ -3,6 +3,7 @@ import ListCard from '@/components/ListCard'
|
||||
import NewListButton from '@/components/NewListButton'
|
||||
import GlobalSearch from '@/components/GlobalSearch'
|
||||
import EmptyState from '@/components/EmptyState'
|
||||
import LogoutButton from '@/components/LogoutButton'
|
||||
import Link from 'next/link'
|
||||
import { getServerSession } from 'next-auth'
|
||||
import { authOptions } from '@/pages/api/auth/[...nextauth]'
|
||||
@@ -39,6 +40,7 @@ export default async function Home() {
|
||||
>
|
||||
Profile
|
||||
</Link>
|
||||
<LogoutButton />
|
||||
</>
|
||||
)}
|
||||
<NewListButton />
|
||||
|
||||
21
components/LogoutButton.tsx
Normal file
21
components/LogoutButton.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { signOut } from 'next-auth/react'
|
||||
import { LogOut } from 'lucide-react'
|
||||
|
||||
export default function LogoutButton() {
|
||||
const handleLogout = async () => {
|
||||
await signOut({ callbackUrl: '/auth/login' })
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className="flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors"
|
||||
aria-label="Log out"
|
||||
>
|
||||
<LogOut size={16} />
|
||||
<span>Log out</span>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user