mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Improve sidebar UX
This commit is contained in:
@@ -120,6 +120,16 @@ const Sidebar = () => {
|
|||||||
};
|
};
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper color={role}>
|
<Wrapper color={role}>
|
||||||
{role !== 'admin' && (
|
{role !== 'admin' && (
|
||||||
@@ -210,27 +220,40 @@ const Sidebar = () => {
|
|||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
<Box display='flex' flexDirection='column'>
|
<Box display='flex' flexDirection='column'>
|
||||||
|
{showAddButton(role, location.pathname) && (
|
||||||
<Box marginBottom='20px'>
|
<Box marginBottom='20px'>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<Add />}
|
icon={<Add />}
|
||||||
color={role}
|
color={role}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
switch(role) {
|
||||||
|
case 'client': {
|
||||||
|
if (/project/i.test(location.pathname)) {
|
||||||
|
navigate('/add-project');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 'productOwner': {
|
||||||
if (/project/i.test(location.pathname)) {
|
if (/project/i.test(location.pathname)) {
|
||||||
navigate('/add-project');
|
navigate('/add-project');
|
||||||
}
|
}
|
||||||
if (/template/i.test(location.pathname)) {
|
if (/template/i.test(location.pathname)) {
|
||||||
navigate('/add-template');
|
navigate('/add-template');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
case 'developer': {
|
||||||
if (/feature/i.test(location.pathname)) {
|
if (/feature/i.test(location.pathname)) {
|
||||||
navigate('/add-feature');
|
navigate('/add-feature');
|
||||||
}
|
}
|
||||||
if (/category/i.test(location.pathname)) {
|
if (/category/i.test(location.pathname)) {
|
||||||
navigate('/add-category');
|
navigate('/add-category');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
{/\/project/i.test(location.pathname) && (
|
)}
|
||||||
|
{/project/i.test(location.pathname) && ['client', 'productOwner'].includes(role) && (
|
||||||
<Box>
|
<Box>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<Messaging />}
|
icon={<Messaging />}
|
||||||
|
|||||||
@@ -418,12 +418,10 @@ const AddProject = () => {
|
|||||||
.required('Email is required')
|
.required('Email is required')
|
||||||
.email('Email is invalid'),
|
.email('Email is invalid'),
|
||||||
prefix: Yup.string().required('Prefix is required'),
|
prefix: Yup.string().required('Prefix is required'),
|
||||||
// prettier-ignore
|
|
||||||
number: Yup.number().typeError('Phone must be a number').required('Phone is required'),
|
number: Yup.number().typeError('Phone must be a number').required('Phone is required'),
|
||||||
place: Yup.string().required('Address is required'),
|
place: Yup.string().required('Address is required'),
|
||||||
city: Yup.string().required('City is required'),
|
city: Yup.string().required('City is required'),
|
||||||
country: Yup.string().required('Country is required'),
|
country: Yup.string().required('Country is required'),
|
||||||
// prettier-ignore
|
|
||||||
zip: Yup.number().typeError('Zip must be a number').required('Zip is required'),
|
zip: Yup.number().typeError('Zip must be a number').required('Zip is required'),
|
||||||
}),
|
}),
|
||||||
onSubmit: ({
|
onSubmit: ({
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ const AddTemplate = () => {
|
|||||||
<Spinner fullScreen color={role || 'client'} />
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
);
|
);
|
||||||
|
|
||||||
if (categoriesError || featuresError || !availableFeatures || !categories) return (
|
if (categoriesError || featuresError || !categories) return (
|
||||||
<Wrapper color={role}>
|
<Wrapper color={role}>
|
||||||
<Box
|
<Box
|
||||||
width='100%'
|
width='100%'
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export const Wrapper = styled.div`
|
type WrapperProps = {
|
||||||
|
color?: 'client' | 'productOwner' | 'developer' | 'admin';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Wrapper = styled.div<WrapperProps>`
|
||||||
padding: 35px 45px 35px 120px;
|
padding: 35px 45px 35px 120px;
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
fill: ${({ theme, color }) =>
|
||||||
|
color ? theme.colors[color].main : theme.colors.client.main};
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user