Skip to content

Commit

Permalink
MAT-7797 pass in the right data for edit
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-cecilialiu committed Dec 19, 2024
1 parent d18e7c7 commit 71f2b1c
Showing 1 changed file with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Funct {
functionsArguments: any;
comment?: string;
expressionEditorValue?: string;
logic?: string;
}

export interface FunctionProps {
Expand Down Expand Up @@ -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 (
<div>
<form id="function-form" onSubmit={formik.handleSubmit}>
Expand Down Expand Up @@ -245,13 +271,15 @@ export default function FunctionBuilder({
onClick={
operation === "edit"
? () => {
const functionToApply = {
functionName: formik.values.functionName,
comment: formik.values.comment,
functionsArguments: formik.values.functionsArguments,
fluentFunction: formik.values.fluentFunction,
expressionValue: formik.values.expressionEditorValue,
const functionToEdit = {
functionName: funct.name,
comment: funct.comment,
functionsArguments: funct.functionsArguments,
fluentFunction: funct.fluentFunction,
expressionValue: funct.expressionEditorValue,
expression: funct.logic,
};
handleFunctionEdit(functionToEdit, getEditedFunction());
}
: () => {
const functionToApply = {
Expand Down

0 comments on commit 71f2b1c

Please sign in to comment.