import { useRef, useState } from 'react'; import { NavLink } from 'react-router-dom'; import Arrow1 from './assets/arrow.svg'; import Arrow2 from './assets/dropdown-arrow.svg'; import Message from './assets/message.svg'; import Hamburger from './assets/hamburger.svg'; import Key from './assets/key.svg'; import Info from './assets/info.svg'; import Link from './assets/link.svg'; import { ActiveState } from './models/misc'; import APIKeyModal from './preferences/APIKeyModal'; import SelectDocsModal from './preferences/SelectDocsModal'; import { useDispatch, useSelector } from 'react-redux'; import { selectApiKeyStatus, selectSelectedDocs, selectSelectedDocsStatus, selectSourceDocs, setSelectedDocs, } from './preferences/preferenceSlice'; import { useOutsideAlerter } from './hooks'; export default function Navigation({ navState, setNavState, }: { navState: ActiveState; setNavState: React.Dispatch>; }) { const dispatch = useDispatch(); const docs = useSelector(selectSourceDocs); const selectedDocs = useSelector(selectSelectedDocs); const [isDocsListOpen, setIsDocsListOpen] = useState(false); const isApiKeySet = useSelector(selectApiKeyStatus); const [apiKeyModalState, setApiKeyModalState] = useState( isApiKeySet ? 'INACTIVE' : 'ACTIVE', ); const isSelectedDocsSet = useSelector(selectSelectedDocsStatus); const [selectedDocsModalState, setSelectedDocsModalState] = useState(isSelectedDocsSet ? 'INACTIVE' : 'ACTIVE'); const navRef = useRef(null); useOutsideAlerter( navRef, () => { if ( window.matchMedia('(max-width: 768px)').matches && navState === 'ACTIVE' && apiKeyModalState === 'INACTIVE' ) { setNavState('INACTIVE'); setIsDocsListOpen(false); } }, [navState, isDocsListOpen, apiKeyModalState], ); return ( <>
`${ isActive ? 'bg-gray-3000' : '' } my-auto mx-4 mt-4 flex h-12 cursor-pointer gap-4 rounded-md hover:bg-gray-100` } >

Chat

setIsDocsListOpen(!isDocsListOpen)} > {selectedDocs && (

{selectedDocs.name} {selectedDocs.version}

)} arrow
{isDocsListOpen && (
{docs ? ( docs.map((doc, index) => { if (doc.model) { return (
{ dispatch(setSelectedDocs(doc)); setIsDocsListOpen(false); }} className="h-10 w-full cursor-pointer border-x-2 border-b-2 hover:bg-gray-100" >

{doc.name} {doc.version}

); } }) ) : (

No default documentation.

)}
)}

Source Docs

{ setApiKeyModalState('ACTIVE'); }} > key

Reset Key

`my-auto mx-4 flex h-12 cursor-pointer gap-4 rounded-md hover:bg-gray-100 ${ isActive ? 'bg-gray-3000' : '' }` } > info

About

link

Discord

link

Github

); }