Navigation improvements

This commit is contained in:
Hazem Krimi
2023-05-28 16:57:03 +01:00
parent eb9b60bbf2
commit 90ad62d41f
2 changed files with 10 additions and 10 deletions
+6 -6
View File
@@ -72,11 +72,11 @@ const Navbar = () => {
<Link <Link
href='/template' href='/template'
color={ color={
new RegExp('template', 'i').test(location.pathname) new RegExp(/(template|prototype)/, 'i').test(location.pathname)
? 'developer' ? 'developer'
: 'black' : 'black'
} }
selected={new RegExp('template', 'i').test(location.pathname)} selected={new RegExp(/(template|prototype)/, 'i').test(location.pathname)}
> >
Templates Templates
</Link> </Link>
@@ -109,22 +109,22 @@ const Navbar = () => {
<Link <Link
href='/project' href='/project'
color={ color={
new RegExp('project', 'i').test(location.pathname) new RegExp(/(project|support)/, 'i').test(location.pathname)
? 'productOwner' ? 'productOwner'
: 'black' : 'black'
} }
selected={new RegExp('project', 'i').test(location.pathname)} selected={new RegExp(/(project|support)/, 'i').test(location.pathname)}
> >
Projects Projects
</Link> </Link>
<Link <Link
href='/template' href='/template'
color={ color={
new RegExp('template', 'i').test(location.pathname) new RegExp(/(template|prototype)/, 'i').test(location.pathname)
? 'productOwner' ? 'productOwner'
: 'black' : 'black'
} }
selected={new RegExp('template', 'i').test(location.pathname)} selected={new RegExp(/(template|prototype)/, 'i').test(location.pathname)}
> >
Templates Templates
</Link> </Link>
+4 -4
View File
@@ -96,7 +96,7 @@ const Sidebar = () => {
}); });
useEffect(() => { useEffect(() => {
if (/project/i.test(location.pathname)) { if (/(project|support)/i.test(location.pathname)) {
if (role !== 'client') getProjects(); if (role !== 'client') getProjects();
else getProjectsByClientId({ variables: { id: currentUser?.id! } }); else getProjectsByClientId({ variables: { id: currentUser?.id! } });
} }
@@ -123,7 +123,7 @@ const Sidebar = () => {
const showAddButton = (role: string, pathname: string) => { const showAddButton = (role: string, pathname: string) => {
switch (role) { switch (role) {
case 'client': case 'client':
return /project/i.test(pathname); return /(project|support)/i.test(pathname);
case 'productOwner': case 'productOwner':
return /template/i.test(pathname); return /template/i.test(pathname);
case 'developer': case 'developer':
@@ -139,7 +139,7 @@ const Sidebar = () => {
<> <>
<Box display='flex' flexDirection='column'> <Box display='flex' flexDirection='column'>
{projects && {projects &&
new RegExp(/project/, 'i').test(location.pathname) && new RegExp(/(project|support)/, 'i').test(location.pathname) &&
projects.map((project, index) => ( projects.map((project, index) => (
<Box marginBottom='20px' key={project.id}> <Box marginBottom='20px' key={project.id}>
<div id={`project-${project.id}`}> <div id={`project-${project.id}`}>
@@ -261,7 +261,7 @@ const Sidebar = () => {
/> />
</Box> </Box>
)} )}
{/project/i.test(location.pathname) && {/(project|support)/i.test(location.pathname) &&
['client', 'productOwner'].includes(role as string) && ( ['client', 'productOwner'].includes(role as string) && (
<Box> <Box>
<IconButton <IconButton