'use client'; import React, { useState } from 'react'; import { useApiKey } from '../contexts/ApiKeyContext'; interface ApiKeyPromptProps { show: boolean; onClose?: () => void; } export function ApiKeyPrompt({ show, onClose }: ApiKeyPromptProps) { const { setApiKey } = useApiKey(); const [inputValue, setInputValue] = useState(''); const [error, setError] = useState(''); if (!show) return null; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); if (!inputValue.trim()) { setError('API key is required'); return; } // Test the API key by making a simple request try { const response = await fetch('/api/obsStatus', { headers: { 'x-api-key': inputValue.trim() } }); if (response.ok) { setApiKey(inputValue.trim()); setInputValue(''); onClose?.(); } else { setError('Invalid API key'); } } catch { setError('Failed to validate API key'); } }; return (

API Key Required

This application requires an API key for access. Please enter your API key to continue.

setInputValue(e.target.value)} className="w-full text-white focus:outline-none focus:ring-2 focus:ring-blue transition-all" style={{ padding: '12px 24px', background: 'rgba(7, 54, 66, 0.4)', backdropFilter: 'blur(10px)', border: '1px solid rgba(88, 110, 117, 0.3)', borderRadius: '12px', fontSize: '16px' }} placeholder="Enter your API key" autoFocus /> {error && (

{error}

)}
{onClose && ( )}
); } export function ApiKeyBanner() { const { isAuthenticated, clearApiKey } = useApiKey(); const [showPrompt, setShowPrompt] = useState(false); if (isAuthenticated) { return (
Authenticated
setShowPrompt(false)} />
); } return ( <>
⚠️ API key required for full access
setShowPrompt(false)} /> ); }