'use client' import type { FC } from 'react' import React, { useEffect, useRef, useState } from 'react' import { RiDeleteBinLine, RiEditLine, } from '@remixicon/react' import { useTranslation } from 'react-i18next' import { useBoolean } from 'ahooks' import { Pin02 } from '../../base/icons/src/vender/line/general' import s from './style.module.css' import cn from '@/utils/classnames' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '@/app/components/base/portal-to-follow-elem' export type IItemOperationProps = { className?: string isItemHovering?: boolean isPinned: boolean isShowRenameConversation?: boolean onRenameConversation?: () => void isShowDelete: boolean togglePin: () => void onDelete: () => void } const ItemOperation: FC = ({ className, isItemHovering, isPinned, togglePin, isShowRenameConversation, onRenameConversation, isShowDelete, onDelete, }) => { const { t } = useTranslation() const [open, setOpen] = useState(false) const ref = useRef(null) const [isHovering, { setTrue: setIsHovering, setFalse: setNotHovering }] = useBoolean(false) useEffect(() => { if (!isItemHovering && !isHovering) setOpen(false) }, [isItemHovering, isHovering]) return ( setOpen(v => !v)} >
{ e.stopPropagation() }} >
{isPinned ? t('explore.sidebar.action.unpin') : t('explore.sidebar.action.pin')}
{isShowRenameConversation && (
{t('explore.sidebar.action.rename')}
)} {isShowDelete && (
{t('explore.sidebar.action.delete')}
)}
) } export default React.memo(ItemOperation)