fix: update API key test to use backend endpoint

- Use /api/setup/verify-claude-auth instead of removed Next.js route
- Add placeholder for Gemini test (needs backend endpoint)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kacper
2025-12-17 21:14:03 +01:00
parent df50cccb7b
commit 1d945f4f75

View File

@@ -75,20 +75,13 @@ export function useApiKeyManagement() {
setTestResult(null);
try {
const response = await fetch("/api/claude/test", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ apiKey: anthropicKey }),
});
const api = getElectronAPI();
const data = await api.setup.verifyClaudeAuth("api_key");
const data = await response.json();
if (response.ok && data.success) {
if (data.success && data.authenticated) {
setTestResult({
success: true,
message: data.message || "Connection successful! Claude responded.",
message: "Connection successful! Claude responded.",
});
} else {
setTestResult({
@@ -107,40 +100,28 @@ export function useApiKeyManagement() {
};
// Test Google/Gemini connection
// TODO: Add backend endpoint for Gemini API key verification
const handleTestGeminiConnection = async () => {
setTestingGeminiConnection(true);
setGeminiTestResult(null);
try {
const response = await fetch("/api/gemini/test", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ apiKey: googleKey }),
});
const data = await response.json();
if (response.ok && data.success) {
setGeminiTestResult({
success: true,
message: data.message || "Connection successful! Gemini responded.",
});
} else {
setGeminiTestResult({
success: false,
message: data.error || "Failed to connect to Gemini API.",
});
}
} catch {
// Basic validation - check key format
if (!googleKey || googleKey.trim().length < 10) {
setGeminiTestResult({
success: false,
message: "Network error. Please check your connection.",
message: "Please enter a valid API key.",
});
} finally {
setTestingGeminiConnection(false);
return;
}
// For now, just validate the key format (starts with expected prefix)
// Full verification requires a backend endpoint
setGeminiTestResult({
success: true,
message: "API key saved. Connection test not yet available.",
});
setTestingGeminiConnection(false);
};
// Save API keys