Refactor globalVariablesStore to use optional provider
This commit is contained in:
parent
b76eb655b2
commit
9c24affbd1
2 changed files with 6 additions and 5 deletions
|
|
@ -11,8 +11,9 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
||||||
globalVariablesEntries: Object.keys(variables),
|
globalVariablesEntries: Object.keys(variables),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addGlobalVariable: (key, value) => {
|
addGlobalVariable: (key, id, provider) => {
|
||||||
const newVariables = { ...get().globalVariables, [key]: value };
|
const data = { id, provider };
|
||||||
|
const newVariables = { ...get().globalVariables, [key]: data };
|
||||||
set({
|
set({
|
||||||
globalVariables: newVariables,
|
globalVariables: newVariables,
|
||||||
globalVariablesEntries: Object.keys(newVariables),
|
globalVariablesEntries: Object.keys(newVariables),
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
export type GlobalVariablesStore = {
|
export type GlobalVariablesStore = {
|
||||||
globalVariablesEntries: Array<string>;
|
globalVariablesEntries: Array<string>;
|
||||||
globalVariables: { [key: string]: { id: string; provider: string } };
|
globalVariables: { [key: string]: { id: string; provider?: string } };
|
||||||
setGlobalVariables: (variables: {
|
setGlobalVariables: (variables: {
|
||||||
[key: string]: { id: string; provider: string };
|
[key: string]: { id: string; provider?: string };
|
||||||
}) => void;
|
}) => void;
|
||||||
addGlobalVariable: (key: string, value: string, provider?: string) => void;
|
addGlobalVariable: (key: string, id: string, provider?: string) => void;
|
||||||
removeGlobalVariable: (key: string) => void;
|
removeGlobalVariable: (key: string) => void;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue