Add provider field to AddNewVariableButton component

This commit is contained in:
anovazzi1 2024-02-08 15:29:41 -03:00
commit 021612f5ae

View file

@ -1,4 +1,5 @@
import { useState } from "react"; import { useState } from "react";
import InputComponent from "../../../components/inputComponent";
import { Button } from "../../../components/ui/button"; import { Button } from "../../../components/ui/button";
import { Input } from "../../../components/ui/input"; import { Input } from "../../../components/ui/input";
import { Label } from "../../../components/ui/label"; import { Label } from "../../../components/ui/label";
@ -12,15 +13,17 @@ import { useGlobalVariablesStore } from "../../../stores/globalVariables";
export default function AddNewVariableButton(): JSX.Element { export default function AddNewVariableButton(): JSX.Element {
const [key, setKey] = useState(""); const [key, setKey] = useState("");
const [value, setValue] = useState(""); const [value, setValue] = useState("");
const [provider, setProvider] = useState("");
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const addGlobalVariable = useGlobalVariablesStore( const addGlobalVariable = useGlobalVariablesStore(
(state) => state.addGlobalVariable (state) => state.addGlobalVariable
); );
function handleSaveVariable() { function handleSaveVariable() {
registerGlobalVariable(key, value).then((_) => { registerGlobalVariable(key, value, provider).then((_) => {
addGlobalVariable(key, value); addGlobalVariable(key, value, provider);
setKey(""); setKey("");
setValue(""); setValue("");
setProvider("");
setOpen(false); setOpen(false);
}); });
} }
@ -45,6 +48,16 @@ export default function AddNewVariableButton(): JSX.Element {
}} }}
placeholder="example name" placeholder="example name"
></Input> ></Input>
<Label>Provider (optional) </Label>
<InputComponent
value={provider}
onChange={(e) => {
setProvider(e);
}}
password={false}
options={["OPENAI_API_KEY", "ANTHROPIC_API_KEY"]}
placeholder="example provider"
></InputComponent>
</div> </div>
<div className="h-1/2"> <div className="h-1/2">
<Label>Variable Value </Label> <Label>Variable Value </Label>