Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import { useNodes } from 'reactflow'
  4. import { useTranslation } from 'react-i18next'
  5. import type { DocExtractorNodeType } from './types'
  6. import { isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils'
  7. import { BlockEnum, type Node, type NodeProps } from '@/app/components/workflow/types'
  8. import {
  9. VariableLabelInNode,
  10. } from '@/app/components/workflow/nodes/_base/components/variable/variable-label'
  11. const i18nPrefix = 'workflow.nodes.docExtractor'
  12. const NodeComponent: FC<NodeProps<DocExtractorNodeType>> = ({
  13. data,
  14. }) => {
  15. const { t } = useTranslation()
  16. const nodes: Node[] = useNodes()
  17. const { variable_selector: variable } = data
  18. if (!variable || variable.length === 0)
  19. return null
  20. const isSystem = isSystemVar(variable)
  21. const node = isSystem ? nodes.find(node => node.data.type === BlockEnum.Start) : nodes.find(node => node.id === variable[0])
  22. return (
  23. <div className='relative px-3'>
  24. <div className='system-2xs-medium-uppercase mb-1 text-text-tertiary'>{t(`${i18nPrefix}.inputVar`)}</div>
  25. <VariableLabelInNode
  26. variables={variable}
  27. nodeType={node?.data.type}
  28. nodeTitle={node?.data.title}
  29. />
  30. </div>
  31. )
  32. }
  33. export default React.memo(NodeComponent)