Fix warnings

This commit is contained in:
Hazem Krimi
2023-05-21 17:18:54 +01:00
parent 69e7258076
commit 055ad3a61e
+22 -11
View File
@@ -56,7 +56,7 @@ const Sidebar = () => {
}, },
onCompleted({ getAllProjectsByClientId }) { onCompleted({ getAllProjectsByClientId }) {
setProjects(getAllProjectsByClientId); setProjects(getAllProjectsByClientId);
} },
}); });
const [getProjects] = useLazyQuery< const [getProjects] = useLazyQuery<
@@ -65,7 +65,7 @@ const Sidebar = () => {
>(GET_ALL_PROJECTS, { >(GET_ALL_PROJECTS, {
onCompleted({ getAllProjects }) { onCompleted({ getAllProjects }) {
setProjects(getAllProjects); setProjects(getAllProjects);
} },
}); });
const [getTemplates] = useLazyQuery< const [getTemplates] = useLazyQuery<
@@ -122,13 +122,16 @@ const Sidebar = () => {
const showAddButton = (role: string, pathname: string) => { const showAddButton = (role: string, pathname: string) => {
switch (role) { switch (role) {
case 'client': return (/project/i.test(pathname)); case 'client':
case 'productOwner': return (/template/i.test(pathname)); return /project/i.test(pathname);
case 'developer': return (/feature/i.test(pathname) || /category/i.test(pathname)); case 'productOwner':
return /template/i.test(pathname);
case 'developer':
return /feature/i.test(pathname) || /category/i.test(pathname);
} }
return false; return false;
} };
return ( return (
<Wrapper color={role}> <Wrapper color={role}>
@@ -144,7 +147,8 @@ const Sidebar = () => {
color={role} color={role}
selected={ selected={
new RegExp(project.id, 'i').test(location.pathname) || new RegExp(project.id, 'i').test(location.pathname) ||
(index === 0 && location.pathname === '/project')} (index === 0 && location.pathname === '/project')
}
text={project.name[0]} text={project.name[0]}
onClick={() => navigate(`/project/${project.id}`)} onClick={() => navigate(`/project/${project.id}`)}
/> />
@@ -220,17 +224,19 @@ const Sidebar = () => {
))} ))}
</Box> </Box>
<Box display='flex' flexDirection='column'> <Box display='flex' flexDirection='column'>
{showAddButton(role, location.pathname) && ( {showAddButton(role as string, location.pathname) && (
<Box marginBottom='20px'> <Box marginBottom='20px'>
<IconButton <IconButton
icon={<Add />} icon={<Add />}
color={role} color={role}
onClick={() => { onClick={() => {
switch (role) { switch (role) {
case 'client': { case 'client':
default: {
if (/project/i.test(location.pathname)) { if (/project/i.test(location.pathname)) {
navigate('/add-project'); navigate('/add-project');
} }
break;
} }
case 'productOwner': { case 'productOwner': {
if (/project/i.test(location.pathname)) { if (/project/i.test(location.pathname)) {
@@ -239,6 +245,7 @@ const Sidebar = () => {
if (/template/i.test(location.pathname)) { if (/template/i.test(location.pathname)) {
navigate('/add-template'); navigate('/add-template');
} }
break;
} }
case 'developer': { case 'developer': {
if (/feature/i.test(location.pathname)) { if (/feature/i.test(location.pathname)) {
@@ -247,18 +254,22 @@ const Sidebar = () => {
if (/category/i.test(location.pathname)) { if (/category/i.test(location.pathname)) {
navigate('/add-category'); navigate('/add-category');
} }
break;
} }
} }
}} }}
/> />
</Box> </Box>
)} )}
{/project/i.test(location.pathname) && ['client', 'productOwner'].includes(role) && ( {/project/i.test(location.pathname) &&
['client', 'productOwner'].includes(role as string) && (
<Box> <Box>
<IconButton <IconButton
icon={<Messaging />} icon={<Messaging />}
color={role} color={role}
onClick={() => setMessagingSidebarOpen(!messagingSidebarOpen)} onClick={() =>
setMessagingSidebarOpen(!messagingSidebarOpen)
}
/> />
</Box> </Box>
)} )}