From e773227e4a94f86caf6ca807482d77519a09e5e2 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 30 Apr 2024 16:49:26 +0200 Subject: [PATCH] Added fields to request for creating new variable --- .../addNewVariableButtonComponent/addNewVariableButton.tsx | 5 +++-- src/frontend/src/stores/globalVariables.ts | 4 ++-- src/frontend/src/types/zustand/globalVariables/index.ts | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/components/addNewVariableButtonComponent/addNewVariableButton.tsx b/src/frontend/src/components/addNewVariableButtonComponent/addNewVariableButton.tsx index 6ab25b026..aae36775d 100644 --- a/src/frontend/src/components/addNewVariableButtonComponent/addNewVariableButton.tsx +++ b/src/frontend/src/components/addNewVariableButtonComponent/addNewVariableButton.tsx @@ -26,15 +26,16 @@ export default function AddNewVariableButton({ children }): JSX.Element { (state) => state.addGlobalVariable ); function handleSaveVariable() { - let data: { name: string; value: string; type?: string } = { + let data: { name: string; value: string; type?: string; default_fields?: string[] } = { name: key, type, value, + default_fields: fields }; registerGlobalVariable(data) .then((res) => { const { name, id, type } = res.data; - addGlobalVariable(name, id, type); + addGlobalVariable(name, id, type, fields); setKey(""); setValue(""); setType(""); diff --git a/src/frontend/src/stores/globalVariables.ts b/src/frontend/src/stores/globalVariables.ts index d9a326b08..ff0514042 100644 --- a/src/frontend/src/stores/globalVariables.ts +++ b/src/frontend/src/stores/globalVariables.ts @@ -21,8 +21,8 @@ export const useGlobalVariablesStore = create( globalVariablesEntries: Object.keys(variables), }); }, - addGlobalVariable: (name, id, type) => { - const data = { id, type }; + addGlobalVariable: (name, id, type, default_fields) => { + const data = { id, type, default_fields }; const newVariables = { ...get().globalVariables, [name]: data }; set({ globalVariables: newVariables, diff --git a/src/frontend/src/types/zustand/globalVariables/index.ts b/src/frontend/src/types/zustand/globalVariables/index.ts index c5f6c24d2..d34973a17 100644 --- a/src/frontend/src/types/zustand/globalVariables/index.ts +++ b/src/frontend/src/types/zustand/globalVariables/index.ts @@ -1,10 +1,10 @@ export type GlobalVariablesStore = { globalVariablesEntries: Array; - globalVariables: { [name: string]: { id: string; type?: string } }; + globalVariables: { [name: string]: { id: string; type?: string, default_fields?: string[] } }; setGlobalVariables: (variables: { - [name: string]: { id: string; type?: string }; + [name: string]: { id: string; type?: string, default_fields?: string[]}; }) => void; - addGlobalVariable: (name: string, id: string, type?: string) => void; + addGlobalVariable: (name: string, id: string, type?: string, default_fields?: string[]) => void; removeGlobalVariable: (name: string) => void; getVariableId: (name: string) => string | undefined; unavaliableFields: Set;