import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { IconName } from '@fortawesome/fontawesome-svg-core' import { Dialog, Transition } from '@headlessui/react' import toast, { Toaster } from 'react-hot-toast' import Link from 'next/link' import Image from 'next/image' import { useRouter } from 'next/router' import { Fragment, useEffect, useState } from 'react' import siteConfig from '../config/site.json' const Navbar = () => { const router = useRouter() const [tokenPresent, setTokenPresent] = useState(false) const [isOpen, setIsOpen] = useState(false) useEffect(() => { const storedToken = () => { for (const r of siteConfig.protectedRoutes) { if (localStorage.hasOwnProperty(r)) { return true } } return false } setTokenPresent(storedToken()) }, []) const clearTokens = () => { setIsOpen(false) siteConfig.protectedRoutes.forEach(r => { localStorage.removeItem(r) }) toast.success('Cleared all tokens') setTimeout(() => { router.reload() }, 1000) } return (
icon {siteConfig.title}
{siteConfig.links.map(l => ( {l.name} ))} {siteConfig.email && ( Email )} {tokenPresent && ( )}
setIsOpen(false)}>
{/* This element is to trick the browser into centering the modal contents. */}
Clear all tokens?

These tokens are used to authenticate yourself into password protected folders, clearing them means that you will need to re-enter the passwords again.

{siteConfig.protectedRoutes.map((r, i) => (
{r}
))}
) } export default Navbar