'use client'; import { AlertCircle, ExternalLink, X, Settings, Key } from 'lucide-react'; import { GeminiErrorInfo } from '@/lib/geminiErrorHandler'; import { ApiKeyInfo, getApiKeySourceDescription } from '@/lib/apiKeyHelper'; import { useRouter } from 'next/navigation'; interface GeminiErrorModalProps { error: GeminiErrorInfo; apiKeyInfo: ApiKeyInfo; onClose: () => void; } export function GeminiErrorModal({ error, apiKeyInfo, onClose }: GeminiErrorModalProps) { const router = useRouter(); const handleGoToSettings = () => { onClose(); router.push('/settings'); }; return (
{/* Header */}

{error.isQuotaError ? 'API Quota Exceeded' : 'API Error'}

{/* Content */}
{/* API Key Info */}

Current API Key:

{apiKeyInfo.anonymized}

Source: {getApiKeySourceDescription(apiKeyInfo.source)}

{error.userMessage}

{error.retryAfterSeconds && (

You can try again in {error.retryAfterSeconds} seconds.

)} {error.isQuotaError && (

Solutions:

    {apiKeyInfo.source === 'localStorage' && (
  • Change your API key to a different one with available quota
  • )}
  • Upgrade to a paid Gemini API plan for higher quotas
  • Wait until tomorrow for your free tier quota to reset
  • Use the chess tutor less frequently throughout the day
  • {apiKeyInfo.source === 'env' && (
  • Update the NEXT_PUBLIC_GEMINI_API_KEY environment variable
  • )}
{/* Change API Key button (if from localStorage) */} {apiKeyInfo.source === 'localStorage' && ( )} View Gemini API Pricing Check Your API Usage
)} {/* Technical details (collapsible) */}
Technical details
              {error.technicalMessage}
            
{/* Footer */}
); }