import { useState } from 'react'; import { Settings } from 'lucide-react'; import { EModelEndpoint } from 'librechat-data-provider'; import type { FC } from 'react'; import { useLocalize, useUserKey } from '~/hooks'; import { SetKeyDialog } from '~/components/Input/SetKeyDialog'; import { useChatContext } from '~/Providers'; import { icons } from './Icons'; import { cn } from '~/utils'; type MenuItemProps = { title: string; value: EModelEndpoint; selected: boolean; description?: string; userProvidesKey: boolean; // iconPath: string; // hoverContent?: string; }; const MenuItem: FC = ({ title, value: endpoint, description, selected, userProvidesKey, ...rest }) => { const Icon = icons[endpoint] ?? icons.unknown; const [isDialogOpen, setDialogOpen] = useState(false); const { newConversation } = useChatContext(); const { getExpiry } = useUserKey(endpoint); const localize = useLocalize(); const expiryTime = getExpiry(); const onSelectEndpoint = (newEndpoint: EModelEndpoint) => { if (!newEndpoint) { return; } else { if (!expiryTime) { setDialogOpen(true); } newConversation({ template: { endpoint: newEndpoint, conversationId: 'new' } }); } }; return ( <>
onSelectEndpoint(endpoint)} >
{}
{title}
{description}
{userProvidesKey ? (
) : null} {selected && ( )} {(!userProvidesKey || expiryTime) && (
{!userProvidesKey &&
{localize('com_ui_new_chat')}
}
)}
{userProvidesKey && ( )} ); }; export default MenuItem;