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),
|
||||
});
|
||||
},
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue