Update global variable type in API and store
This commit is contained in:
parent
6d258a78ea
commit
8292cb8cfa
3 changed files with 11 additions and 11 deletions
|
|
@ -860,13 +860,13 @@ export async function requestLogout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getGlobalVariables(): Promise<{
|
export async function getGlobalVariables(): Promise<{
|
||||||
[key: string]: { id: string; provider: string };
|
[key: string]: { id: string; type: string };
|
||||||
}> {
|
}> {
|
||||||
const globalVariables = {};
|
const globalVariables = {};
|
||||||
(await api.get(`${BASE_URL_API}variables/`)).data.forEach((element) => {
|
(await api.get(`${BASE_URL_API}variables/`)).data.forEach((element) => {
|
||||||
globalVariables[element.name] = {
|
globalVariables[element.name] = {
|
||||||
id: element.id,
|
id: element.id,
|
||||||
provider: element.provider,
|
type: element.type,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return globalVariables;
|
return globalVariables;
|
||||||
|
|
@ -875,16 +875,16 @@ export async function getGlobalVariables(): Promise<{
|
||||||
export async function registerGlobalVariable({
|
export async function registerGlobalVariable({
|
||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
provider,
|
type,
|
||||||
}: {
|
}: {
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
provider?: string;
|
type?: string;
|
||||||
}): Promise<AxiosResponse<{ name: string; id: string; provider: string }>> {
|
}): Promise<AxiosResponse<{ name: string; id: string; type: string }>> {
|
||||||
return await api.post(`${BASE_URL_API}variables/`, {
|
return await api.post(`${BASE_URL_API}variables/`, {
|
||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
provider,
|
type,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
|
||||||
globalVariablesEntries: Object.keys(variables),
|
globalVariablesEntries: Object.keys(variables),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addGlobalVariable: (name, id, provider) => {
|
addGlobalVariable: (name, id, type) => {
|
||||||
const data = { id, provider };
|
const data = { id, type };
|
||||||
const newVariables = { ...get().globalVariables, [name]: data };
|
const newVariables = { ...get().globalVariables, [name]: data };
|
||||||
set({
|
set({
|
||||||
globalVariables: newVariables,
|
globalVariables: newVariables,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export type GlobalVariablesStore = {
|
export type GlobalVariablesStore = {
|
||||||
globalVariablesEntries: Array<string>;
|
globalVariablesEntries: Array<string>;
|
||||||
globalVariables: { [name: string]: { id: string; provider?: string } };
|
globalVariables: { [name: string]: { id: string; type?: string } };
|
||||||
setGlobalVariables: (variables: {
|
setGlobalVariables: (variables: {
|
||||||
[name: string]: { id: string; provider?: string };
|
[name: string]: { id: string; type?: string };
|
||||||
}) => void;
|
}) => void;
|
||||||
addGlobalVariable: (name: string, id: string, provider?: string) => void;
|
addGlobalVariable: (name: string, id: string, type?: string) => void;
|
||||||
removeGlobalVariable: (name: string) => void;
|
removeGlobalVariable: (name: string) => void;
|
||||||
getVariableId: (name: string) => string | undefined;
|
getVariableId: (name: string) => string | undefined;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue