Change page routing structure and added header

This commit is contained in:
Mitchell Magro 2025-06-20 08:16:39 +02:00
parent 1f7b2dc188
commit 48764c779c
9 changed files with 189 additions and 8 deletions

View File

@ -0,0 +1,46 @@
import React, { useState } from 'react';
import { AppBar, Toolbar, IconButton, Menu, MenuItem, Button } from '@mui/material';
import MenuIcon from '@mui/icons-material/Menu';
const Header = () => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
// Handle menu open
const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
// Handle menu close
const handleMenuClose = () => {
setAnchorEl(null);
};
return (
<AppBar position="sticky" color="transparent" elevation={0} sx={{ borderBottom: '1px solid #22242626' }}>
<Toolbar>
{/* Burger Menu */}
<IconButton edge="start" color="inherit" aria-label="menu">
<MenuIcon />
</IconButton>
{/* Dropdown Button */}
<Button color="inherit" onClick={handleMenuClick}>
Options
</Button>
{/* Dropdown Menu */}
<Menu
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleMenuClose}
>
<MenuItem onClick={handleMenuClose}>Option 1</MenuItem>
<MenuItem onClick={handleMenuClose}>Option 2</MenuItem>
<MenuItem onClick={handleMenuClose}>Option 3</MenuItem>
</Menu>
</Toolbar>
</AppBar>
);
};
export default Header;

View File

@ -0,0 +1,8 @@
import { styled } from '@mui/system';
export const LayoutWrapper = styled('div')({
display: 'flex',
width: '100%',
height: '100vh',
overflow: 'hidden',
});

View File

@ -0,0 +1,8 @@
import { styled } from '@mui/system';
export const MainContent = styled('div')(({ theme }) => ({
marginLeft: '240px',
padding: theme.spacing(3),
minHeight: '100vh',
width: 'calc(100% - 240px)',
}));

View File

@ -0,0 +1,41 @@
'use client';
import Link from 'next/link';
import { styled } from '@mui/system';
import { ISidebarLink } from '@/interfaces/SidebarLink.interfaces';
const LinkContainer = styled('div')(({ theme }) => ({
display: 'flex',
alignItems: 'center',
padding: '12px 1px',
borderRadius: '4px',
color: theme.palette.text.tertiary,
textDecoration: 'none',
transition: 'background 0.2s ease-in-out',
'&:hover': {
color: 'rgb(255, 255, 255)',
background: 'rgba(255, 255, 255, 0.08)',
backgroundColor: theme.palette.action.hover,
cursor: 'pointer',
},
}));
const LinkText = styled('span')(({ theme }) => ({
color: theme.palette.text.tertiary,
marginLeft: '12px',
fontWeight: 500,
}));
export default function SidebarLink({ title, path, icon: Icon }: ISidebarLink) {
return (
<Link href={path} passHref legacyBehavior>
<a style={{ textDecoration: 'none' }}>
<LinkContainer>
{Icon && <Icon />}
<LinkText>{title}</LinkText>
</LinkContainer>
</a>
</Link>
);
}

View File

@ -0,0 +1,55 @@
'use client';
import React from 'react';
import DashboardIcon from '@mui/icons-material/Dashboard';
import { styled } from '@mui/system';
import { SIDEBAR_LINKS } from '@/constants/SidebarLink.constants';
import SidebarLink from './SideBarLink';
const SidebarContainer = styled('aside')(({ theme }) => ({
position: 'fixed',
top: 0,
left: 0,
width: 240,
height: '100vh',
backgroundColor: theme.palette.background.primary,
color: theme.palette.text.primary,
display: 'flex',
flexDirection: 'column',
padding: theme.spacing(2),
zIndex: 1100,
borderRight: `1px solid ${theme.palette.divider}`,
}));
const SidebarHeader = styled('div')(({ theme }) => ({
fontSize: '20px',
fontWeight: 600,
marginBottom: theme.spacing(3),
display: 'flex',
alignItems: 'center',
color: theme.palette.text.primary,
}));
const IconSpacing = styled(DashboardIcon)(({ theme }) => ({
marginLeft: theme.spacing(1),
}));
const Sidebar = () => {
return (
<SidebarContainer>
<SidebarHeader>
PaymentIQ <IconSpacing fontSize="small" />
</SidebarHeader>
{SIDEBAR_LINKS.map((link) => (
<SidebarLink
key={link.path}
title={link.title}
path={link.path}
icon={link.icon}
/>
))}
</SidebarContainer>
);
};
export default Sidebar;

View File

@ -0,0 +1,15 @@
// This ensures this component is rendered only on the client side
// 'use client';
import Typography from '@mui/material/Typography';
import React from 'react';
export default function KycPage() {
return (
<div>
<Typography variant="h4" gutterBottom>
KYC Overview
</Typography>
</div>
);
}

View File

@ -1,10 +1,23 @@
'use client'; 'use client';
import React from 'react'; import React from 'react';
import SidebarLayout from '../components/sidebar/Sidebar'; import { MainContent } from '../components/dashboard/layout/mainContent';
import Header from '../components/dashboard/header/Header';
import { LayoutWrapper } from '../components/dashboard/layout/layoutWrapper';
import Sidebar from '@/app/components/dashboard/sidebar/Sidebar';
const DashboardLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => { const DashboardLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
return <SidebarLayout>{children}</SidebarLayout>; // Ensure that the sidebar wraps all dashboard pages return (
<LayoutWrapper>
<Sidebar />
<div style={{ flexGrow: 1, display: 'flex', flexDirection: 'column' }}>
<MainContent>
<Header />
{children}
</MainContent>
</div>
</LayoutWrapper>
);
}; };
export default DashboardLayout; export default DashboardLayout;

View File

@ -1,7 +1,7 @@
'use client'; 'use client';
import React from 'react'; import React from 'react';
import { Typography, Paper } from '@mui/material'; import { Typography } from '@mui/material';
const DashboardPage = () => { const DashboardPage = () => {
return ( return (

View File

@ -1,5 +0,0 @@
import SidebarLayout from '@/app/components/sidebar/Sidebar';
export default function Home() {
return <SidebarLayout />;
}