import type { JSX } from 'react'
import { cloneElement, useCallback } from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import Button from '@/app/components/base/button'
import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger } from '../base/portal-to-follow-elem'
import Divider from '@/app/components/base/divider'
import { RiMoreFill } from '@remixicon/react'
import cn from '@/utils/classnames'
export type Operation = {
id: string
title: string
icon: JSX.Element
onClick: () => void
type?: 'action' | 'divider'
className?: string
}
const AppOperations = ({ primaryOperations, secondaryOperations, gap }: {
primaryOperations: Operation[]
secondaryOperations: Operation[]
gap: number
}) => {
const { t } = useTranslation()
const [showMore, setShowMore] = useState(false)
const handleTriggerMore = useCallback(() => {
setShowMore(prev => !prev)
}, [])
const renderSecondaryOperation = (operation: Operation, index: number) => {
if (operation.type === 'divider') {
return (