import React, { useEffect, useState } from 'react' import NavLink from './navLink' import type { NavIcon } from './navLink' import AppBasic from './basic' import AppInfo from './app-info' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { AlignLeft01, AlignRight01, } from '@/app/components/base/icons/src/vender/line/layout' import { useStore as useAppStore } from '@/app/components/app/store' export type IAppDetailNavProps = { iconType?: 'app' | 'dataset' | 'notion' title: string desc: string icon: string icon_background: string navigation: Array<{ name: string href: string icon: NavIcon selectedIcon: NavIcon }> extraInfo?: (modeState: string) => React.ReactNode } const AppDetailNav = ({ title, desc, icon, icon_background, navigation, extraInfo, iconType = 'app' }: IAppDetailNavProps) => { const { appSidebarExpand, setAppSiderbarExpand } = useAppStore() const media = useBreakpoints() const isMobile = media === MediaType.mobile const [modeState, setModeState] = useState(appSidebarExpand) const expand = modeState === 'expand' const handleToggle = (state: string) => { setAppSiderbarExpand(state === 'expand' ? 'collapse' : 'expand') } useEffect(() => { if (appSidebarExpand) { localStorage.setItem('app-detail-collapse-or-expand', appSidebarExpand) setModeState(appSidebarExpand) } }, [appSidebarExpand]) return (
{iconType === 'app' && ( )} {iconType !== 'app' && ( )}
{!expand && (
)} { !isMobile && (
handleToggle(modeState)} > { expand ? : }
) }
) } export default React.memo(AppDetailNav)