diff --git a/src/components/ApiSettings.tsx b/src/components/ApiSettings.tsx new file mode 100644 index 0000000..59f8cab --- /dev/null +++ b/src/components/ApiSettings.tsx @@ -0,0 +1,72 @@ +import { useEffect, useState } from "react"; + +const ApiSettings = () => { + const [apiKey, setApiKey] = useState(""); + const [isSaved, setIsSaved] = useState(false); + + useEffect(() => { + chrome.storage.local.get("genai_api_key", (result) => { + if (result.genai_api_key) { + setApiKey(result.genai_api_key as string); + } + }); + }, []); + + const handleSave = () => { + chrome.storage.local.set({ genai_api_key: apiKey }, () => { + setIsSaved(true); + setTimeout(() => setIsSaved(false), 2000); + }); + }; + + return ( +
+

API & Security

+ +
+
+

Bring Your Own Key (BYOK)

+

+ To use Lexiflow, you must provide your own Google Gemini API key. + This key is stored securely in your browser's local storage and is never sent to our servers. +

+
+ +
+ + setApiKey(e.target.value)} + /> +

+ You can get a free API key from Google AI Studio. +

+
+ +
+ + {isSaved && ( + + + + + Saved successfully + + )} +
+
+
+ ); +}; + +export default ApiSettings; diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx index d73c806..55e4433 100644 --- a/src/components/SettingsPage.tsx +++ b/src/components/SettingsPage.tsx @@ -2,6 +2,7 @@ import { useState, useEffect } from "react"; import GeneralSettings from "./GeneralSettings"; import Integrations from "./Integrations"; import GlossarySettings from "./GlossarySettings"; +import ApiSettings from "./ApiSettings"; import { LexiFlowSettingsProvider } from "../context/LexiFlowSettingsContext"; const SettingsPage = () => { @@ -20,6 +21,8 @@ const SettingsPage = () => { switch (activeTab) { case "#general": return ; + case "#api": + return ; case "#integrations": return ; case "#glossary": @@ -54,6 +57,19 @@ const SettingsPage = () => { > General Settings +