diff --git a/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx b/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx index 48ae78a..9784793 100644 --- a/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx +++ b/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx @@ -26,6 +26,7 @@ export interface Funct { functionsArguments: any; comment?: string; expressionEditorValue?: string; + logic?: string; } export interface FunctionProps { @@ -129,6 +130,31 @@ export default function FunctionBuilder({ formik.setFieldValue("functionsArguments", newArgs); }; + const getFunctionArguments = (args) => { + let argStr = ""; + args?.forEach((arg) => { + argStr += arg.argumentName + " " + arg.dataType + ", "; + }); + argStr = argStr.substring(0, argStr.length - 2); + return argStr; + }; + const getEditedFunction = (): string => { + let logic = ""; + if (formik.values.comment) { + logic += "/*\n" + formik.values.comment + "\n*/\n"; + } + logic += "define "; + if (formik.values.fluentFunction) { + logic += "fluent "; + } + logic += "function "; + logic += formik.values.functionName + " "; + logic += + "(" + getFunctionArguments(formik.values.functionsArguments) + "):\n"; + logic += formik.values.expressionEditorValue; + return logic; + }; + return (