Refactor registerGlobalVariable function signature

This commit is contained in:
anovazzi1 2024-02-08 15:36:18 -03:00
commit c724d1131a
2 changed files with 15 additions and 6 deletions

View file

@ -864,11 +864,15 @@ export async function getGlobalVariables(): Promise<{
return globalVariables; return globalVariables;
} }
export async function registerGlobalVariable( export async function registerGlobalVariable({
name: string, name,
value: string, value,
provider?: string provider,
) { }: {
name: string;
value: string;
provider?: string;
}) {
return await api.post(`${BASE_URL_API}credentials/`, { return await api.post(`${BASE_URL_API}credentials/`, {
name, name,
value, value,

View file

@ -19,7 +19,12 @@ export default function AddNewVariableButton(): JSX.Element {
(state) => state.addGlobalVariable (state) => state.addGlobalVariable
); );
function handleSaveVariable() { function handleSaveVariable() {
registerGlobalVariable(key, value, provider).then((_) => { let data: { name: string; value: string; provider?: string } = {
name: key,
value,
};
if (provider) data = { ...data, provider };
registerGlobalVariable(data).then((_) => {
addGlobalVariable(key, value, provider); addGlobalVariable(key, value, provider);
setKey(""); setKey("");
setValue(""); setValue("");