All files / frontend/src/components MainLayout.tsx

17.94% Statements 7/39
100% Branches 0/0
0% Functions 0/1
17.94% Lines 7/39

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 601x 1x 1x 1x 1x               1x                                                                                           1x  
import React, { useState } from 'react';
import Sidebar from './Sidebar';
import Header from './Header';
import MobileMenu from './Navigation/MobileMenu';
import BottomNav from './Navigation/BottomNav';
 
interface MainLayoutProps {
    children: React.ReactNode;
    title?: string;
    showBackButton?: boolean;
}
 
const MainLayout: React.FC<MainLayoutProps> = ({ children, title = 'Dashboard', showBackButton = false }) => {
    const [sidebarOpen, setSidebarOpen] = useState(false);
    const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
 
    const handleMenuClick = () => {
        // On desktop, toggle sidebar; on mobile, toggle mobile menu
        if (window.innerWidth >= 1024) {
            setSidebarOpen(!sidebarOpen);
        } else {
            setMobileMenuOpen(!mobileMenuOpen);
        }
    };
 
    return (
        <div className="min-h-screen bg-oxford-blue">
            {/* Desktop Sidebar */}
            <div className="hidden lg:block">
                <Sidebar isOpen={sidebarOpen} onClose={() => setSidebarOpen(false)} />
            </div>
            
            {/* Mobile Menu */}
            <div className="lg:hidden">
                <MobileMenu isOpen={mobileMenuOpen} onClose={() => setMobileMenuOpen(false)} />
            </div>
            
            <Header 
                onMenuClick={handleMenuClick} 
                title={title} 
                showBackButton={showBackButton}
            />
 
            <main 
                className="lg:ml-64 p-4 sm:p-6 lg:p-8 mobile-p-4"
                role="main"
                aria-label={title}
                style={{ paddingBottom: '5rem' }}
            >
                {children}
            </main>
 
            {/* Bottom Navigation for Mobile */}
            <BottomNav />
        </div>
    );
};
 
export default MainLayout;