import { useCallback } from 'react'; import { BookmarkPlusIcon } from 'lucide-react'; import type { FC } from 'react'; import type { TConversation } from 'librechat-data-provider'; import { BookmarkItems, BookmarkEditDialog } from '~/components/Bookmarks'; import { useTagConversationMutation } from '~/data-provider'; import { NotificationSeverity } from '~/common'; import { useToastContext } from '~/Providers'; import { useLocalize } from '~/hooks'; export const BookmarkMenuItems: FC<{ conversation: TConversation; tags: string[]; setTags: (tags: string[]) => void; setConversation: (conversation: TConversation) => void; }> = ({ conversation, tags, setTags, setConversation }) => { const { showToast } = useToastContext(); const localize = useLocalize(); const { mutateAsync } = useTagConversationMutation(conversation?.conversationId ?? ''); const handleSubmit = useCallback( async (tag: string): Promise => { if (tags !== undefined && conversation?.conversationId) { const newTags = tags.includes(tag) ? tags.filter((t) => t !== tag) : [...tags, tag]; await mutateAsync( { conversationId: conversation.conversationId, tags: newTags, }, { onSuccess: (newTags: string[]) => { setTags(newTags); setConversation({ ...conversation, tags: newTags }); }, onError: () => { showToast({ message: 'Error adding bookmark', severity: NotificationSeverity.ERROR, }); }, }, ); } }, [tags, conversation], ); return (
{localize('com_ui_bookmarks_new')}
} /> } /> ); };