Feat: Connect conditional operators to other operators #3221 (#8231)

### What problem does this PR solve?

Feat: Connect conditional operators to other operators #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-13 09:30:34 +08:00
committed by GitHub
parent 99725444f1
commit a9d9215547
11 changed files with 156 additions and 98 deletions

View File

@ -135,24 +135,6 @@ export const useBuildVariableOptions = (nodeId?: string) => {
return options;
};
export const useGetComponentLabelByValue = (nodeId: string) => {
const options = useBuildVariableOptions(nodeId);
const flattenOptions = useMemo(() => {
return options.reduce<DefaultOptionType[]>((pre, cur) => {
return [...pre, ...cur.options];
}, []);
}, [options]);
const getLabel = useCallback(
(val?: string) => {
return flattenOptions.find((x) => x.value === val)?.label;
},
[flattenOptions],
);
return getLabel;
};
export function useBuildQueryVariableOptions() {
const { data } = useFetchAgent();
const node = useContext(AgentFormContext);
@ -220,3 +202,21 @@ export function useBuildComponentIdAndBeginOptions(
return [...beginOptions, ...componentIdOptions];
}
export const useGetComponentLabelByValue = (nodeId: string) => {
const options = useBuildComponentIdAndBeginOptions(nodeId);
const flattenOptions = useMemo(() => {
return options.reduce<DefaultOptionType[]>((pre, cur) => {
return [...pre, ...cur.options];
}, []);
}, [options]);
const getLabel = useCallback(
(val?: string) => {
return flattenOptions.find((x) => x.value === val)?.label;
},
[flattenOptions],
);
return getLabel;
};