()
| 14 | const OUTLINE_BUTTON_CLASSES = "border-cyan-400/50 hover:border-cyan-400 bg-transparent transition-colors text-cyan-50 shadow-[0_0_10px_rgba(34,211,238,0.1)] w-full sm:w-auto h-12 rounded-full font-semibold uppercase tracking-widest text-xs"; |
| 15 | |
| 16 | const HeroSection = () => { |
| 17 | const [stars, setStars] = useState<number | null>(null); |
| 18 | const [forks, setForks] = useState<number | null>(null); |
| 19 | const [version, setVersion] = useState(""); |
| 20 | const [copied, setCopied] = useState(false); |
| 21 | |
| 22 | // Indexing states |
| 23 | const [activeTab, setActiveTab] = useState<'client' | 'server'>('client'); |
| 24 | const [repoUrl, setRepoUrl] = useState(""); |
| 25 | const [email, setEmail] = useState(""); |
| 26 | const [generationStatus, setGenerationStatus] = useState<any>({ status: "idle" }); |
| 27 | const [progress, setProgress] = useState(0); |
| 28 | const [graphData, setGraphData] = useState<any>(null); |
| 29 | |
| 30 | useEffect(() => { |
| 31 | async function fetchVersion() { |
| 32 | try { |
| 33 | const res = await fetch( |
| 34 | "https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/README.md" |
| 35 | ); |
| 36 | if (!res.ok) throw new Error("Failed to fetch README"); |
| 37 | const text = await res.text(); |
| 38 | const match = text.match(/\*\*Version:\*\*\s*([0-9]+\.[0-9]+\.[0-9]+)/i); |
| 39 | setVersion(match ? match[1] : "N/A"); |
| 40 | } catch (err) { |
| 41 | setVersion("N/A"); |
| 42 | } |
| 43 | } |
| 44 | fetchVersion(); |
| 45 | }, []); |
| 46 | |
| 47 | useEffect(() => { |
| 48 | fetch("https://api.github.com/repos/CodeGraphContext/CodeGraphContext") |
| 49 | .then((response) => response.json()) |
| 50 | .then((data) => { |
| 51 | setStars(data.stargazers_count); |
| 52 | setForks(data.forks_count); |
| 53 | }) |
| 54 | .catch((error) => console.error("Error fetching GitHub stats:", error)); |
| 55 | }, []); |
| 56 | |
| 57 | const handleCopy = async () => { |
| 58 | try { |
| 59 | await navigator.clipboard.writeText("pip install codegraphcontext"); |
| 60 | setCopied(true); |
| 61 | toast.success("Copied to clipboard!"); |
| 62 | setTimeout(() => setCopied(false), 2000); |
| 63 | } catch (err) { |
| 64 | toast.error("Failed to copy"); |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | const handleGenerateBundle = async () => { |
| 69 | if (!repoUrl.trim()) { |
| 70 | toast.error("Please enter a GitHub repository URL"); |
| 71 | return; |
| 72 | } |
| 73 |
nothing calls this directly
no test coverage detected