import React, { useState } from 'react'; import { invoke } from '@tauri-apps/api/core'; interface SettingsProps { isOpen: boolean; onClose: () => void; apiKey: string; onApiKeyChange: (key: string) => void; } const DEFAULT_API_KEY = 'AIzaSyAF825tPTh77oL0knsGFEyvsN0iPUO_bXc'; export const Settings: React.FC = ({ isOpen, onClose, apiKey, onApiKeyChange }) => { const [testing, setTesting] = useState(false); const [testResult, setTestResult] = useState(null); const handleApiKeyChange = (e: React.ChangeEvent) => { onApiKeyChange(e.target.value); }; const resetToDefault = () => { onApiKeyChange(DEFAULT_API_KEY); }; const testApiKey = async () => { setTesting(true); setTestResult(null); try { await invoke('test_gemini_api', { apiKey }); setTestResult('API key is valid'); } catch (error) { setTestResult(`Error: ${error}`); } finally { setTesting(false); } }; if (!isOpen) return null; return (

Settings

{apiKey !== DEFAULT_API_KEY && ( )}
{testResult && (
{testResult}
)}
); };