import { Fragment } from "react"; import { Disclosure, Menu, Transition } from "@headlessui/react"; import Link from "next/link"; import { useRouter } from "next/router"; import { signOut, useSession } from "next-auth/react"; import avatarFromInitials from "avatar-from-initials"; import { toast, Toaster } from "react-hot-toast"; import { Bars3Icon, BellIcon, XMarkIcon, UserCircleIcon, ArrowRightOnRectangleIcon, DocumentTextIcon, ChartBarIcon, WrenchIcon, } from "@heroicons/react/24/outline"; import Logo from "./logo"; const user = { name: "Timur Ercan", email: "timur@documenso.com", imageUrl: "https://pbs.twimg.com/profile_images/1382036502390181888/4BT30oTM_400x400.jpg", }; const navigation = [ { name: "Dashboard", href: "/dashboard", current: false, icon: ChartBarIcon, }, { name: "Documents", href: "/documents", current: false, icon: DocumentTextIcon, }, { name: "Settings", href: "/settings", current: true, icon: WrenchIcon, }, ]; const userNavigation = [ { name: "Your Profile", href: "/settings/profile", icon: UserCircleIcon }, { name: "Sign out", href: "", click: async (e: any) => { e.preventDefault(); const res: any = await toast.promise( signOut({ callbackUrl: "/login" }), { loading: "Logging out", success: "Your are logged out.", error: "Could not log out :/", }, { style: { minWidth: "200px", }, success: { duration: 10000, }, } ); }, icon: ArrowRightOnRectangleIcon, }, ]; function classNames(...classes: any) { return classes.filter(Boolean).join(" "); } export default function TopNavigation() { // const session = useSession(); const router = useRouter(); navigation.forEach((element) => { element.current = router.route.startsWith("/" + element.href.split("/")[1]); }); return ( <> {({ open }) => ( <>
{navigation.map((item) => ( {item.name} ))}

{user.name}

{user.email}

Open user menu
{userNavigation.map((item) => ( {({ active }) => ( {item.name} )} ))}
{/* Mobile menu button */} Open main menu {open ? (
{navigation.map((item) => ( {item.name} ))}
{user.name}
{user.email}
{userNavigation.map((item) => ( {item.name} ))}
)}
{/* */} ); }