All files / features/admin/layouts AdminLayout.tsx

100% Statements 6/6
62.5% Branches 5/8
100% Functions 2/2
100% Lines 5/5

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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90              1x 3x 3x   12x   3x                                                                                                                                                        
import { Suspense } from 'react'
import { Outlet, Link, useLocation } from 'react-router-dom'
import { PageLoader } from '@core/components/ui/page-loader'
import { AppHeader } from '@core/components/AppHeader'
import { useTranslation } from 'react-i18next'
import { LayoutDashboard, Layers, Users, Settings } from 'lucide-react'
 
export const AdminLayout = () => {
    const { t } = useTranslation('common')
    const location = useLocation()
 
    const isActive = (path: string) => location.pathname === path
 
    return (
        <div className="flex flex-col h-screen w-full overflow-hidden">
            <AppHeader title={t('admin_layout.title', 'Admin')} />
            <div className="flex flex-1 overflow-hidden">
                <aside
                    className="hidden md:flex p-4 border-r flex-col"
                    style={{
                        width: 'var(--admin-sidebar-width)',
                        backgroundColor: 'var(--admin-sidebar-bg)',
                        color: 'var(--admin-sidebar-text)',
                        padding: 'var(--admin-sidebar-padding)',
                    }}
                >
                    <nav className="flex flex-col gap-1">
                        <Link
                            to="/admin"
                            className={`p-2 rounded flex items-center gap-3 transition-colors ${
                                isActive('/admin')
                                    ? 'bg-primary/10 text-primary font-medium'
                                    : 'hover:bg-muted/10'
                            }`}
                        >
                            <LayoutDashboard className="h-4 w-4" />
                            {t('nav.dashboard')}
                        </Link>
                        <Link
                            to="/admin/events"
                            className={`p-2 rounded flex items-center gap-3 transition-colors ${
                                isActive('/admin/events')
                                    ? 'bg-primary/10 text-primary font-medium'
                                    : 'hover:bg-muted/10'
                            }`}
                        >
                            <Layers className="h-4 w-4" />
                            {t('nav.events')}
                        </Link>
                        <Link
                            to="/admin/staff"
                            className={`p-2 rounded flex items-center gap-3 transition-colors ${
                                isActive('/admin/staff')
                                    ? 'bg-primary/10 text-primary font-medium'
                                    : 'hover:bg-muted/10'
                            }`}
                        >
                            <Users className="h-4 w-4" />
                            {t('nav.staff', 'Staff')}
                        </Link>
                        <Link
                            to="/admin/settings"
                            className={`p-2 rounded flex items-center gap-3 transition-colors ${
                                isActive('/admin/settings')
                                    ? 'bg-primary/10 text-primary font-medium'
                                    : 'hover:bg-muted/10'
                            }`}
                        >
                            <Settings className="h-4 w-4" />
                            {t('nav.settings')}
                        </Link>
                    </nav>
                </aside>
                <main
                    className="flex-1 overflow-auto"
                    style={{
                        backgroundColor: 'var(--admin-content-bg)',
                    }}
                >
                    <div className="p-6" style={{ padding: 'var(--admin-content-padding)' }}>
                        <Suspense fallback={<PageLoader />}>
                            <Outlet />
                        </Suspense>
                    </div>
                </main>
            </div>
        </div>
    )
}