import { useState, useMemo } from 'react'; import { Settings } from 'lucide-react'; import type { FC } from 'react'; import type { TModelSpec, TEndpointsConfig } from 'librechat-data-provider'; import { SetKeyDialog } from '~/components/Input/SetKeyDialog'; import { useLocalize, useUserKey } from '~/hooks'; import { cn, getEndpointField } from '~/utils'; import SpecIcon from './SpecIcon'; type MenuItemProps = { title: string; spec: TModelSpec; selected: boolean; description?: string; userProvidesKey: boolean; endpointsConfig: TEndpointsConfig; onClick?: () => void; // iconPath: string; // hoverContent?: string; }; const MenuItem: FC = ({ title, spec, selected, description, userProvidesKey, endpointsConfig, onClick, ...rest }) => { const { endpoint } = spec.preset; const [isDialogOpen, setDialogOpen] = useState(false); const { getExpiry } = useUserKey(endpoint ?? ''); const localize = useLocalize(); const expiryTime = getExpiry(); const clickHandler = () => { if (!expiryTime) { setDialogOpen(true); } if (onClick) { onClick(); } }; const endpointType = useMemo( () => spec.preset.endpointType ?? getEndpointField(endpointsConfig, endpoint, 'type'), [spec, endpointsConfig, endpoint], ); const { showIconInMenu = true } = spec; return ( <>
{showIconInMenu && }
{title}
{description}
{userProvidesKey ? (
) : null} {selected && ( )}
{userProvidesKey && ( )} ); }; export default MenuItem;