wwf
2 天以前 a430284aa21e3ae1f0d5654e55b2ad2852519cc2
app/components/workflow/nodes/question-classifier/components/class-list.tsx
@@ -7,24 +7,21 @@
import AddButton from '../../_base/components/add-button'
import Item from './class-item'
import type { Topic } from '@/app/components/workflow/nodes/question-classifier/types'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
const i18nPrefix = 'workflow.nodes.questionClassifiers'
type Props = {
  nodeId: string
  id: string
  list: Topic[]
  onChange: (list: Topic[]) => void
  readonly?: boolean
  filterVar: (payload: Var, valueSelector: ValueSelector) => boolean
}
const ClassList: FC<Props> = ({
  nodeId,
  id,
  list,
  onChange,
  readonly,
  filterVar,
}) => {
  const { t } = useTranslation()
  const { handleEdgeDeleteByDeleteBranch } = useEdgesInteractions()
@@ -47,13 +44,13 @@
  const handleRemoveClass = useCallback((index: number) => {
    return () => {
      handleEdgeDeleteByDeleteBranch(nodeId, list[index].id)
      handleEdgeDeleteByDeleteBranch(id, list[index].id)
      const newList = produce(list, (draft) => {
        draft.splice(index, 1)
      })
      onChange(newList)
    }
  }, [list, onChange, handleEdgeDeleteByDeleteBranch, nodeId])
  }, [list, onChange, handleEdgeDeleteByDeleteBranch, id])
  // Todo Remove; edit topic name
  return (
@@ -62,14 +59,12 @@
        list.map((item, index) => {
          return (
            <Item
              nodeId={nodeId}
              key={list[index].id}
              key={index}
              payload={item}
              onChange={handleClassChange(index)}
              onRemove={handleRemoveClass(index)}
              index={index + 1}
              readonly={readonly}
              filterVar={filterVar}
            />
          )
        })