Refactor addNewVariableButtonComponent and API registerGlobalVariable

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-21 14:01:05 -03:00
commit 69735b070f
2 changed files with 7 additions and 6 deletions

View file

@ -1,13 +1,13 @@
import { useState } from "react";
import { registerGlobalVariable } from "../../controllers/API";
import BaseModal from "../../modals/baseModal";
import { useGlobalVariablesStore } from "../../stores/globalVariables";
import ForwardedIconComponent from "../genericIconComponent";
import InputComponent from "../inputComponent";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { Label } from "../ui/label";
import { Textarea } from "../ui/textarea";
import { registerGlobalVariable } from "../../controllers/API";
import BaseModal from "../../modals/baseModal";
import { useGlobalVariablesStore } from "../../stores/globalVariables";
//TODO IMPLEMENT FORM LOGIC
@ -25,8 +25,9 @@ export default function AddNewVariableButton({ children }): JSX.Element {
value,
};
if (provider) data = { ...data, provider };
registerGlobalVariable(data).then((_) => {
addGlobalVariable(key, value, provider);
registerGlobalVariable(data).then((res) => {
const { name, id, provider } = res.data;
addGlobalVariable(name, id, provider);
setKey("");
setValue("");
setProvider("");

View file

@ -880,7 +880,7 @@ export async function registerGlobalVariable({
name: string;
value: string;
provider?: string;
}) {
}): Promise<AxiosResponse<{ name: string; id: string; provider: string }>> {
return await api.post(`${BASE_URL_API}credentials/`, {
name,
value,