import { useState } from 'react'; import { useGitHub } from '@/hooks/useGitHub'; import { useGitHubStore } from '@/stores/githubStore'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; import { Github, Loader2 } from 'lucide-react'; interface RepoImporterProps { open: boolean; onClose: () => void; } export default function RepoImporter({ open, onClose }: RepoImporterProps) { const [url, setUrl] = useState(''); const { importRepo, isImporting } = useGitHub(); const importProgress = useGitHubStore((s) => s.importProgress); const [error, setError] = useState(''); const handleImport = async () => { if (!url.trim()) return; setError(''); try { await importRepo(url.trim()); onClose(); } catch (err) { setError((err as Error).message || 'Failed to import repository'); } }; return ( !o && onClose()}> Import from GitHub Paste a GitHub repository URL to import and analyze.
setUrl(e.target.value)} placeholder="https://github.com/owner/repo or owner/repo" disabled={isImporting} onKeyDown={(e) => e.key === 'Enter' && handleImport()} /> {error &&

{error}

} {isImporting && (
{importProgress || 'Importing...'}
)}
); }