EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
Sidebar.tsx
Go to the documentation of this file.
1"use client";
2import Link from "next/link";
3import { usePathname } from "next/navigation";
4
5interface SidebarProps {
6 currentPage: string;
7}
8
9const menuItems = [
10 { name: "Home", path: "/pages/home", icon: "🏠" },
11 { name: "Sales", path: "/pages/sales", icon: "💰" },
12 { name: "Products", path: "/pages/products", icon: "📦" },
13 { name: "Customers", path: "/pages/customers", icon: "👥" },
14 { name: "Reports", path: "/pages/reports", icon: "📊" },
15 { name: "Stores", path: "/pages/stores", icon: "🏪" },
16];
17
18export default function Sidebar({ currentPage }: SidebarProps) {
19 const pathname = usePathname();
20
21 return (
22 <div className="bg-white shadow-lg w-64 min-h-screen flex flex-col">
23 {/* Header */}
24 <div className="p-6 border-b">
25 <h1 className="text-xl font-bold text-gray-800">EverydayPOS</h1>
26 <p className="text-sm text-gray-600">Point of Sale System</p>
27 </div>
28
29 {/* Navigation */}
30 <nav className="flex-1 p-4">
31 <ul className="space-y-2">
32 {menuItems.map((item) => {
33 const isActive = currentPage === item.name.toLowerCase() || pathname === item.path;
34 return (
35 <li key={item.name}>
36 <Link
37 href={item.path}
38 className={`flex items-center p-3 rounded-lg transition-colors ${
39 isActive
40 ? "bg-blue-100 text-blue-700 border-r-4 border-blue-700"
41 : "text-gray-700 hover:bg-gray-100"
42 }`}
43 >
44 <span className="mr-3 text-lg">{item.icon}</span>
45 <span className="font-medium">{item.name}</span>
46 </Link>
47 </li>
48 );
49 })}
50 </ul>
51 </nav>
52
53 {/* Footer */}
54 <div className="p-4 border-t">
55 <Link
56 href="/"
57 className="flex items-center p-2 text-gray-600 hover:text-gray-800 transition-colors"
58 >
59 <span className="mr-2">🚪</span>
60 <span>Logout</span>
61 </Link>
62 </div>
63 </div>
64 );
65}