Update global variable type in API and store

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-25 09:59:10 -03:00
commit 8292cb8cfa
3 changed files with 11 additions and 11 deletions

View file

@ -860,13 +860,13 @@ export async function requestLogout() {
}
export async function getGlobalVariables(): Promise<{
[key: string]: { id: string; provider: string };
[key: string]: { id: string; type: string };
}> {
const globalVariables = {};
(await api.get(`${BASE_URL_API}variables/`)).data.forEach((element) => {
globalVariables[element.name] = {
id: element.id,
provider: element.provider,
type: element.type,
};
});
return globalVariables;
@ -875,16 +875,16 @@ export async function getGlobalVariables(): Promise<{
export async function registerGlobalVariable({
name,
value,
provider,
type,
}: {
name: string;
value: string;
provider?: string;
}): Promise<AxiosResponse<{ name: string; id: string; provider: string }>> {
type?: string;
}): Promise<AxiosResponse<{ name: string; id: string; type: string }>> {
return await api.post(`${BASE_URL_API}variables/`, {
name,
value,
provider,
type,
});
}

View file

@ -11,8 +11,8 @@ export const useGlobalVariablesStore = create<GlobalVariablesStore>(
globalVariablesEntries: Object.keys(variables),
});
},
addGlobalVariable: (name, id, provider) => {
const data = { id, provider };
addGlobalVariable: (name, id, type) => {
const data = { id, type };
const newVariables = { ...get().globalVariables, [name]: data };
set({
globalVariables: newVariables,

View file

@ -1,10 +1,10 @@
export type GlobalVariablesStore = {
globalVariablesEntries: Array<string>;
globalVariables: { [name: string]: { id: string; provider?: string } };
globalVariables: { [name: string]: { id: string; type?: string } };
setGlobalVariables: (variables: {
[name: string]: { id: string; provider?: string };
[name: string]: { id: string; type?: string };
}) => void;
addGlobalVariable: (name: string, id: string, provider?: string) => void;
addGlobalVariable: (name: string, id: string, type?: string) => void;
removeGlobalVariable: (name: string) => void;
getVariableId: (name: string) => string | undefined;
};