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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | 2x 3x 3x 3x 3x 3x 18x 3x 3x 12x 12x 12x 12x | import React, { useState } from 'react';
import { Link, useLocation, Outlet } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
import {
Home,
Briefcase,
Users,
FileText,
Building,
User,
LogOut,
Menu,
X,
Bell
} from 'lucide-react';
const Layout = () => {
const { user, logout } = useAuth();
const location = useLocation();
const [sidebarOpen, setSidebarOpen] = useState(false);
const navigation = [
{ name: 'Dashboard', href: '/dashboard', icon: Home, roles: ['admin', 'recruiter', 'employer', 'candidate'] },
{ name: 'Jobs', href: '/jobs', icon: Briefcase, roles: ['admin', 'recruiter', 'employer', 'candidate'] },
{ name: 'Candidates', href: '/candidates', icon: Users, roles: ['admin', 'recruiter', 'employer'] },
{ name: 'Applications', href: '/applications', icon: FileText, roles: ['admin', 'recruiter', 'employer', 'candidate'] },
{ name: 'Employers', href: '/employers', icon: Building, roles: ['admin', 'recruiter'] },
{ name: 'Resumes', href: '/resumes', icon: FileText, roles: ['candidate'] },
];
const filteredNavigation = navigation.filter(item =>
item.roles.includes(user?.role)
);
const handleLogout = () => {
logout();
};
return (
<div className="min-h-screen bg-gray-50">
{/* Mobile sidebar */}
<div className={`fixed inset-0 z-50 lg:hidden ${sidebarOpen ? 'block' : 'hidden'}`}>
<div className="fixed inset-0 bg-gray-600 bg-opacity-75" onClick={() => setSidebarOpen(false)} />
<div className="relative flex-1 flex flex-col max-w-xs w-full bg-white">
<div className="absolute top-0 right-0 -mr-12 pt-2">
<button
type="button"
className="ml-1 flex items-center justify-center h-10 w-10 rounded-full focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"
onClick={() => setSidebarOpen(false)}
>
<X className="h-6 w-6 text-white" />
</button>
</div>
<div className="flex-1 h-0 pt-5 pb-4 overflow-y-auto">
<div className="flex-shrink-0 flex items-center px-4">
<h1 className="text-xl font-bold text-gray-900">MerchantsOfHope-SupplyANdDemandPortal</h1>
</div>
<nav className="mt-5 px-2 space-y-1">
{filteredNavigation.map((item) => {
const isActive = location.pathname === item.href;
return (
<Link
key={item.name}
to={item.href}
className={`${
isActive
? 'bg-primary-100 text-primary-900'
: 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'
} group flex items-center px-2 py-2 text-base font-medium rounded-md`}
>
<item.icon className="mr-4 h-6 w-6" />
{item.name}
</Link>
);
})}
</nav>
</div>
</div>
</div>
{/* Desktop sidebar */}
<div className="hidden lg:flex lg:w-64 lg:flex-col lg:fixed lg:inset-y-0">
<div className="flex-1 flex flex-col min-h-0 border-r border-gray-200 bg-white">
<div className="flex-1 flex flex-col pt-5 pb-4 overflow-y-auto">
<div className="flex items-center flex-shrink-0 px-4">
<h1 className="text-xl font-bold text-gray-900">MerchantsOfHope-SupplyANdDemandPortal</h1>
</div>
<nav className="mt-5 flex-1 px-2 space-y-1">
{filteredNavigation.map((item) => {
const isActive = location.pathname === item.href;
return (
<Link
key={item.name}
to={item.href}
className={`${
isActive
? 'bg-primary-100 text-primary-900'
: 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'
} group flex items-center px-2 py-2 text-sm font-medium rounded-md`}
>
<item.icon className="mr-3 h-6 w-6" />
{item.name}
</Link>
);
})}
</nav>
</div>
<div className="flex-shrink-0 flex border-t border-gray-200 p-4">
<div className="flex-shrink-0 w-full group block">
<div className="flex items-center">
<div className="ml-3">
<p className="text-sm font-medium text-gray-700 group-hover:text-gray-900">
{user?.firstName} {user?.lastName}
</p>
<p className="text-xs font-medium text-gray-500 group-hover:text-gray-700">
{user?.role}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
{/* Main content */}
<div className="lg:pl-64 flex flex-col flex-1">
<div className="sticky top-0 z-10 lg:hidden pl-1 pt-1 sm:pl-3 sm:pt-3 bg-gray-100">
<button
type="button"
className="-ml-0.5 -mt-0.5 h-12 w-12 inline-flex items-center justify-center rounded-md text-gray-500 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-primary-500"
onClick={() => setSidebarOpen(true)}
>
<Menu className="h-6 w-6" />
</button>
</div>
<main className="flex-1">
<div className="py-6">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<Outlet />
</div>
</div>
</main>
</div>
{/* Top bar for desktop */}
<div className="hidden lg:block lg:pl-64">
<div className="sticky top-0 z-10 flex-shrink-0 flex h-16 bg-white border-b border-gray-200">
<div className="flex-1 px-4 flex justify-between">
<div className="flex-1 flex">
<div className="w-full flex md:ml-0">
<div className="relative w-full text-gray-400 focus-within:text-gray-600">
<div className="absolute inset-y-0 left-0 flex items-center pointer-events-none">
<Bell className="h-5 w-5" />
</div>
</div>
</div>
</div>
<div className="ml-4 flex items-center md:ml-6">
<div className="ml-3 relative">
<div className="flex items-center space-x-4">
<Link
to="/profile"
className="flex items-center text-sm font-medium text-gray-700 hover:text-gray-900"
>
<User className="h-5 w-5 mr-2" />
Profile
</Link>
<button
onClick={handleLogout}
className="flex items-center text-sm font-medium text-gray-700 hover:text-gray-900"
>
<LogOut className="h-5 w-5 mr-2" />
Logout
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default Layout;
|