import { useState } from 'react'; import { Dialog, DialogTitle, DialogContent, DialogActions, TextField, Button, Alert, CircularProgress, Typography, Box, } from '@mui/material'; import { useAuthStore } from '@/store/authStore'; interface AnthropicKeyModalProps { open: boolean; onClose: () => void; } export function AnthropicKeyModal({ open, onClose }: AnthropicKeyModalProps) { const [apiKey, setApiKey] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const [error, setError] = useState(null); const { setAnthropicKey } = useAuthStore(); const handleSubmit = async () => { if (!apiKey.trim()) { setError('Please enter your API key'); return; } setIsSubmitting(true); setError(null); const success = await setAnthropicKey(apiKey.trim()); setIsSubmitting(false); if (success) { setApiKey(''); onClose(); } else { setError('Failed to validate API key. Please check and try again.'); } }; const handleClose = () => { setApiKey(''); setError(null); onClose(); }; return ( Anthropic API Key Required To use the AI agent, you need to provide your own Anthropic API key. Your key is stored securely and only used for this session. Get your API key from{' '} console.anthropic.com {error && ( {error} )} setApiKey(e.target.value)} placeholder="sk-ant-..." disabled={isSubmitting} onKeyDown={(e) => { if (e.key === 'Enter' && !isSubmitting) { handleSubmit(); } }} /> ); }