From 911d6813208b3b27b51e8398b34e2a64f1b769b8 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 5 Feb 2024 18:07:05 -0300 Subject: [PATCH] feat(addNewVariableButton.tsx): implement form logic to handle saving new global variables feat(globalVariables.ts): add functions to add and remove global variables in the store feat(globalVariables/index.ts): add types for the new functions in the global variables store --- .../components/addNewVariableButton.tsx | 24 ++++++++++++++++--- src/frontend/src/stores/globalVariables.ts | 15 ++++++++++++ .../types/zustand/globalVariables/index.ts | 2 ++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/pages/globalVariablesPage/components/addNewVariableButton.tsx b/src/frontend/src/pages/globalVariablesPage/components/addNewVariableButton.tsx index 59e86fe3e..17f815c60 100644 --- a/src/frontend/src/pages/globalVariablesPage/components/addNewVariableButton.tsx +++ b/src/frontend/src/pages/globalVariablesPage/components/addNewVariableButton.tsx @@ -1,13 +1,19 @@ +import { useState } from "react"; import { Button } from "../../../components/ui/button"; import { Input } from "../../../components/ui/input"; import { Label } from "../../../components/ui/label"; import { Textarea } from "../../../components/ui/textarea"; +import { registerGlobalVariable } from "../../../controllers/API"; import BaseModal from "../../../modals/baseModal"; //TODO IMPLEMENT FORM LOGIC export default function AddNewVariableButton(): JSX.Element { - function handleSaveVariable() {} + const [key, setKey] = useState(""); + const [value, setValue] = useState(""); + function handleSaveVariable() { + registerGlobalVariable(key, value).then((_) => {}); + } return (
- + { + setKey(e.target.value); + }} + placeholder="example name" + >
-