2024-02-27 14:39:05 -07:00
|
|
|
import Logo from "../Logo";
|
|
|
|
|
import NavItem from "./NavItem";
|
2024-03-04 16:18:30 -07:00
|
|
|
import { CameraGroupSelector } from "../filter/CameraGroupSelector";
|
2024-07-10 10:28:05 -05:00
|
|
|
import { Link, useMatch } from "react-router-dom";
|
2024-04-19 06:34:07 -05:00
|
|
|
import GeneralSettings from "../menu/GeneralSettings";
|
|
|
|
|
import AccountSettings from "../menu/AccountSettings";
|
2024-04-11 14:54:09 -06:00
|
|
|
import useNavigation from "@/hooks/use-navigation";
|
2024-07-09 14:36:55 -05:00
|
|
|
import { baseUrl } from "@/api/baseUrl";
|
|
|
|
|
import { useMemo } from "react";
|
2024-02-27 14:39:05 -07:00
|
|
|
|
|
|
|
|
function Sidebar() {
|
2024-07-09 14:36:55 -05:00
|
|
|
const basePath = useMemo(() => new URL(baseUrl).pathname, []);
|
2024-03-04 16:18:30 -07:00
|
|
|
|
2024-07-10 10:28:05 -05:00
|
|
|
const isRootMatch = useMatch("/");
|
|
|
|
|
const isBasePathMatch = useMatch(basePath);
|
|
|
|
|
|
2024-04-11 14:54:09 -06:00
|
|
|
const navbarLinks = useNavigation();
|
|
|
|
|
|
2024-02-27 14:39:05 -07:00
|
|
|
return (
|
2024-06-03 13:43:30 -05: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-27 14:39:05 -07:00
|
|
|
<span tabIndex={0} className="sr-only" />
|
2024-05-14 10:06:44 -05:00
|
|
|
<div className="flex w-full flex-col items-center gap-0">
|
2024-07-10 10:28:05 -05:00
|
|
|
<Link to="/">
|
|
|
|
|
<Logo className="mb-6 h-8 w-8" />
|
|
|
|
|
</Link>
|
2024-03-05 17:39:37 -07:00
|
|
|
{navbarLinks.map((item) => {
|
|
|
|
|
const showCameraGroups =
|
2024-07-10 10:28:05 -05:00
|
|
|
(isRootMatch || isBasePathMatch) && item.id === 1;
|
2024-03-05 17:39:37 -07:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div key={item.id}>
|
|
|
|
|
<NavItem
|
|
|
|
|
className={`mx-[10px] ${showCameraGroups ? "mb-2" : "mb-4"}`}
|
2024-04-11 14:54:09 -06:00
|
|
|
item={item}
|
2024-03-05 17:39:37 -07:00
|
|
|
Icon={item.icon}
|
|
|
|
|
/>
|
|
|
|
|
{showCameraGroups && <CameraGroupSelector className="mb-4" />}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2024-02-27 14:39:05 -07:00
|
|
|
</div>
|
2024-05-14 10:06:44 -05:00
|
|
|
<div className="mb-8 flex flex-col items-center gap-4">
|
2024-04-01 09:31:31 -06:00
|
|
|
<GeneralSettings />
|
|
|
|
|
<AccountSettings />
|
|
|
|
|
</div>
|
2024-02-27 14:39:05 -07:00
|
|
|
</aside>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Sidebar;
|