### What problem does this PR solve? Feat: Add loop operator node. #10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
27 lines
811 B
TypeScript
27 lines
811 B
TypeScript
import { SwitchOperatorOptions } from '@/constants/agent';
|
|
import { camelCase, toLower } from 'lodash';
|
|
import { useCallback } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { LoopTerminationStringComparisonOperatorMap } from '../../constant';
|
|
|
|
export function useBuildLogicalOptions() {
|
|
const { t } = useTranslation();
|
|
|
|
const buildLogicalOptions = useCallback(
|
|
(type: string) => {
|
|
return LoopTerminationStringComparisonOperatorMap[
|
|
toLower(type) as keyof typeof LoopTerminationStringComparisonOperatorMap
|
|
]?.map((x) => ({
|
|
label: t(
|
|
`flow.switchOperatorOptions.${camelCase(SwitchOperatorOptions.find((y) => y.value === x)?.label || x)}`,
|
|
),
|
|
value: x,
|
|
}));
|
|
},
|
|
[t],
|
|
);
|
|
|
|
return {
|
|
buildLogicalOptions,
|
|
};
|
|
}
|