import React, { useState, useEffect } from 'react'; import { motion } from 'framer-motion'; import { X, Key, Eye, EyeOff, Loader2 } from 'lucide-react'; import { useBodyScrollLock } from '../hooks/useBodyScrollLock'; interface ApiKeyModalProps { isOpen: boolean; onClose: () => void; apiKey: string | undefined; onSave: (key: string | undefined) => Promise; saving: boolean; hasAIAccess: boolean; } export const ApiKeyModal: React.FC = ({ isOpen, onClose, apiKey, onSave, saving, hasAIAccess, }) => { useBodyScrollLock(isOpen); const [localApiKey, setLocalApiKey] = useState(apiKey || ''); const [showApiKey, setShowApiKey] = useState(false); useEffect(() => { if (isOpen) { setLocalApiKey(apiKey || ''); } }, [isOpen, apiKey]); if (!isOpen) return null; const handleSave = async () => { await onSave(localApiKey || undefined); onClose(); }; return ( e.stopPropagation()} >

Account Settings

Manage your API access

{hasAIAccess ? (

Custom Gemini API Key

Use your own API key for quiz generation. Leave empty to use the system key.

setLocalApiKey(e.target.value)} placeholder="AIza..." className="w-full px-4 py-3 pr-12 rounded-xl border-2 border-gray-200 focus:border-theme-primary focus:outline-none text-gray-800" />
) : (

API access not available

Contact an administrator for access

)}
{hasAIAccess && ( )}
); };