import React from 'react' import { useAtomValue, useSetAtom } from 'jotai' import { MainViewState, getMainViewStateAtom, setMainViewStateAtom, } from '@helpers/atoms/MainView.atom' import CompactLogo from '@containers/Logo/CompactLogo' import { MessageCircle, Settings, Bot, LayoutGrid, CpuIcon, BookOpen, } from 'lucide-react' import { motion as m, Variants } from 'framer-motion' import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels' import { twMerge } from 'tailwind-merge' import { showingBotListModalAtom } from '@helpers/atoms/Modal.atom' import useGetBots from '@hooks/useGetBots' import { useUserConfigs } from '@hooks/useUserConfigs' export const SidebarLeft = () => { const [config] = useUserConfigs() const currentState = useAtomValue(getMainViewStateAtom) const setMainViewState = useSetAtom(setMainViewStateAtom) const setBotListModal = useSetAtom(showingBotListModalAtom) const { downloadedModels } = useGetDownloadedModels() const { getAllBots } = useGetBots() const onMenuClick = (mainViewState: MainViewState) => { if (currentState === mainViewState) return setMainViewState(mainViewState) } const onBotListClick = async () => { const bots = await getAllBots() if (!bots || bots?.length === 0) { alert('You have not created any bot') return } if (downloadedModels.length === 0) { alert('You have no model downloaded') return } setBotListModal(true) } const variant: Variants = { hide: { opacity: 0, display: 'none', transition: { delay: 0, }, }, show: { opacity: 1, display: 'inline-block', transition: { duration: 0.5, delay: 0.4, }, }, } const menus = [ { name: 'Getting Started', icon: , state: MainViewState.Welcome, }, { name: 'Chat', icon: , state: MainViewState.Conversation, }, { name: 'Explore Models', icon: , state: MainViewState.ExploreModel, }, { name: 'My Models', icon: , state: MainViewState.MyModel, }, { name: 'Bot', icon: , state: MainViewState.CreateBot, }, { name: 'Settings', icon: , state: MainViewState.Setting, }, ] return ( {menus.map((menu, i) => { const isActive = currentState === menu.state const isBotMenu = menu.name === 'Bot' return ( isBotMenu ? onBotListClick() : onMenuClick(menu.state) } > {menu.icon} {menu.name} {isActive ? ( ) : null} ) })} window.coreAPI?.openExternalUrl( 'https://discord.gg/AsJ8krTT3N' ) } className="block text-xs font-semibold text-muted-foreground" > Discord window.coreAPI?.openExternalUrl( 'https://twitter.com/janhq_' ) } className="block text-xs font-semibold text-muted-foreground" > Twitter ) }