Refactor globalVariablesStore to use optional provider

This commit is contained in:
anovazzi1 2024-02-08 14:16:03 -03:00
commit 9c24affbd1
2 changed files with 6 additions and 5 deletions

View file

@ -11,8 +11,9 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
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),

View file

@ -1,9 +1,9 @@
export type GlobalVariablesStore = {
globalVariablesEntries: Array<string>;
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;
};