diff --git a/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx b/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx index 14ff0f3..8493cd1 100644 --- a/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx +++ b/packages/frontend/src/components/shared/Sidebar/Sidebar.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { NavLink, useNavigate, useParams } from 'react-router-dom'; import { Organization, User } from 'gql-client'; import { motion } from 'framer-motion'; @@ -10,12 +10,10 @@ import { useGQLClient } from 'context/GQLClientContext'; import AsyncSelect from 'components/shared/AsyncSelect'; import { ChevronGrabberHorizontal, - FolderIcon, GlobeIcon, LifeBuoyIcon, LogoutIcon, QuestionMarkRoundIcon, - SettingsSlidersIcon, } from 'components/shared/CustomIcon'; import { Tabs } from 'components/shared/Tabs'; import { Logo } from 'components/Logo'; @@ -25,6 +23,7 @@ import { getInitials } from 'utils/geInitials'; import { Button } from 'components/shared/Button'; import { cn } from 'utils/classnames'; import { useMediaQuery } from 'usehooks-ts'; +import { SIDEBAR_MENU } from './constants'; interface SidebarProps { mobileOpen?: boolean; @@ -61,11 +60,39 @@ export const Sidebar = ({ mobileOpen }: SidebarProps) => { setSelectedOrgSlug(orgSlug); }, [orgSlug]); + const renderOrganizations = useMemo(() => { + return organizations.map((org) => ( + + )); + }, [organizations]); + + const renderMenu = useMemo(() => { + return SIDEBAR_MENU(orgSlug).map(({ title, icon, url }, index) => ( + + + {title} + + + )); + }, [orgSlug]); + const handleLogOut = useCallback(() => { disconnect(); navigate('/login'); }, [disconnect, navigate]); - console.log(isDesktop); + return ( { } > {/* // TODO: Show label organization and manage in option */} - {organizations.map((org) => ( - - ))} + {renderOrganizations} - - {[ - { - title: 'Projects', - url: `/${orgSlug}/`, - icon: , - }, - { - title: 'Settings', - url: `/${orgSlug}/settings`, - icon: , - }, - ].map(({ title, icon, url }, index) => ( - - - {title} - - - ))} - + {renderMenu} {/* Bottom navigation */} diff --git a/packages/frontend/src/components/shared/Sidebar/constants.tsx b/packages/frontend/src/components/shared/Sidebar/constants.tsx new file mode 100644 index 0000000..6c30310 --- /dev/null +++ b/packages/frontend/src/components/shared/Sidebar/constants.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { FolderIcon, SettingsSlidersIcon } from 'components/shared/CustomIcon'; + +export const SIDEBAR_MENU = (orgSlug?: string) => [ + { + title: 'Projects', + url: `/${orgSlug}/`, + icon: , + }, + { + title: 'Settings', + url: `/${orgSlug}/settings`, + icon: , + }, +];