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