68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
"use client"; // components/Navigation.jsx
|
|
import React, { useEffect, useState } from "react";
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
|
|
interface NavigationProps {
|
|
className?: string;
|
|
}
|
|
|
|
const Navigation: React.FC<NavigationProps> = ({ className }) => {
|
|
const pathname = usePathname();
|
|
const [activeLink, setActiveLink] = useState("");
|
|
|
|
useEffect(() => {
|
|
if (pathname) {
|
|
setActiveLink(pathname);
|
|
}
|
|
}, [pathname]);
|
|
|
|
const formatPath = (path: string) => {
|
|
return process.env.NODE_ENV === "production" ? `${path}.html` : path;
|
|
};
|
|
|
|
const menuItems = [
|
|
{ name: "Übersicht", path: "/dashboardPage" },
|
|
{ name: "Kabelüberwachung ", path: "/kabelueberwachungPage" },
|
|
{ name: "Meldungseingänge ", path: "/digitalInputsPage" }, //vorher Digitale Ein -und Ausgänge
|
|
{ name: "Schaltausgänge ", path: "/digitalOutputsPage", disabled: false }, //vorher Digitale Ein -und Ausgänge
|
|
{ name: "Messwertüberwachung ", path: "/analogeEingaengePage" }, //vorher Analoge Eingänge
|
|
{ name: "Berichte ", path: "/meldungenPage" },
|
|
{ name: "System ", path: "/systemPage" },
|
|
{ name: "Einstellungen ", path: "/einstellungenPage" },
|
|
//{ name: "Zutriffskontrolle", path: "/zutrittskontrolle" },
|
|
|
|
// Weitere Menüpunkte hier
|
|
];
|
|
|
|
return (
|
|
<aside>
|
|
<nav className={`h-full flex-shrink-0 mt-16 ${className || "w-48"}`}>
|
|
{menuItems.map((item) => (
|
|
<div key={item.name}>
|
|
{item.disabled ? (
|
|
<div className="block px-4 py-2 mb-4 font-bold whitespace-nowrap text-gray-400 cursor-not-allowed text-[1rem] sm:text-[1rem] md:text-[1rem] lg:text-[1rem] xl:text-sm 2xl:text-lg">
|
|
{item.name}
|
|
</div>
|
|
) : (
|
|
<Link href={formatPath(item.path)}>
|
|
<div
|
|
className={`block px-4 py-2 mb-4 font-bold whitespace-nowrap transition duration-300 text-[1rem] sm:text-[1rem] md:text-[1rem] lg:text-[1rem] xl:text-sm 2xl:text-lg ${
|
|
activeLink.startsWith(item.path)
|
|
? "bg-sky-500 text-white rounded-r-full xl:mr-4 xl:w-full"
|
|
: "text-black hover:bg-gray-200 rounded-r-full"
|
|
}`}
|
|
>
|
|
{item.name}
|
|
</div>
|
|
</Link>
|
|
)}
|
|
</div>
|
|
))}
|
|
</nav>
|
|
</aside>
|
|
);
|
|
};
|
|
|
|
export default Navigation;
|