diff --git a/dashboard/src/components/page/index.tsx b/dashboard/src/components/page/index.tsx index 383e2fd..48eae7e 100644 --- a/dashboard/src/components/page/index.tsx +++ b/dashboard/src/components/page/index.tsx @@ -3,15 +3,10 @@ import { ScrollArea } from '@marzneshin/components' interface PageProps extends PropsWithChildren { } -/* WARN: The current page height which effect the scroll -* area activness, is calculated based on height of header -* and margin. -*/ - export const Page: FC = ({ children }) => { return ( - -
+ +
{children}
diff --git a/dashboard/src/features/bottom-menu/index.tsx b/dashboard/src/features/bottom-menu/index.tsx new file mode 100644 index 0000000..8957648 --- /dev/null +++ b/dashboard/src/features/bottom-menu/index.tsx @@ -0,0 +1,76 @@ +import { Button, SidebarItem } from "@marzneshin/components"; +import i18n from "@marzneshin/features/i18n"; +import { Link } from "@tanstack/react-router"; +import { FC } from "react"; +import { Box, Home, Server, ServerCog, UsersIcon } from 'lucide-react'; +import { useIsCurrentRoute } from "@marzneshin/hooks"; + +type BottomMenuItemProps = Omit + +const BottomMenuItem: FC = ({ title, icon, to, active }) => { + return ( + + ) +} + +const adminItems: BottomMenuItemProps[] = [ + { + title: i18n.t('users'), + to: '/users', + icon: , + }, + { + title: i18n.t('home'), + to: '/', + icon: , + }, +] + +const sudoAdminItems: BottomMenuItemProps[] = [ + { + title: i18n.t('users'), + to: '/users', + icon: , + }, + { + title: i18n.t('services'), + to: '/services', + icon: , + }, + { + title: i18n.t('home'), + to: '/', + icon: , + }, + { + title: i18n.t('nodes'), + to: '/nodes', + icon: , + }, + { + title: i18n.t('hosts'), + to: '/hosts', + icon: , + }, +] + +export const DashboardBottomMenu = ({ variant = "admin" }: { variant: "sudo-admin" | "admin" }) => { + const { isCurrentRouteActive } = useIsCurrentRoute() + const items = variant === "sudo-admin" ? sudoAdminItems : adminItems; + return ( +
+ {items.map((item: BottomMenuItemProps) => ( + + ))} +
+ ) +} + diff --git a/dashboard/src/features/sidebar/sidebar.tsx b/dashboard/src/features/sidebar/sidebar.tsx index afa1fdb..637fb2d 100644 --- a/dashboard/src/features/sidebar/sidebar.tsx +++ b/dashboard/src/features/sidebar/sidebar.tsx @@ -2,7 +2,7 @@ import { Sidebar, type SidebarItem, } from "@marzneshin/components"; -import { useRouterState } from "@tanstack/react-router"; +import { useIsCurrentRoute } from "@marzneshin/hooks"; import type { FC } from "react"; import { sidebarItems as sidebarItemsSudoAdmin, sidebarItemsNonSudoAdmin } from "."; import { cn } from "@marzneshin/utils"; @@ -24,15 +24,8 @@ export const DashboardSidebar: FC = ({ setOpen, open, }) => { - const router = useRouterState(); const { isSudo } = useAuth(); - const currentActivePath = router.location.pathname; - const isActive = (path: string) => { - if (path === "/") { - return currentActivePath === path; - } - return currentActivePath.startsWith(path); - }; + const { isCurrentRouteActive } = useIsCurrentRoute() const sidebarItems = isSudo() ? sidebarItemsSudoAdmin : sidebarItemsNonSudoAdmin return (