71 lines
2.7 KiB
TypeScript
71 lines
2.7 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: "/dashboard" },
|
|
{ name: "Kabelüberwachung ", path: "/kabelueberwachung" },
|
|
{ name: "Meldungseingänge ", path: "/digitalInputs" }, //vorher Digitale Ein -und Ausgänge
|
|
{ name: "Schaltausgänge ", path: "/digitalOutputs", disabled: false }, //vorher Digitale Ein -und Ausgänge
|
|
{ name: "Messwerteingänge ", path: "/analogInputs" }, //vorher Analoge Eingänge
|
|
{ name: "Berichte ", path: "/meldungen" },
|
|
{ name: "System ", path: "/system" },
|
|
{ name: "Einstellungen ", path: "/einstellungen" },
|
|
//{ name: "Zutriffskontrolle", path: "/zutrittskontrolle" },
|
|
|
|
// Weitere Menüpunkte hier
|
|
];
|
|
|
|
return (
|
|
<aside className="h-full bg-[var(--color-surface)] dark:bg-[var(--color-surface)] ">
|
|
<nav className={`h-full flex-shrink-0 mt-24 ${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-[var(--color-fg-muted)] opacity-60 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)}
|
|
prefetch={false}
|
|
onClick={() => setActiveLink(item.path)}
|
|
className={`block px-4 py-2 mb-4 font-semibold whitespace-nowrap transition duration-200 rounded-r-full pr-6 relative text-[1rem] sm:text-[1rem] md:text-[1rem] lg:text-[1rem] xl:text-sm 2xl:text-lg
|
|
${
|
|
activeLink.startsWith(item.path)
|
|
? "bg-[var(--color-accent)] text-white shadow-sm xl:mr-4 xl:w-full"
|
|
: "text-[var(--color-fg-muted)] hover:text-[var(--color-fg)] hover:bg-[var(--color-surface-alt)]/80 dark:hover:bg-[var(--color-surface-alt)]/40"
|
|
}
|
|
`}
|
|
>
|
|
{item.name}
|
|
</Link>
|
|
)}
|
|
</div>
|
|
))}
|
|
</nav>
|
|
</aside>
|
|
);
|
|
};
|
|
|
|
export default Navigation;
|