diff --git a/pkgs/ui/src/components/sidebar/index.tsx b/pkgs/ui/src/components/sidebar/index.tsx index 55bb214..227bd24 100644 --- a/pkgs/ui/src/components/sidebar/index.tsx +++ b/pkgs/ui/src/components/sidebar/index.tsx @@ -9,6 +9,7 @@ import { Tooltip, useMediaQuery, } from "@mui/material"; +import { useGetAllEntities } from "@/api/entities/entities"; import Image from "next/image"; import React, { ReactNode } from "react"; @@ -33,32 +34,7 @@ type MenuEntry = { subMenuEntries?: MenuEntry[]; }; -export const menuEntityEntries: MenuEntry[] = [ - { - icon: , - label: "C1", - to: "/client/C1", - disabled: false, - }, - { - icon: , - label: "C2", - to: "/client/C2", - disabled: false, - }, - { - icon: , - label: "C3", - to: "/client/C3", - disabled: false, - }, - { - icon: , - label: "C4", - to: "/client/C4", - disabled: false, - }, -]; +export let menuEntityEntries: MenuEntry[] = []; export const menuEntries: MenuEntry[] = [ { @@ -96,6 +72,7 @@ interface SidebarProps { } export function Sidebar(props: SidebarProps) { + const { data: entityData } = useGetAllEntities(); const { show, onClose } = props; const [activeMenuItem, setActiveMenuItem] = React.useState( typeof window !== "undefined" ? window.location.pathname : "", @@ -113,12 +90,22 @@ export function Sidebar(props: SidebarProps) { }; React.useEffect(() => { + if (entityData) { + menuEntityEntries = Array.isArray(entityData.data) + ? entityData.data.map((entity) => ({ + icon: , + label: entity.name, + to: `/client/${entity.name}`, + disabled: false, + })) + : []; + } if (isSmallerScreen) { setCollapseMenuOpen(false); } else { setCollapseMenuOpen(true); } - }, [isSmallerScreen]); + }, [isSmallerScreen, entityData]); return (