2024-02-28 00:39:05 +03:00
|
|
|
import Logo from "../Logo";
|
|
|
|
|
import NavItem from "./NavItem";
|
2024-03-05 02:18:30 +03:00
|
|
|
import { CameraGroupSelector } from "../filter/CameraGroupSelector";
|
2024-07-10 18:28:05 +03:00
|
|
|
import { Link, useMatch } from "react-router-dom";
|
2024-04-19 14:34:07 +03:00
|
|
|
import GeneralSettings from "../menu/GeneralSettings";
|
|
|
|
|
import AccountSettings from "../menu/AccountSettings";
|
2024-04-11 23:54:09 +03:00
|
|
|
import useNavigation from "@/hooks/use-navigation";
|
2024-07-09 22:36:55 +03:00
|
|
|
import { baseUrl } from "@/api/baseUrl";
|
|
|
|
|
import { useMemo } from "react";
|
2024-02-28 00:39:05 +03:00
|
|
|
|
|
|
|
|
function Sidebar() {
|
2024-07-09 22:36:55 +03:00
|
|
|
const basePath = useMemo(() => new URL(baseUrl).pathname, []);
|
2024-03-05 02:18:30 +03:00
|
|
|
|
2024-07-10 18:28:05 +03:00
|
|
|
const isRootMatch = useMatch("/");
|
|
|
|
|
const isBasePathMatch = useMatch(basePath);
|
|
|
|
|
|
2024-04-11 23:54:09 +03:00
|
|
|
const navbarLinks = useNavigation();
|
|
|
|
|
|
2024-02-28 00:39:05 +03:00
|
|
|
return (
|
2024-06-03 21:43:30 +03:00
|
|
|
<aside className="scrollbar-container scrollbar-hidden absolute inset-y-0 left-0 z-10 flex w-[52px] flex-col justify-between overflow-y-auto border-r border-secondary-highlight bg-background_alt py-4">
|
2024-02-28 00:39:05 +03:00
|
|
|
<span tabIndex={0} className="sr-only" />
|
2024-05-14 18:06:44 +03:00
|
|
|
<div className="flex w-full flex-col items-center gap-0">
|
2024-07-10 18:28:05 +03:00
|
|
|
<Link to="/">
|
|
|
|
|
<Logo className="mb-6 h-8 w-8" />
|
|
|
|
|
</Link>
|
2024-03-06 03:39:37 +03:00
|
|
|
{navbarLinks.map((item) => {
|
|
|
|
|
const showCameraGroups =
|
2024-07-10 18:28:05 +03:00
|
|
|
(isRootMatch || isBasePathMatch) && item.id === 1;
|
2024-03-06 03:39:37 +03:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div key={item.id}>
|
|
|
|
|
<NavItem
|
|
|
|
|
className={`mx-[10px] ${showCameraGroups ? "mb-2" : "mb-4"}`}
|
2024-04-11 23:54:09 +03:00
|
|
|
item={item}
|
2024-03-06 03:39:37 +03:00
|
|
|
Icon={item.icon}
|
|
|
|
|
/>
|
|
|
|
|
{showCameraGroups && <CameraGroupSelector className="mb-4" />}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2024-02-28 00:39:05 +03:00
|
|
|
</div>
|
2024-05-14 18:06:44 +03:00
|
|
|
<div className="mb-8 flex flex-col items-center gap-4">
|
2024-04-01 18:31:31 +03:00
|
|
|
<GeneralSettings />
|
|
|
|
|
<AccountSettings />
|
|
|
|
|
</div>
|
2024-02-28 00:39:05 +03:00
|
|
|
</aside>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Sidebar;
|