Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3130 finance tab divided into subtabs #3139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 80 additions & 18 deletions src/frontend/src/layouts/Sidebar/NavPageLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,70 @@
import { NavLink } from 'react-router-dom';
import { LinkItem } from '../../utils/types';
import { routes } from '../../utils/routes';
import { Typography, useTheme } from '@mui/material';
import { Box, Typography, useTheme, Collapse } from '@mui/material';

export interface NavPageLinkItemProps extends LinkItem {
open?: boolean;
isSubmenuOpen?: boolean;
onSubmenuHover?: () => void;
onSubmenuCollapse?: () => void;
isSubItem?: boolean;
}

const NavPageLink: React.FC<NavPageLinkItemProps> = ({ name, route, icon }) => {
const NavPageLink: React.FC<NavPageLinkItemProps> = ({
name,
route,
icon,
subItems,
isSubmenuOpen,
onSubmenuHover,
onSubmenuCollapse,
isSubItem = false
}) => {
const theme = useTheme();
return (
<NavLink
key={name}
to={route}
exact={route === routes.HOME}
style={(isActive) => {
return {

const renderLink = () => {
const content = (
<>
{icon}
<Typography
sx={{
fontSize: isSubItem ? '0.8rem' : '1rem'
}}
>
{name}
</Typography>
</>
);

if (subItems) {
return (
<Box
onMouseEnter={onSubmenuHover}
sx={{
textDecoration: 'none',
color: theme.palette.text.primary,
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
gap: '8px',
borderRadius: '8px',
padding: '8px',
margin: '8px',
cursor: 'pointer'
}}
>
{content}
</Box>
);
}

return (
<NavLink
to={route}
exact={route === routes.HOME}
onClick={onSubmenuCollapse}
style={(isActive) => ({
textDecoration: 'none',
color: isActive ? '#ef4345' : theme.palette.text.primary,
backgroundColor: isActive ? 'white' : 'transparent',
Expand All @@ -29,14 +78,27 @@ const NavPageLink: React.FC<NavPageLinkItemProps> = ({ name, route, icon }) => {
justifyContent: 'flex-start',
gap: '8px',
borderRadius: '8px',
padding: '8px',
margin: '8px'
};
}}
>
{icon}
<Typography>{name}</Typography>
</NavLink>
padding: isSubItem ? '2px' : '8px',
margin: isSubItem ? '2px' : '8px',
marginLeft: isSubItem ? '28px' : '8px'
})}
>
{content}
</NavLink>
);
};

return (
<Box>
{renderLink()}
{subItems && (
<Collapse in={isSubmenuOpen} timeout="auto" unmountOnExit>
{subItems.map((subItem) => (
<NavPageLink {...subItem} isSubItem={true} />
))}
</Collapse>
)}
</Box>
);
};

Expand Down
45 changes: 43 additions & 2 deletions src/frontend/src/layouts/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import NavUserMenu from '../PageTitle/NavUserMenu';
import DrawerHeader from '../../components/DrawerHeader';
import { ChevronLeft, ChevronRight } from '@mui/icons-material';
import BarChartIcon from '@mui/icons-material/BarChart';
import QueryStatsIcon from '@mui/icons-material/QueryStats';
import CurrencyExchangeIcon from '@mui/icons-material/CurrencyExchange';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import { useState } from 'react';

interface SidebarProps {
drawerOpen: boolean;
Expand All @@ -30,6 +34,7 @@ interface SidebarProps {
}

const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: SidebarProps) => {
const [openSubmenu, setOpenSubmenu] = useState<string | null>(null);
const linkItems: LinkItem[] = [
{
name: 'Home',
Expand All @@ -54,7 +59,30 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
{
name: 'Finance',
icon: <AttachMoneyIcon />,
route: routes.FINANCE
route: routes.FINANCE,
subItems: [
{
name: 'Finance Dashboard',
icon: <QueryStatsIcon sx={{ fontSize: '20px' }} />,
route: routes.FINANCE_DASHBOARD
},
{
name: 'Reimbursments',
icon: <CurrencyExchangeIcon sx={{ fontSize: '20px' }} />,
route: routes.REIMBURSEMENT_REQUESTS
},
{
name: 'Companies & Sponsors',
icon: <ShoppingCartIcon sx={{ fontSize: '20px' }} />,
route: routes.COMPANIES_SPONSORS
},
{
/* FOR REFRENCE (TO BE REMOVED) */
name: 'Original Page',
icon: <AttachMoneyIcon sx={{ fontSize: '20px' }} />,
route: routes.FINANCE
}
]
},
{
name: 'Teams',
Expand Down Expand Up @@ -85,6 +113,14 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
setMoveContent(!moveContent);
};

const handleOpenSubmenu = (name: string) => {
setOpenSubmenu(name);
};

const handleCloseSubmenu = () => {
setOpenSubmenu(null);
};

return (
<NERDrawer
open={drawerOpen}
Expand All @@ -107,7 +143,12 @@ const Sidebar = ({ drawerOpen, setDrawerOpen, moveContent, setMoveContent }: Sid
>
<Box>
{linkItems.map((linkItem) => (
<NavPageLink {...linkItem} />
<NavPageLink
{...linkItem}
isSubmenuOpen={openSubmenu === linkItem.name}
onSubmenuHover={() => handleOpenSubmenu(linkItem.name)}
onSubmenuCollapse={() => handleCloseSubmenu()}
/>
))}
{<NavUserMenu open={drawerOpen} />}
</Box>
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/src/pages/FinancePage/CompaniesAndSponsors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Box } from '@mui/system';

const CompaniesAndSponsors: React.FC = () => {
return <Box>Companies and Sponsoring Vendors</Box>;
};

export default CompaniesAndSponsors;
6 changes: 6 additions & 0 deletions src/frontend/src/pages/FinancePage/Finance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ import FinancePage from './FinancePage';
import CreateReimbursementRequestPage from './CreateReimbursementRequest';
import EditReimbursementRequestPage from './EditReimbursementRequest/EditReimbursementRequest';
import ReimbursementRequestDetails from './ReimbursementRequestDetailPage/ReimbursementRequestDetails';
import FinanceDashboard from './FinanceDashboard';
import ReimbursmentRequests from './ReimbursmentRequests';
import CompaniesAndSponsors from './CompaniesAndSponsors';

const Finance: React.FC = () => {
return (
<Switch>
<Route path={routes.REIMBURSEMENT_REQUEST_EDIT} component={EditReimbursementRequestPage} />
<Route path={routes.NEW_REIMBURSEMENT_REQUEST} component={CreateReimbursementRequestPage} />
<Route path={routes.REIMBURSEMENT_REQUEST_BY_ID} component={ReimbursementRequestDetails} />
<Route path={routes.FINANCE_DASHBOARD} component={FinanceDashboard} />
<Route path={routes.REIMBURSEMENT_REQUESTS} component={ReimbursmentRequests} />
<Route path={routes.COMPANIES_SPONSORS} component={CompaniesAndSponsors} />
<Route path={routes.FINANCE} component={FinancePage} />
</Switch>
);
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/src/pages/FinancePage/FinanceDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Box } from '@mui/system';

const FinanceDashboard: React.FC = () => {
return <Box>Finance Dashboard</Box>;
};

export default FinanceDashboard;
7 changes: 7 additions & 0 deletions src/frontend/src/pages/FinancePage/ReimbursmentRequests.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Box } from '@mui/system';

const ReimbursementRequests: React.FC = () => {
return <Box>Reimbursement Requests</Box>;
};

export default ReimbursementRequests;
4 changes: 4 additions & 0 deletions src/frontend/src/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const REIMBURSEMENT_REQUESTS = FINANCE + '/reimbursement-requests';
const REIMBURSEMENT_REQUEST_BY_ID = REIMBURSEMENT_REQUESTS + `/:id`;
const REIMBURSEMENT_REQUEST_EDIT = REIMBURSEMENT_REQUEST_BY_ID + `/edit`;
const NEW_REIMBURSEMENT_REQUEST = REIMBURSEMENT_REQUESTS + `/new`;
const FINANCE_DASHBOARD = FINANCE + `/dashboard`;
const COMPANIES_SPONSORS = FINANCE + `/companies-sponsors`;

/**************** Projects Section ****************/
const PROJECTS = `/projects`;
Expand Down Expand Up @@ -95,6 +97,8 @@ export const routes = {
REIMBURSEMENT_REQUESTS,
REIMBURSEMENT_REQUEST_BY_ID,
REIMBURSEMENT_REQUEST_EDIT,
FINANCE_DASHBOARD,
COMPANIES_SPONSORS,

SETTINGS,
SETTINGS_DETAILS,
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface LinkItem {
name: string;
icon?: JSX.Element;
route: string;
subItems?: LinkItem[];
}

export interface VersionObject {
Expand Down
Loading