From 9c24affbd12b95a8d450d81ebec35e916dfd8cec Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 8 Feb 2024 14:16:03 -0300 Subject: [PATCH] Refactor globalVariablesStore to use optional provider --- src/frontend/src/stores/globalVariables.ts | 5 +++-- src/frontend/src/types/zustand/globalVariables/index.ts | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/stores/globalVariables.ts b/src/frontend/src/stores/globalVariables.ts index 8eaaa3282..377cd00f0 100644 --- a/src/frontend/src/stores/globalVariables.ts +++ b/src/frontend/src/stores/globalVariables.ts @@ -11,8 +11,9 @@ export const useGlobalVariablesStore = create( globalVariablesEntries: Object.keys(variables), }); }, - addGlobalVariable: (key, value) => { - const newVariables = { ...get().globalVariables, [key]: value }; + addGlobalVariable: (key, id, provider) => { + const data = { id, provider }; + const newVariables = { ...get().globalVariables, [key]: data }; set({ globalVariables: newVariables, globalVariablesEntries: Object.keys(newVariables), diff --git a/src/frontend/src/types/zustand/globalVariables/index.ts b/src/frontend/src/types/zustand/globalVariables/index.ts index ed81caf1c..95c15a310 100644 --- a/src/frontend/src/types/zustand/globalVariables/index.ts +++ b/src/frontend/src/types/zustand/globalVariables/index.ts @@ -1,9 +1,9 @@ export type GlobalVariablesStore = { globalVariablesEntries: Array; - globalVariables: { [key: string]: { id: string; provider: string } }; + globalVariables: { [key: string]: { id: string; provider?: string } }; setGlobalVariables: (variables: { - [key: string]: { id: string; provider: string }; + [key: string]: { id: string; provider?: string }; }) => void; - addGlobalVariable: (key: string, value: string, provider?: string) => void; + addGlobalVariable: (key: string, id: string, provider?: string) => void; removeGlobalVariable: (key: string) => void; };