import type { FC } from 'react' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiMoreFill, } from '@remixicon/react' import { useSelectOrDelete, useTrigger } from '../../hooks' import { UPDATE_HISTORY_EVENT_EMITTER } from '../../constants' import type { RoleName } from './index' import { DELETE_HISTORY_BLOCK_COMMAND } from './index' import { MessageClockCircle } from '@/app/components/base/icons/src/vender/solid/general' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' import { useEventEmitterContextContext } from '@/context/event-emitter' type HistoryBlockComponentProps = { nodeKey: string roleName?: RoleName onEditRole: () => void } const HistoryBlockComponent: FC = ({ nodeKey, roleName = { user: '', assistant: '' }, onEditRole, }) => { const { t } = useTranslation() const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_HISTORY_BLOCK_COMMAND) const [triggerRef, open, setOpen] = useTrigger() const { eventEmitter } = useEventEmitterContextContext() const [localRoleName, setLocalRoleName] = useState(roleName) eventEmitter?.useSubscription((v: any) => { if (v?.type === UPDATE_HISTORY_EVENT_EMITTER) setLocalRoleName(v.payload) }) return (
{t('common.promptEditor.history.item.title')}
{t('common.promptEditor.history.modal.title')}
{localRoleName?.user}
{t('common.promptEditor.history.modal.user')}
{localRoleName?.assistant}
{t('common.promptEditor.history.modal.assistant')}
{t('common.promptEditor.history.modal.edit')}
) } export default HistoryBlockComponent