You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

relevant-node.tsx 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { Handle, NodeProps, Position } from '@xyflow/react';
  2. import { Flex } from 'antd';
  3. import classNames from 'classnames';
  4. import { RightHandleStyle } from './handle-icon';
  5. import { useTheme } from '@/components/theme-provider';
  6. import { IRelevantNode } from '@/interfaces/database/flow';
  7. import { get } from 'lodash';
  8. import { useReplaceIdWithName } from '../../hooks';
  9. import styles from './index.less';
  10. import NodeHeader from './node-header';
  11. export function RelevantNode({ id, data, selected }: NodeProps<IRelevantNode>) {
  12. const yes = get(data, 'form.yes');
  13. const no = get(data, 'form.no');
  14. const replaceIdWithName = useReplaceIdWithName();
  15. const { theme } = useTheme();
  16. return (
  17. <section
  18. className={classNames(
  19. styles.logicNode,
  20. theme === 'dark' ? styles.dark : '',
  21. {
  22. [styles.selectedNode]: selected,
  23. },
  24. )}
  25. >
  26. <Handle
  27. type="target"
  28. position={Position.Left}
  29. isConnectable
  30. className={styles.handle}
  31. id={'a'}
  32. ></Handle>
  33. <Handle
  34. type="source"
  35. position={Position.Right}
  36. isConnectable
  37. className={styles.handle}
  38. id={'yes'}
  39. style={{ ...RightHandleStyle, top: 57 + 20 }}
  40. ></Handle>
  41. <Handle
  42. type="source"
  43. position={Position.Right}
  44. isConnectable
  45. className={styles.handle}
  46. id={'no'}
  47. style={{ ...RightHandleStyle, top: 115 + 20 }}
  48. ></Handle>
  49. <NodeHeader
  50. id={id}
  51. name={data.name}
  52. label={data.label}
  53. className={styles.nodeHeader}
  54. ></NodeHeader>
  55. <Flex vertical gap={10}>
  56. <Flex vertical>
  57. <div className={styles.relevantLabel}>Yes</div>
  58. <div className={styles.nodeText}>{replaceIdWithName(yes)}</div>
  59. </Flex>
  60. <Flex vertical>
  61. <div className={styles.relevantLabel}>No</div>
  62. <div className={styles.nodeText}>{replaceIdWithName(no)}</div>
  63. </Flex>
  64. </Flex>
  65. </section>
  66. );
  67. }