Skip to content
Snippets Groups Projects
Commit 4cbaaecc authored by Felipe D'Abrantes's avatar Felipe D'Abrantes
Browse files

Add questions page link to user navigation

parent dd572310
No related branches found
No related tags found
1 merge request!25Add a question management page
import { FC, PropsWithChildren } from 'react' import { FC, PropsWithChildren } from 'react'
import { Disclosure, Menu } from '@headlessui/react' import { Disclosure, Menu } from '@headlessui/react'
import { Bars3Icon, BellIcon, XMarkIcon } from '@heroicons/react/24/outline' import { Bars3Icon, BellIcon, XMarkIcon, } from '@heroicons/react/24/outline'
import { UserCircleIcon, MagnifyingGlassIcon } from '@heroicons/react/24/solid' import { UserCircleIcon, MagnifyingGlassIcon } from '@heroicons/react/24/solid'
import { User } from '@/types/user' import { User } from '@/types/user'
import NavMenu from './NavMenu' import NavMenu from './NavMenu'
...@@ -12,11 +12,18 @@ import Router from 'next/router' ...@@ -12,11 +12,18 @@ import Router from 'next/router'
const navigation = [ const navigation = [
{ name: 'My Feed', href: '/feed', current: true } { name: 'My Feed', href: '/feed', current: true }
] ]
const userNavigation = [
{ name: 'Your Profile', href: '/profile' }, const userNavigation = (isAdmin: Boolean) => {
{ name: 'Friends', href: '/search'}, const list = [
{ name: 'Sign out', href: '/signOut' }, { name: 'Your Profile', href: '/profile' },
] { name: 'Friends', href: '/search' }
];
isAdmin && list.push({ name: 'Questions', href: '/questions' });
list.push({ name: 'Sign out', href: '/signOut' });
return list;
};
function classNames(...classes: any) { function classNames(...classes: any) {
return classes.filter(Boolean).join(' ') return classes.filter(Boolean).join(' ')
...@@ -98,7 +105,7 @@ const NavBar: FC<PropsWithChildren<NavBarProps>> = ({ ...@@ -98,7 +105,7 @@ const NavBar: FC<PropsWithChildren<NavBarProps>> = ({
<div className='w-full border-b'> <div className='w-full border-b'>
<p className='block px-4 py-2 text-sm text-gray-700 font-bold'>{`Hi, ${user?.firstName || user?.username}`}</p> <p className='block px-4 py-2 text-sm text-gray-700 font-bold'>{`Hi, ${user?.firstName || user?.username}`}</p>
</div> </div>
{userNavigation.map((item) => ( {userNavigation(user.admin).map((item) => (
<Menu.Item key={item.name}> <Menu.Item key={item.name}>
{({ active }) => ( {({ active }) => (
<a <a
...@@ -180,7 +187,7 @@ const NavBar: FC<PropsWithChildren<NavBarProps>> = ({ ...@@ -180,7 +187,7 @@ const NavBar: FC<PropsWithChildren<NavBarProps>> = ({
</button> </button>
</div> </div>
<div className="mt-4 space-y-1 px-2"> <div className="mt-4 space-y-1 px-2">
{userNavigation.map((item) => ( {userNavigation(user?.admin ?? false).map((item) => (
<Disclosure.Button <Disclosure.Button
key={item.name} key={item.name}
as="a" as="a"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment