|
|
|
@ -15,9 +15,8 @@ import {
|
|
|
|
DropdownItem,
|
|
|
|
DropdownItem,
|
|
|
|
DropdownTrigger,
|
|
|
|
DropdownTrigger,
|
|
|
|
} from '@nextui-org/dropdown'
|
|
|
|
} from '@nextui-org/dropdown'
|
|
|
|
import { Avatar, AvatarGroup, AvatarIcon } from '@nextui-org/avatar'
|
|
|
|
import { Avatar, AvatarIcon } from '@nextui-org/avatar'
|
|
|
|
import { Link } from '@nextui-org/link'
|
|
|
|
import { Link } from '@nextui-org/link'
|
|
|
|
import { Input } from '@nextui-org/input'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { link as linkStyles } from '@nextui-org/theme'
|
|
|
|
import { link as linkStyles } from '@nextui-org/theme'
|
|
|
|
|
|
|
|
|
|
|
|
@ -30,11 +29,23 @@ import { GithubIcon } from '@/components/icons'
|
|
|
|
|
|
|
|
|
|
|
|
import { Icon } from '@iconify/react'
|
|
|
|
import { Icon } from '@iconify/react'
|
|
|
|
import NewBookmarkForm from '@/components/newBookmarkForm'
|
|
|
|
import NewBookmarkForm from '@/components/newBookmarkForm'
|
|
|
|
import { usePathname } from 'next/navigation'
|
|
|
|
import { usePathname, useRouter } from 'next/navigation'
|
|
|
|
|
|
|
|
import { User } from '@/types'
|
|
|
|
export const Navbar = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const Navbar = ({ user }: { user: User | null }) => {
|
|
|
|
const pathname = usePathname()
|
|
|
|
const pathname = usePathname()
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pathname.startsWith('/login') || pathname.startsWith('/signup')) {
|
|
|
|
|
|
|
|
return <></>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const logout = async () => {
|
|
|
|
|
|
|
|
const response = await fetch('/api/auth/logout', {
|
|
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
router.refresh()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<NextUINavbar
|
|
|
|
<NextUINavbar
|
|
|
|
@ -110,12 +121,13 @@ export const Navbar = () => {
|
|
|
|
Signed in as
|
|
|
|
Signed in as
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
<p className='font-semibold text-primary'>
|
|
|
|
<p className='font-semibold text-primary'>
|
|
|
|
Guest
|
|
|
|
{user ? user.email : 'Guest'}
|
|
|
|
</p>
|
|
|
|
</p>
|
|
|
|
</DropdownItem>
|
|
|
|
</DropdownItem>
|
|
|
|
<DropdownItem
|
|
|
|
<DropdownItem
|
|
|
|
key='logout'
|
|
|
|
key='logout'
|
|
|
|
color='danger'>
|
|
|
|
color='danger'
|
|
|
|
|
|
|
|
onPress={() => logout()}>
|
|
|
|
Log Out
|
|
|
|
Log Out
|
|
|
|
</DropdownItem>
|
|
|
|
</DropdownItem>
|
|
|
|
</DropdownMenu>
|
|
|
|
</DropdownMenu>
|
|
|
|
|