Fixed the issue where variables were not displayed in the switch operator #3221 (#8601)

### What problem does this PR solve?

Feat: Fixed the issue where variables were not displayed in the switch
operator #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-07-01 15:52:14 +08:00
committed by GitHub
parent 1c77b4ed9b
commit 6b04b07eb4
7 changed files with 154 additions and 122 deletions

View File

@ -4,7 +4,7 @@ import { ISwitchCondition, ISwitchNode } from '@/interfaces/database/flow';
import { NodeProps, Position } from '@xyflow/react';
import { memo, useCallback } from 'react';
import { NodeHandleId, SwitchOperatorOptions } from '../../constant';
import { useGetComponentLabelByValue } from '../../hooks/use-get-begin-query';
import { useGetVariableLabelByValue } from '../../hooks/use-get-begin-query';
import { CommonHandle } from './handle';
import { RightHandleStyle } from './handle-icon';
import NodeHeader from './node-header';
@ -25,12 +25,9 @@ const getConditionKey = (idx: number, length: number) => {
const ConditionBlock = ({
condition,
nodeId,
}: {
condition: ISwitchCondition;
nodeId: string;
}) => {
}: { condition: ISwitchCondition } & { nodeId: string }) => {
const items = condition?.items ?? [];
const getLabel = useGetComponentLabelByValue(nodeId);
const getLabel = useGetVariableLabelByValue(nodeId);
const renderOperatorIcon = useCallback((operator?: string) => {
const name = SwitchOperatorOptions.find((x) => x.value === operator)?.icon;
@ -83,8 +80,8 @@ function InnerSwitchNode({ id, data, selected }: NodeProps<ISwitchNode>) {
</div>
{position.condition && (
<ConditionBlock
nodeId={id}
condition={position.condition}
nodeId={id}
></ConditionBlock>
)}
</section>