'use client'; import clsx from 'clsx'; import { useCallback } from 'react'; import { LocationIcon, SubscribeIcon, VisibilityIcon } from '@/components/DomainIcons'; import { IconEditor, IconFolder, IconOwner } from '@/components/Icons'; import BadgeHelp from '@/components/info/BadgeHelp'; import Dropdown from '@/components/ui/Dropdown'; import DropdownButton from '@/components/ui/DropdownButton'; import MiniButton from '@/components/ui/MiniButton'; import SearchBar from '@/components/ui/SearchBar'; import SelectorButton from '@/components/ui/SelectorButton'; import { useAuth } from '@/context/AuthContext'; import useDropdown from '@/hooks/useDropdown'; import { LocationHead } from '@/models/library'; import { HelpTopic } from '@/models/miscellaneous'; import { PARAMETER, prefixes } from '@/utils/constants'; import { describeLocationHead, labelLocationHead } from '@/utils/labels'; import { tripleToggleColor } from '@/utils/utils'; interface SearchPanelProps { total: number; filtered: number; query: string; setQuery: React.Dispatch>; path: string; setPath: React.Dispatch>; head: LocationHead | undefined; setHead: React.Dispatch>; isVisible: boolean | undefined; toggleVisible: () => void; isOwned: boolean | undefined; toggleOwned: () => void; isSubscribed: boolean | undefined; toggleSubscribed: () => void; isEditor: boolean | undefined; toggleEditor: () => void; } function SearchPanel({ total, filtered, query, setQuery, path, setPath, head, setHead, isVisible, toggleVisible, isOwned, toggleOwned, isSubscribed, toggleSubscribed, isEditor, toggleEditor }: SearchPanelProps) { const { user } = useAuth(); const headMenu = useDropdown(); const handleChange = useCallback( (newValue: LocationHead | undefined) => { headMenu.hide(); setHead(newValue); }, [headMenu, setHead] ); return (
{filtered} из {total}
{user ? (
} onClick={toggleVisible} /> } onClick={toggleSubscribed} /> } onClick={toggleOwned} /> } onClick={toggleEditor} />
) : null}
) : ( ) } onClick={headMenu.toggle} text={head ?? '//'} /> handleChange(undefined)}>
отображать все
{Object.values(LocationHead).map((head, index) => { return ( handleChange(head)} title={describeLocationHead(head)} >
{labelLocationHead(head)}
); })}
); } export default SearchPanel;