Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.3 KB
Raw Blame
import type { ChatTopicStatus } from '@lobechat/types';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

import NavItem from '@/features/NavPanel/components/NavItem';

import Actions from './Actions';
import { useDropdownMenu } from './useDropdownMenu';

interface TopicItemProps {
  active: boolean;
  agentId?: string;
  fav?: boolean;
  onClose: () => void;
  onDelete?: (topicId: string) => void;
  onTopicChange: (topicId: string) => void;
  status?: ChatTopicStatus | null;
  topicId: string;
  topicTitle: string;
}

const TopicItem = memo<TopicItemProps>(
  ({ active, agentId, fav, onClose, onDelete, onTopicChange, status, topicId, topicTitle }) => {
    const { t } = useTranslation('topic');

    const dropdownMenu = useDropdownMenu({
      agentId,
      fav,
      onClose,
      onDelete,
      status,
      topicId,
      topicTitle,
    });

    return (
      <NavItem
        actions={<Actions dropdownMenu={dropdownMenu} />}
        active={active}
        contextMenuItems={dropdownMenu}
        style={{ flexShrink: 0 }}
        title={topicTitle || t('untitled', { defaultValue: 'Untitled' })}
        onClick={() => {
          onTopicChange(topicId);
          onClose();
        }}
      />
    );
  },
);

export default TopicItem;