'use client' import type { FC } from 'react' import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' import { RiDeleteBinLine, } from '@remixicon/react' import type { Topic } from '../types' import TextEditor from '../../_base/components/editor/text-editor' const i18nPrefix = 'workflow.nodes.questionClassifiers' type Props = { payload: Topic onChange: (payload: Topic) => void onRemove: () => void index: number readonly?: boolean } const ClassItem: FC = ({ payload, onChange, onRemove, index, readonly, }) => { const { t } = useTranslation() const handleNameChange = useCallback((value: string) => { onChange({ ...payload, name: value }) }, [onChange, payload]) return (
{`${t(`${i18nPrefix}.class`)} ${index}`}
} value={payload.name} onChange={handleNameChange} placeholder={t(`${i18nPrefix}.topicPlaceholder`)!} headerRight={(
{payload.name.length}
{!readonly && ( )}
)} readonly={readonly} minHeight={64} /> ) } export default React.memo(ClassItem)