"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { ArrowRight, Loader2 } from "lucide-react"; interface ExampleRepo { name: string; description: string; language: string; languageColor: string; } interface ExampleRepoCardProps { repo: ExampleRepo; } export function ExampleRepoCard({ repo }: ExampleRepoCardProps) { const [isLoading, setIsLoading] = useState(false); const router = useRouter(); const handleGenerate = async () => { const repoUrl = `https://github.com/${repo.name}`; setIsLoading(true); try { const response = await fetch("/api/generate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ repoUrl }), }); if (!response.ok) { const data = await response.json(); throw new Error(data.error || "Failed to start generation"); } const data = await response.json(); router.push(`/generate?repo=${encodeURIComponent(repoUrl)}&id=${data.id}`); } catch (err) { setIsLoading(false); } }; return (
{repo.description}